<%= for rank <- @ranks do %>
<%= for file <- @files do %>
@@ -45,6 +53,7 @@ defmodule ChesstrainerWeb.Board.BoardComponent do
files_list={@files_list}
move_from_square={@game.move_from_square}
myself={@myself}
+ interactive={@interactive}
/>
<% end %>
<% end %>
diff --git a/lib/chesstrainer_web/components/board/square_component.ex b/lib/chesstrainer_web/components/board/square_component.ex
index f538db8..251a974 100644
--- a/lib/chesstrainer_web/components/board/square_component.ex
+++ b/lib/chesstrainer_web/components/board/square_component.ex
@@ -10,7 +10,8 @@ defmodule ChesstrainerWeb.Board.SquareComponent do
attr :piece, :any, default: nil
attr :files_list, :list, required: true
attr :move_from_square, :any, default: nil
- attr :myself, :any, required: true
+ attr :myself, :any, default: nil
+ attr :interactive, :boolean, default: true
def square(assigns) do
current_square = {assigns.file, assigns.rank}
@@ -22,20 +23,20 @@ defmodule ChesstrainerWeb.Board.SquareComponent do
~H"""
f == @file end),
@rank - 1
),
highlight_square(@highlight_square)
]}
- phx-click="square-click"
- phx-value-file={@file}
- phx-value-rank={@rank}
- phx-value-type="move"
- phx-target={@myself}
+ phx-click={@interactive && "square-click"}
+ phx-value-file={@interactive && @file}
+ phx-value-rank={@interactive && @rank}
+ phx-value-type={@interactive && "move"}
+ phx-target={@interactive && @myself}
>
- <.piece piece={@piece} class="w-10 h-10" />
+ <.piece piece={@piece} class="w-[83%] h-[83%]" />
"""
end
diff --git a/lib/chesstrainer_web/live/endgame_live/form.ex b/lib/chesstrainer_web/live/endgame_live/form.ex
index a2ad25a..4ebb97d 100644
--- a/lib/chesstrainer_web/live/endgame_live/form.ex
+++ b/lib/chesstrainer_web/live/endgame_live/form.ex
@@ -7,6 +7,8 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
alias Chesstrainer.Endgames
alias Chesstrainer.Endgames.Endgame
+ import ChesstrainerWeb.Board.BoardComponent
+
@impl true
def render(assigns) do
~H"""
@@ -73,26 +75,36 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
<.form for={@form} id="endgame-form" phx-change="validate" phx-submit="save">
- <.input field={@form[:fen]} type="text" label="Fen" disabled={@live_action == :edit} />
- <.input field={@form[:color]} type="text" label="Color" disabled />
- <.input
- field={@form[:rating]}
- type="number"
- value={rating_display(@form[:rating])}
- label="Rating"
- />
- <.input field={@form[:message]} type="textarea" label="Message" />
- <.input field={@form[:notes]} type="textarea" label="Notes" />
- <.input
- field={@form[:result]}
- type="select"
- options={[
- {"Win", :win},
- {"Draw", :draw},
- {"Loss", :loss}
- ]}
- label="Result"
- />
+
+
+ <.input field={@form[:fen]} type="text" label="Fen" disabled={@live_action == :edit} />
+ <.input field={@form[:color]} type="text" label="Color" disabled />
+ <.input
+ field={@form[:rating]}
+ type="number"
+ value={rating_display(@form[:rating])}
+ label="Rating"
+ />
+ <.input field={@form[:message]} type="textarea" label="Message" />
+ <.input field={@form[:notes]} type="textarea" label="Notes" />
+ <.input
+ field={@form[:result]}
+ type="select"
+ options={[
+ {"Win", :win},
+ {"Draw", :draw},
+ {"Loss", :loss}
+ ]}
+ label="Result"
+ />
+
+
+
+ Current position
+ <.board game={@preview_game} class="w-full mt-2" interactive={false} />
+
+