mirror of
https://github.com/TheRealOwenRees/chess-endgame-trainer.git
synced 2026-11-18 11:42:07 +00:00
* commented out lesson and learning strip until lessons are established * reword the hero section * change layout and working on puzzle section - remove top div as it was redundant * amend flash message on replay * switch cancel session for return home * remove system theme toggle since this is the default, leaving only light and dark toggles * add keyboard and screen reader support for play (#72) First draft covering the accessibility work in #72:\n\n- labelled SAN/UCI move input, validated against the tablebase and applied\n by the board hook, plus an accessible promotion picker\n- live-region announcements for moves, checks, checkmates and solve/fail,\n and a hidden text summary of the position\n- accessible labels, focus ring, skip link, keyboard-friendly review table\n and non-colour grade cues\n- WCAG AA text contrast roles and a responsive play surface\n- regression tests for move entry, announcements and link-style CTAs
85 lines
2.5 KiB
Elixir
85 lines
2.5 KiB
Elixir
defmodule ChesstrainerWeb.UserLive.Login do
|
|
use ChesstrainerWeb, :live_view
|
|
|
|
@impl true
|
|
def render(assigns) do
|
|
~H"""
|
|
<Layouts.app flash={@flash} current_scope={@current_scope}>
|
|
<div class="mx-auto max-w-sm space-y-4">
|
|
<div class="text-center">
|
|
<h1 class="settings-header">Log in</h1>
|
|
<%= if @current_scope do %>
|
|
You need to reauthenticate to perform sensitive actions on your account.
|
|
<% else %>
|
|
<p class="settings-subtitle my-4">
|
|
Don't have an account? <.link
|
|
navigate={~p"/users/register"}
|
|
class="font-semibold text-primary-text hover:underline"
|
|
phx-no-format
|
|
>Sign up</.link> for an account now.
|
|
</p>
|
|
<% end %>
|
|
</div>
|
|
|
|
<.form
|
|
:let={f}
|
|
for={@form}
|
|
id="login_form_password"
|
|
action={~p"/users/log-in"}
|
|
phx-submit="submit_password"
|
|
phx-trigger-action={@trigger_submit}
|
|
>
|
|
<.input
|
|
readonly={!!@current_scope}
|
|
field={f[:email]}
|
|
type="text"
|
|
label="Email or username"
|
|
autocomplete="username"
|
|
spellcheck="false"
|
|
required
|
|
/>
|
|
<.input
|
|
field={@form[:password]}
|
|
type="password"
|
|
label="Password"
|
|
autocomplete="current-password"
|
|
spellcheck="false"
|
|
/>
|
|
<.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="w-full mt-2">
|
|
Log in only this time
|
|
</.button>
|
|
</.form>
|
|
|
|
<p class="text-center text-sm">
|
|
<.link
|
|
navigate={~p"/users/reset-password"}
|
|
class="font-semibold text-primary-text hover:underline"
|
|
>
|
|
Forgot your password?
|
|
</.link>
|
|
</p>
|
|
</div>
|
|
</Layouts.app>
|
|
"""
|
|
end
|
|
|
|
@impl true
|
|
def mount(_params, _session, socket) do
|
|
email =
|
|
Phoenix.Flash.get(socket.assigns.flash, :email) ||
|
|
get_in(socket.assigns, [:current_scope, Access.key(:user), Access.key(:email)])
|
|
|
|
form = to_form(%{"email" => email}, as: "user")
|
|
|
|
{:ok, assign(socket, form: form, trigger_submit: false)}
|
|
end
|
|
|
|
@impl true
|
|
def handle_event("submit_password", _params, socket) do
|
|
{:noreply, assign(socket, :trigger_submit, true)}
|
|
end
|
|
end
|