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
34 lines
1.4 KiB
Elixir
34 lines
1.4 KiB
Elixir
defmodule ChesstrainerWeb.Board.PieceComponent do
|
|
@moduledoc """
|
|
Chess pieces component
|
|
"""
|
|
use Phoenix.Component
|
|
|
|
attr :piece, :any, required: true
|
|
attr :class, :string, default: ""
|
|
|
|
def piece(assigns) do
|
|
assigns = assign(assigns, :path, piece_path(assigns.piece))
|
|
|
|
~H"""
|
|
<%= if @path do %>
|
|
<img src={@path} class={@class} alt="" aria-hidden="true" />
|
|
<% end %>
|
|
"""
|
|
end
|
|
|
|
def piece_path({:king, :white, _square}), do: "/images/pieces/white/king.svg"
|
|
def piece_path({:queen, :white, _square}), do: "/images/pieces/white/queen.svg"
|
|
def piece_path({:rook, :white, _square}), do: "/images/pieces/white/rook.svg"
|
|
def piece_path({:bishop, :white, _square}), do: "/images/pieces/white/bishop.svg"
|
|
def piece_path({:knight, :white, _square}), do: "/images/pieces/white/knight.svg"
|
|
def piece_path({:pawn, :white, _square}), do: "/images/pieces/white/pawn.svg"
|
|
def piece_path({:king, :black, _square}), do: "/images/pieces/black/king.svg"
|
|
def piece_path({:queen, :black, _square}), do: "/images/pieces/black/queen.svg"
|
|
def piece_path({:rook, :black, _square}), do: "/images/pieces/black/rook.svg"
|
|
def piece_path({:bishop, :black, _square}), do: "/images/pieces/black/bishop.svg"
|
|
def piece_path({:knight, :black, _square}), do: "/images/pieces/black/knight.svg"
|
|
def piece_path({:pawn, :black, _square}), do: "/images/pieces/black/pawn.svg"
|
|
def piece_path(_), do: nil
|
|
end
|