From 7658450573e9169779fc57e87e7ebc67b0865491 Mon Sep 17 00:00:00 2001 From: Owen Date: Mon, 2 Nov 2026 11:04:04 +0100 Subject: [PATCH] Full-width list/show pages and trim the admin table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List and show pages now use a wide container (max-w-7xl) while the form and play pages keep the narrow column. The admin table drops Fen, Message, Notes, Attempted and Solved — all already shown on the show page — so it fits without right-overflow. Closes #16 --- lib/chesstrainer_web/components/layouts.ex | 6 +++- .../live/endgame_live/index.ex | 30 ++++--------------- .../live/endgame_live/player_index.ex | 2 +- .../live/endgame_live/show.ex | 2 +- .../live/endgame_live/form_test.exs | 4 ++- .../live/endgame_live/index_test.exs | 22 ++++++++++++-- .../live/endgame_live/play_test.exs | 1 + .../live/endgame_live/player_index_test.exs | 1 + 8 files changed, 36 insertions(+), 32 deletions(-) diff --git a/lib/chesstrainer_web/components/layouts.ex b/lib/chesstrainer_web/components/layouts.ex index e8d199c..cb46d96 100644 --- a/lib/chesstrainer_web/components/layouts.ex +++ b/lib/chesstrainer_web/components/layouts.ex @@ -31,12 +31,16 @@ defmodule ChesstrainerWeb.Layouts do default: nil, doc: "the current [scope](https://phoenix.hexdocs.pm/scopes.html)" + attr :wide, :boolean, + default: false, + doc: "use a wide container instead of the default narrow column" + slot :inner_block, required: true def app(assigns) do ~H"""
-
+
{render_slot(@inner_block)}
diff --git a/lib/chesstrainer_web/live/endgame_live/index.ex b/lib/chesstrainer_web/live/endgame_live/index.ex index fc4c440..628e4ee 100644 --- a/lib/chesstrainer_web/live/endgame_live/index.ex +++ b/lib/chesstrainer_web/live/endgame_live/index.ex @@ -8,7 +8,7 @@ defmodule ChesstrainerWeb.EndgameLive.Index do @impl true def render(assigns) do ~H""" - + <.header> Listing Endgames <:actions> @@ -29,39 +29,22 @@ defmodule ChesstrainerWeb.EndgameLive.Index do <.grouped_list :if={@groups != []} groups={@groups}> <:header> - Fen - Color Key - Rating - Message - Notes + Color Result Themes - Attempted - Solved + Rating Actions <:row :let={endgame}> endgame.id}> - - {endgame.fen} - - - {endgame.color} - {endgame.key} - {endgame.rating} - - - {endgame.message} - - - {endgame.notes} + {endgame.color} {endgame.result} @@ -75,10 +58,7 @@ defmodule ChesstrainerWeb.EndgameLive.Index do None - {endgame.times_attempted} - - - {endgame.times_solved} + {endgame.rating}
diff --git a/lib/chesstrainer_web/live/endgame_live/player_index.ex b/lib/chesstrainer_web/live/endgame_live/player_index.ex index 826b8d5..77a4588 100644 --- a/lib/chesstrainer_web/live/endgame_live/player_index.ex +++ b/lib/chesstrainer_web/live/endgame_live/player_index.ex @@ -6,7 +6,7 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndex do @impl true def render(assigns) do ~H""" - + <.header> Endgames <:subtitle>Pick an endgame to play. diff --git a/lib/chesstrainer_web/live/endgame_live/show.ex b/lib/chesstrainer_web/live/endgame_live/show.ex index c6be616..27dea47 100644 --- a/lib/chesstrainer_web/live/endgame_live/show.ex +++ b/lib/chesstrainer_web/live/endgame_live/show.ex @@ -25,7 +25,7 @@ defmodule ChesstrainerWeb.EndgameLive.Show do |> assign(:game_type, :endgame) ~H""" - + <.header> Endgame {@endgame.id} <:subtitle>This is a endgame record from your database. diff --git a/test/chesstrainer_web/live/endgame_live/form_test.exs b/test/chesstrainer_web/live/endgame_live/form_test.exs index 7d06d43..f8e4f8f 100644 --- a/test/chesstrainer_web/live/endgame_live/form_test.exs +++ b/test/chesstrainer_web/live/endgame_live/form_test.exs @@ -13,7 +13,9 @@ defmodule ChesstrainerWeb.EndgameLive.FormTest do test "creates an endgame with staged themes", %{conn: conn} do theme = theme_fixture(%{name: "Lucena"}) - {:ok, view, _html} = live(conn, ~p"/admin/endgames/new") + {:ok, view, html} = live(conn, ~p"/admin/endgames/new") + + assert html =~ "max-w-2xl" view |> form("#theme-form", %{theme_search: "Luc"}) |> render_change() view |> element("button", "Lucena") |> render_click() diff --git a/test/chesstrainer_web/live/endgame_live/index_test.exs b/test/chesstrainer_web/live/endgame_live/index_test.exs index f8f16c7..455814e 100644 --- a/test/chesstrainer_web/live/endgame_live/index_test.exs +++ b/test/chesstrainer_web/live/endgame_live/index_test.exs @@ -11,12 +11,28 @@ defmodule ChesstrainerWeb.EndgameLive.IndexTest do endgame_fixture() endgame_fixture() - {:ok, view, _html} = live(conn, ~p"/admin/endgames") + {:ok, view, html} = live(conn, ~p"/admin/endgames") + assert html =~ "max-w-7xl" assert has_element?(view, "#key-group-K-v-K") assert has_element?(view, "#key-group-K-v-K .badge", "2") end + test "trims the table to the key columns", %{conn: conn} do + endgame_fixture() + + {:ok, view, _html} = live(conn, ~p"/admin/endgames") + view |> element("#key-group-K-v-K button") |> render_click() + + for label <- ~w(Key Color Result Themes Rating) do + assert has_element?(view, "th", label) + end + + for label <- ~w(Fen Message Notes Attempted Solved) do + refute has_element?(view, "th", label) + end + end + test "lazy-loads a group's endgames when expanded", %{conn: conn} do theme = theme_fixture(%{name: "Lucena"}) endgame = endgame_fixture() @@ -25,13 +41,13 @@ defmodule ChesstrainerWeb.EndgameLive.IndexTest do {:ok, view, html} = live(conn, ~p"/admin/endgames") # collapsed: the endgame row (and its themes) are not rendered yet - refute html =~ endgame.fen + refute html =~ ~p"/endgames/#{endgame}/play" refute html =~ "Lucena" view |> element("#key-group-K-v-K button") |> render_click() html = render(view) - assert html =~ endgame.fen + assert html =~ ~p"/endgames/#{endgame}/play" assert html =~ "Lucena" end diff --git a/test/chesstrainer_web/live/endgame_live/play_test.exs b/test/chesstrainer_web/live/endgame_live/play_test.exs index cbba826..1e25300 100644 --- a/test/chesstrainer_web/live/endgame_live/play_test.exs +++ b/test/chesstrainer_web/live/endgame_live/play_test.exs @@ -93,6 +93,7 @@ defmodule ChesstrainerWeb.EndgameLive.PlayTest do assert html =~ "KQ v K" assert html =~ "White to move" assert html =~ "1800" + assert html =~ "max-w-2xl" end test "raises when the endgame does not exist", %{conn: conn} do diff --git a/test/chesstrainer_web/live/endgame_live/player_index_test.exs b/test/chesstrainer_web/live/endgame_live/player_index_test.exs index 3ef3f49..25c2d2c 100644 --- a/test/chesstrainer_web/live/endgame_live/player_index_test.exs +++ b/test/chesstrainer_web/live/endgame_live/player_index_test.exs @@ -16,6 +16,7 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndexTest do {:ok, view, html} = live(conn, ~p"/endgames") assert html =~ "Endgames" + assert html =~ "max-w-7xl" assert has_element?(view, "#key-group-K-v-K") refute html =~ "Lucena"