mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
add puzzle training sessions with difficulty and ratings
- /train starts an ephemeral session by choosing easy/medium/hard, banded relative to the user's current rating (band width configurable) - session timer, average per-puzzle time, net rating gain and per-puzzle delta - next puzzle, plus review and retry reused from the play surface - explicit stop/start: stopping returns to the difficulty picker - puzzle rating shown once a puzzle completes, and a side-to-move indicator - extract the play logic/markup into shared PlayCore and PlayComponents so the standalone play view and sessions share one implementation - sticky footer; glossary entries for Difficulty and Session; ADR 0009
This commit is contained in:
@@ -62,7 +62,10 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
doc: "the current [scope](https://phoenix.hexdocs.pm/scopes.html)"
|
||||
|
||||
def navbar(assigns) do
|
||||
assigns = assign(assigns, :nav_links, nav_links(assigns.current_scope))
|
||||
assigns =
|
||||
assigns
|
||||
|> assign(:nav_links, nav_links(assigns.current_scope))
|
||||
|> assign(:start_href, start_href(assigns.current_scope))
|
||||
|
||||
~H"""
|
||||
<header>
|
||||
@@ -95,7 +98,7 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<.pill_button variant={:nav} href="/endgames">
|
||||
<.pill_button variant={:nav} href={@start_href}>
|
||||
Start training <.icon_arrow />
|
||||
</.pill_button>
|
||||
</div>
|
||||
@@ -139,6 +142,10 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
defp admin?(%{user: %{role: role}}), do: Role.admin?(role)
|
||||
defp admin?(_scope), do: false
|
||||
|
||||
# Signed-in users start a puzzle session; visitors browse the public list.
|
||||
defp start_href(%{user: %{}}), do: ~p"/train"
|
||||
defp start_href(_scope), do: ~p"/endgames"
|
||||
|
||||
@doc """
|
||||
Renders the site-wide footer.
|
||||
|
||||
@@ -183,7 +190,11 @@ defmodule ChesstrainerWeb.Layouts do
|
||||
|
||||
def flash_group(assigns) do
|
||||
~H"""
|
||||
<div id={@id} aria-live="polite">
|
||||
<div
|
||||
id={@id}
|
||||
aria-live="polite"
|
||||
class="pointer-events-none fixed right-4 top-4 z-50 flex w-80 max-w-80 flex-col gap-2 sm:w-96 sm:max-w-96"
|
||||
>
|
||||
<.flash kind={:info} flash={@flash} />
|
||||
<.flash kind={:error} flash={@flash} />
|
||||
|
||||
|
||||
Reference in New Issue
Block a user