Show rating changes on puzzle completion (#146) (#154)

* Show rating changes in flashes and session UI (#146)

- Flash the new rating and delta on every rated completion, with a
  dedicated success flash kind for solved puzzles
- Move flash notifications to the top-left
- Add a colour-coded rating-change pill and show the current rating with
  the session's net change in the train session bar
- Show the user's rating and change beside the puzzle rating after an
  attempt, and show the finishing rating in the last-session summary

* fix header component and start reusing it

* Hide the sign-up link on the prelaunch admin login

The header refactor dropped the @prelaunch guard, so the gated admin login linked to the public registration page again.
This commit is contained in:
2026-11-12 21:13:54 +01:00
committed by GitHub
parent 9e76045862
commit 20b53dae6f
11 changed files with 135 additions and 49 deletions
@@ -30,6 +30,8 @@ defmodule ChesstrainerWeb.PlayComponents do
attr :move_input_error, :string, default: nil
attr :last_check, :boolean, default: false
attr :last_checkmate, :boolean, default: false
attr :rating, :any, default: nil
attr :rating_delta, :any, default: nil
def play_surface(assigns) do
assigns =
@@ -250,9 +252,17 @@ defmodule ChesstrainerWeb.PlayComponents do
<p class="text-muted font-bold">Make a move.</p>
<p class="text-muted">You play {colour_name(@endgame.color)}</p>
<% end %>
<p :if={@status in [:solved, :failed]} class="mt-1 text-xs text-muted">
Puzzle rating: {round(@endgame.rating)}
</p>
<div
:if={@status in [:solved, :failed]}
class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs"
>
<span class="text-muted">Puzzle rating: {round(@endgame.rating)}</span>
<span :if={@rating} id="your-rating" class="flex items-center gap-1.5 text-muted">
Your rating
<span class="font-mono font-semibold text-base-content">{round(@rating)}</span>
<.rating_change :if={@rating_delta} id="rating-change" delta={@rating_delta} />
</span>
</div>
</div>
<div