mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
landing page (#63)
* remove daisyui and rebuild styles * very basic setup of new design - missing components etc * basic navbar with reusable landing components * basic puzzle of the day * update todos * update todos * add curated landing puzzle cards with selectable board (#55) * update with footer * add button to solve today's puzzle * Make landing page a dead view Render the home page from PageController with a static board preview, link puzzle cards and CTAs to public-code play routes, count puzzles from the DB, and add a global footer. * Serve a marketing-only JS bundle on the landing page Build a small marketing entry point with phoenix_html and the plain-DOM navbar, select it on controller-rendered pages, and keep the full LiveView bundle for LiveView pages. * Add landing page SEO metadata Replace the Phoenix default title with a descriptive Lucid Chess title, and add description, canonical, Open Graph, and Twitter card tags to the landing page. * Complete the hero copy block Add the spark icon primitive and the Endgames, made clear eyebrow. The primary CTA keeps linking to the active puzzle rather than scrolling to the board. * Add a persisted global daily puzzle Assign one endgame per UTC day in a daily_puzzles table with a unique date, preferring endgames unused in the last 30 days and falling back to any. Concurrent first requests insert with on-conflict-ignore and read the winning row. The landing board now shows the daily puzzle. * remove unused CSS, nav links, time pill * allow devices to connect to dev server by changing IP address to 0.0.0.0 * Restore the colour-mode switch and add a dark palette * Use brand colour tokens on the play page * self host fonts - closes issue #62 * begin splitting CSS into modules * remove hover on hero chessboard, split more css modules * remove interactivity from hero chessboard * update todo
This commit is contained in:
@@ -16,25 +16,21 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
|
||||
<:subtitle>Use this form to manage endgame records in your database.</:subtitle>
|
||||
</.header>
|
||||
|
||||
<div class="field mb-6">
|
||||
<label class="label">
|
||||
<span class="label-text">Themes</span>
|
||||
</label>
|
||||
<div class="mb-6">
|
||||
<span class="mb-1 block text-sm font-medium text-base-content">Themes</span>
|
||||
|
||||
<div class="flex flex-wrap gap-2 mb-2">
|
||||
<%= for theme <- @selected_themes do %>
|
||||
<span class="badge badge-primary gap-1">
|
||||
{theme.name}
|
||||
<button
|
||||
type="button"
|
||||
phx-click="remove_theme"
|
||||
phx-value-id={theme.id}
|
||||
aria-label={"Remove #{theme.name}"}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</span>
|
||||
<% end %>
|
||||
<.badge :for={theme <- @selected_themes} color="primary">
|
||||
{theme.name}
|
||||
<button
|
||||
type="button"
|
||||
phx-click="remove_theme"
|
||||
phx-value-id={theme.id}
|
||||
aria-label={"Remove #{theme.name}"}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</.badge>
|
||||
</div>
|
||||
|
||||
<form
|
||||
@@ -42,30 +38,36 @@ defmodule ChesstrainerWeb.EndgameLive.Form do
|
||||
phx-change="search_themes"
|
||||
phx-submit="create_theme_from_search"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
<.input
|
||||
name="theme_search"
|
||||
value={@theme_query}
|
||||
phx-debounce="200"
|
||||
autocomplete="off"
|
||||
placeholder="Search or create a theme…"
|
||||
class="input input-bordered w-full"
|
||||
/>
|
||||
|
||||
<ul class="menu bg-base-100 rounded-box mt-2">
|
||||
<%= for theme <- @theme_results do %>
|
||||
<li>
|
||||
<button type="button" phx-click="add_theme" phx-value-id={theme.id}>{theme.name}</button>
|
||||
</li>
|
||||
<% end %>
|
||||
<ul class="mt-2 w-full rounded-md border border-base-300 bg-base-100 p-1 shadow-sm">
|
||||
<li :for={theme <- @theme_results}>
|
||||
<button
|
||||
type="button"
|
||||
phx-click="add_theme"
|
||||
phx-value-id={theme.id}
|
||||
class="block w-full rounded px-3 py-2 text-left text-sm hover:bg-base-200"
|
||||
>
|
||||
{theme.name}
|
||||
</button>
|
||||
</li>
|
||||
|
||||
<%= if @can_create do %>
|
||||
<li>
|
||||
<button type="button" phx-click="create_theme" phx-value-name={@theme_query}>
|
||||
Create theme "{String.trim(@theme_query)}"
|
||||
</button>
|
||||
</li>
|
||||
<% end %>
|
||||
<li :if={@can_create}>
|
||||
<button
|
||||
type="button"
|
||||
phx-click="create_theme"
|
||||
phx-value-name={@theme_query}
|
||||
class="block w-full rounded px-3 py-2 text-left text-sm hover:bg-base-200"
|
||||
>
|
||||
Create theme "{String.trim(@theme_query)}"
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -31,7 +31,6 @@ defmodule ChesstrainerWeb.EndgameLive.Index do
|
||||
label="Find by ID or FEN"
|
||||
autocomplete="off"
|
||||
placeholder="Public code, database id, or FEN…"
|
||||
class="input input-bordered w-full"
|
||||
/>
|
||||
</div>
|
||||
<.button variant="primary">Find</.button>
|
||||
@@ -40,7 +39,12 @@ defmodule ChesstrainerWeb.EndgameLive.Index do
|
||||
<div :if={@search_query} id="endgame-search-results" class="space-y-3">
|
||||
<div class="flex items-center justify-between">
|
||||
<p class="text-sm text-base-content/70">Results for “{@search_query}”</p>
|
||||
<button type="button" id="clear-endgame-search" phx-click="clear_search" class="link">
|
||||
<button
|
||||
type="button"
|
||||
id="clear-endgame-search"
|
||||
phx-click="clear_search"
|
||||
class="text-sm text-primary underline underline-offset-4 hover:text-primary/80"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
</div>
|
||||
@@ -49,7 +53,7 @@ defmodule ChesstrainerWeb.EndgameLive.Index do
|
||||
No endgame matches “{@search_query}”.
|
||||
</p>
|
||||
|
||||
<table :if={@search_results != []} class="table table-zebra">
|
||||
<table :if={@search_results != []} class={table_class()}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
@@ -115,11 +119,11 @@ defmodule ChesstrainerWeb.EndgameLive.Index do
|
||||
{endgame.result}
|
||||
</td>
|
||||
<td>
|
||||
<span :for={theme <- endgame.themes} class="badge badge-sm">
|
||||
<.badge :for={theme <- endgame.themes} size="sm">
|
||||
<button type="button" phx-click="add_theme" phx-value-id={theme.id}>
|
||||
{theme.name}
|
||||
</button>
|
||||
</span>
|
||||
</.badge>
|
||||
<span :if={endgame.themes == []} class="text-base-content/50">None</span>
|
||||
</td>
|
||||
<td
|
||||
|
||||
@@ -19,7 +19,7 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
|
||||
0} · Solved: {@endgame.times_solved || 0}<span :if={@user_rating}> · Your rating: {round(
|
||||
@user_rating
|
||||
)}</span>
|
||||
<p class="text-xs text-gray-500 flex items-center mt-1">
|
||||
<p class="text-xs text-muted flex items-center mt-1">
|
||||
<span>FEN: {@endgame.fen}</span>
|
||||
<button
|
||||
id="copy-fen-btn"
|
||||
@@ -39,7 +39,7 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<div class="flex gap-2 bg-gray-200 p-4 rounded-xl shadow-inner">
|
||||
<div class="flex gap-2 bg-base-200 p-4 rounded-xl shadow-inner">
|
||||
<div
|
||||
id="endgame-board"
|
||||
phx-hook="ChessBoard"
|
||||
@@ -50,78 +50,78 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
|
||||
</div>
|
||||
|
||||
<div class="w-48 h-100 flex flex-col gap-3">
|
||||
<div class="rounded-lg bg-white p-3 text-sm">
|
||||
<div class="rounded-lg bg-canvas-raised p-3 text-sm">
|
||||
<%= cond do %>
|
||||
<% @status == :loading -> %>
|
||||
<p class="text-gray-500">Loading tablebase…</p>
|
||||
<p class="text-muted">Loading tablebase…</p>
|
||||
<% @status == :blocked -> %>
|
||||
<p class="font-semibold text-red-600">Tablebase unavailable</p>
|
||||
<p class="text-red-500">{@blocked_reason}</p>
|
||||
<p class="font-semibold text-error">Tablebase unavailable</p>
|
||||
<p class="text-error">{@blocked_reason}</p>
|
||||
<% @status == :solved -> %>
|
||||
<p class="font-semibold text-emerald-600">
|
||||
<p class="font-semibold text-success-text">
|
||||
{if @endgame.result == :draw, do: "Draw held!", else: "Solved!"}
|
||||
</p>
|
||||
<% @status == :failed -> %>
|
||||
<p class="font-semibold text-red-600">Failed</p>
|
||||
<p class="text-red-500">
|
||||
<p class="font-semibold text-error">Failed</p>
|
||||
<p class="text-error">
|
||||
{if @endgame.result == :draw,
|
||||
do: "That move loses the draw.",
|
||||
else: "That move throws away the win."}
|
||||
</p>
|
||||
<%= if @best_move && @plies != [] do %>
|
||||
<p class="text-gray-600">
|
||||
<p class="text-muted">
|
||||
You played {List.last(@plies).san}; best was: {@best_move}
|
||||
</p>
|
||||
<% end %>
|
||||
<% @awaiting_reply -> %>
|
||||
<p class="text-gray-500">Opponent is replying…</p>
|
||||
<p class="text-muted">Opponent is replying…</p>
|
||||
<% @last_grade == :optimal -> %>
|
||||
<p class="font-semibold text-emerald-600">Optimal move</p>
|
||||
<p class="font-semibold text-success-text">Optimal move</p>
|
||||
<% @last_grade == :winning -> %>
|
||||
<p class="font-semibold text-amber-600">
|
||||
<p class="font-semibold text-warning">
|
||||
{if @endgame.result == :draw,
|
||||
do: "Keeps the draw — but not the sharpest",
|
||||
else: "Winning — but not the sharpest"}
|
||||
</p>
|
||||
<% @last_grade == :losing -> %>
|
||||
<p class="font-semibold text-red-600">
|
||||
<p class="font-semibold text-error">
|
||||
{if @endgame.result == :draw,
|
||||
do: "Losing move — this loses the draw",
|
||||
else: "Losing move — this throws away the win"}
|
||||
</p>
|
||||
<% @last_grade == :unknown -> %>
|
||||
<p class="font-semibold text-gray-600">Could not grade that move</p>
|
||||
<p class="font-semibold text-muted">Could not grade that move</p>
|
||||
<% true -> %>
|
||||
<p class="text-gray-500">Make a move to have it graded.</p>
|
||||
<p class="text-muted">Make a move to have it graded.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div :if={@reviewing} id="best-move-panel" class="rounded-lg bg-white p-3 text-sm">
|
||||
<div :if={@reviewing} id="best-move-panel" class="rounded-lg bg-canvas-raised p-3 text-sm">
|
||||
<%= cond do %>
|
||||
<% @review_blocked -> %>
|
||||
<p class="text-gray-500">Best move unavailable here</p>
|
||||
<p class="text-gray-400">{@review_blocked}</p>
|
||||
<p class="text-muted">Best move unavailable here</p>
|
||||
<p class="text-muted">{@review_blocked}</p>
|
||||
<% @review_tablebase -> %>
|
||||
<p class="text-gray-600 font-semibold mb-1">Best move:</p>
|
||||
<p class="text-emerald-600">{best_move_text(@review_tablebase) || "—"}</p>
|
||||
<p class="text-muted font-semibold mb-1">Best move:</p>
|
||||
<p class="text-success-text">{best_move_text(@review_tablebase) || "—"}</p>
|
||||
<%= if played_ply = played_ply_at(@line, @review_index) do %>
|
||||
<p class={["mt-1", grade_class(played_ply.grade)]}>Played: {played_ply.san}</p>
|
||||
<% end %>
|
||||
<% true -> %>
|
||||
<p class="text-gray-500">No best move.</p>
|
||||
<p class="text-muted">No best move.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="move-list" class="flex-1 min-h-0 flex flex-col bg-white rounded-lg p-3">
|
||||
<div id="move-list" class="flex-1 min-h-0 flex flex-col bg-canvas-raised rounded-lg p-3">
|
||||
<% plies = display_plies(@reviewing, @line, @plies) %>
|
||||
<p class="text-sm text-gray-600 font-semibold mb-2">Moves:</p>
|
||||
<p class="text-sm text-muted font-semibold mb-2">Moves:</p>
|
||||
<div class="flex-1 overflow-y-auto">
|
||||
<%= if plies == [] do %>
|
||||
<p class="text-sm text-gray-500">No Moves</p>
|
||||
<p class="text-sm text-muted">No Moves</p>
|
||||
<% else %>
|
||||
<%= for {[white_ply, black_ply], move_no} <- move_rows(plies, @endgame.color) do %>
|
||||
<div class="font-mono text-sm leading-6">
|
||||
<span class="text-gray-500 mr-2">{move_no}.</span>
|
||||
<span class="text-muted mr-2">{move_no}.</span>
|
||||
<%= if white_ply do %>
|
||||
<.ply
|
||||
ply={white_ply}
|
||||
@@ -130,7 +130,7 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
|
||||
result={@endgame.result}
|
||||
/>
|
||||
<% else %>
|
||||
<span class="text-gray-900">...</span>
|
||||
<span class="text-body">...</span>
|
||||
<% end %>
|
||||
<%= if black_ply do %>
|
||||
<.ply
|
||||
@@ -504,16 +504,16 @@ defmodule ChesstrainerWeb.EndgameLive.Play do
|
||||
end
|
||||
end
|
||||
|
||||
defp ply_class(%{best_line: true}), do: "text-sky-600 italic"
|
||||
defp ply_class(%{best_line: true}), do: "text-info italic"
|
||||
defp ply_class(ply), do: grade_class(ply.grade)
|
||||
|
||||
defp ply_title(%{best_line: true}, _result), do: "Best line"
|
||||
defp ply_title(ply, result), do: grade_label(ply.grade, result)
|
||||
|
||||
defp grade_class(:optimal), do: "text-emerald-600"
|
||||
defp grade_class(:winning), do: "text-amber-600"
|
||||
defp grade_class(:losing), do: "text-red-600"
|
||||
defp grade_class(_), do: "text-gray-900"
|
||||
defp grade_class(:optimal), do: "text-success-text"
|
||||
defp grade_class(:winning), do: "text-warning"
|
||||
defp grade_class(:losing), do: "text-error"
|
||||
defp grade_class(_), do: "text-body"
|
||||
|
||||
defp grade_label(nil, _result), do: nil
|
||||
defp grade_label(:optimal, _result), do: "Optimal move"
|
||||
|
||||
@@ -52,11 +52,11 @@ defmodule ChesstrainerWeb.EndgameLive.PlayerIndex do
|
||||
{round(endgame.rating)}
|
||||
</td>
|
||||
<td>
|
||||
<span :for={theme <- endgame.themes} class="badge badge-sm">
|
||||
<.badge :for={theme <- endgame.themes} size="sm">
|
||||
<button type="button" phx-click="add_theme" phx-value-id={theme.id}>
|
||||
{theme.name}
|
||||
</button>
|
||||
</span>
|
||||
</.badge>
|
||||
<span :if={endgame.themes == []} class="text-base-content/50">None</span>
|
||||
</td>
|
||||
<td class="w-0 font-semibold">
|
||||
|
||||
@@ -15,7 +15,7 @@ defmodule ChesstrainerWeb.UserLive.Login do
|
||||
<% else %>
|
||||
Don't have an account? <.link
|
||||
navigate={~p"/users/register"}
|
||||
class="font-semibold text-brand hover:underline"
|
||||
class="font-semibold text-primary hover:underline"
|
||||
phx-no-format
|
||||
>Sign up</.link> for an account now.
|
||||
<% end %>
|
||||
@@ -47,10 +47,10 @@ defmodule ChesstrainerWeb.UserLive.Login do
|
||||
autocomplete="current-password"
|
||||
spellcheck="false"
|
||||
/>
|
||||
<.button class="btn btn-primary w-full" name={@form[:remember_me].name} value="true">
|
||||
<.button variant="primary" class="w-full" name={@form[:remember_me].name} value="true">
|
||||
Log in and stay logged in <span aria-hidden="true">→</span>
|
||||
</.button>
|
||||
<.button class="btn btn-primary btn-soft w-full mt-2">
|
||||
<.button class="w-full mt-2">
|
||||
Log in only this time
|
||||
</.button>
|
||||
</.form>
|
||||
|
||||
@@ -14,7 +14,7 @@ defmodule ChesstrainerWeb.UserLive.Registration do
|
||||
Register for an account
|
||||
<:subtitle>
|
||||
Already registered?
|
||||
<.link navigate={~p"/users/log-in"} class="font-semibold text-brand hover:underline">
|
||||
<.link navigate={~p"/users/log-in"} class="font-semibold text-primary hover:underline">
|
||||
Log in
|
||||
</.link>
|
||||
to your account now.
|
||||
@@ -57,7 +57,7 @@ defmodule ChesstrainerWeb.UserLive.Registration do
|
||||
required
|
||||
/>
|
||||
|
||||
<.button phx-disable-with="Creating account..." class="btn btn-primary w-full">
|
||||
<.button phx-disable-with="Creating account..." variant="primary" class="w-full">
|
||||
Create an account
|
||||
</.button>
|
||||
</.form>
|
||||
|
||||
@@ -28,7 +28,7 @@ defmodule ChesstrainerWeb.UserLive.Settings do
|
||||
<.button variant="primary" phx-disable-with="Changing...">Change Email</.button>
|
||||
</.form>
|
||||
|
||||
<div class="divider" />
|
||||
<hr class="my-6 border-base-200" />
|
||||
|
||||
<.form
|
||||
for={@password_form}
|
||||
@@ -66,7 +66,7 @@ defmodule ChesstrainerWeb.UserLive.Settings do
|
||||
</.button>
|
||||
</.form>
|
||||
|
||||
<div class="divider" />
|
||||
<hr class="my-6 border-base-200" />
|
||||
|
||||
<section id="delete_account" class="space-y-4">
|
||||
<.header>
|
||||
@@ -79,15 +79,14 @@ defmodule ChesstrainerWeb.UserLive.Settings do
|
||||
Nothing can be recovered.
|
||||
</p>
|
||||
|
||||
<button
|
||||
<.button
|
||||
id="delete_account_button"
|
||||
type="button"
|
||||
class="btn btn-error"
|
||||
variant="danger"
|
||||
phx-click="delete_account"
|
||||
data-confirm="This permanently deletes your account and all of your data. Nothing can be recovered. Are you sure?"
|
||||
>
|
||||
Delete my account
|
||||
</button>
|
||||
</.button>
|
||||
</section>
|
||||
</Layouts.app>
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user