Introduce la primitiva Card e sistema tocco e accessibilità dei componenti
`rounded-3xl bg-card p-4 shadow-card` era ricopiato a mano 22 volte: cambiare raggio od ombra voleva dire toccare venti file. `Card` in `ui-bits.tsx` è ora l'unica definizione delle superfici, con la gerarchia dei raggi scritta invece che implicita (contenitore 3xl, elemento interno 2xl, controllo full). Tocco e tastiera: - i chip presenza di `EventoCard` erano alti ~28 px ed è il controllo più toccato dell'app: ora `min-h-11`, con 8 px di spazio fra l'uno e l'altro; - stessa cura per il link «Apri partita», la chiusura di `CelebrazioneBadge` e il titolo di `SezioneTendina`; - `aria-pressed` sui controlli a stato, `aria-controls` sulle tendine (che avevano `aria-expanded` senza il pannello a cui si riferisce), `aria-busy` sui caricamenti; - `BottomNav`: lo stato attivo era comunicato solo dal colore. Ora cambia anche il peso del testo, compare una barretta sopra l'icona e c'è `aria-current="page"`. La voce «Home» diventa «Oggi», che dice cosa contiene. La barra è un materiale traslucido con bordo sfumato al posto della riga netta. - `Barra` espone `role="progressbar"` con i valori. Il testo sotto i 12 px è sparito (108 occorrenze fra `text-[9px]`, `text-[10px]` e `text-[11px]`): sotto quella soglia la leggibilità cala e su iOS non scala con Dynamic Type. La gerarchia la fanno peso e maiuscolo. `Avatar` aveva `alt="Foto di 12"` quando il fallback è il numero di maglia — non descrive niente e il nome è già scritto accanto, quindi alt vuoto. Aggiunti `width`/`height` per non far saltare il layout al caricamento. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ff650ecd5
commit
5c49294ad1
16 files changed
+149
-96
No files matched your search
@@ -2,6 +2,7 @@ import { useState } from "react";
|
||||
import { ClipboardCheck, Lock } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { Card } from "@/components/crapp/ui-bits";
|
||||
import { Avatar } from "@/components/crapp/Avatar";
|
||||
import type { Giocatore } from "@/lib/crapp-data";
|
||||
import { useGiocatoreCorrente } from "@/lib/user-store";
|
||||
@@ -41,21 +42,23 @@ export function Pagelle({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rounded-3xl bg-card p-4 shadow-card">
|
||||
<Card>
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<p className="inline-flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wide text-muted-foreground">
|
||||
<p className="inline-flex items-center gap-1.5 text-xs font-bold uppercase tracking-wide text-muted-foreground">
|
||||
<ClipboardCheck className="h-3.5 w-3.5" /> Pagelle anonime
|
||||
</p>
|
||||
<span className="rounded-full bg-secondary px-2.5 py-1 text-[10px] font-bold uppercase text-muted-foreground">
|
||||
<span className="rounded-full bg-secondary px-2.5 py-1 text-xs font-bold uppercase text-muted-foreground">
|
||||
{chiuse ? "Votazioni chiuse" : `${fatti}/${daVotare.length} votati`}
|
||||
</span>
|
||||
</div>
|
||||
<p className="mt-1 text-[11px] text-muted-foreground">
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
Dai un voto da 1 a 10 ai compagni: nessuno vedrà chi ha votato cosa, solo la media.
|
||||
</p>
|
||||
|
||||
{isPending ? (
|
||||
<p className="mt-3 text-xs text-muted-foreground">Carico le pagelle…</p>
|
||||
<p aria-busy="true" className="mt-3 text-xs text-muted-foreground">
|
||||
Carico le pagelle…
|
||||
</p>
|
||||
) : (
|
||||
<div className="mt-3 space-y-1.5">
|
||||
{convocati.map((g) => {
|
||||
@@ -69,12 +72,12 @@ export function Pagelle({
|
||||
<Avatar id={g.id} fallback={String(g.numero)} className="h-8 w-8 text-xs" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm font-bold leading-tight">{g.nome}</span>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{media ? `Media ${media.media} · ${media.voti} voti` : "Nessun voto"}
|
||||
</span>
|
||||
</span>
|
||||
{sonoIo ? (
|
||||
<span className="shrink-0 text-[10px] font-semibold uppercase text-muted-foreground">
|
||||
<span className="shrink-0 text-xs font-semibold uppercase text-muted-foreground">
|
||||
Sei tu
|
||||
</span>
|
||||
) : chiuse ? (
|
||||
@@ -85,7 +88,7 @@ export function Pagelle({
|
||||
disabled={!io || vota.isPending}
|
||||
onClick={() => setApertoPer(aperto ? null : g.id)}
|
||||
className={cn(
|
||||
"shrink-0 rounded-full px-3 py-1 text-[10px] font-bold uppercase transition-colors disabled:opacity-50",
|
||||
"shrink-0 rounded-full px-3 py-1 text-xs font-bold uppercase transition-colors disabled:opacity-50",
|
||||
mio !== undefined
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "bg-card text-foreground",
|
||||
@@ -103,7 +106,7 @@ export function Pagelle({
|
||||
type="button"
|
||||
onClick={() => invia(g.id, v)}
|
||||
className={cn(
|
||||
"rounded-lg py-1.5 text-[11px] font-bold tabular-nums transition-transform active:scale-90",
|
||||
"rounded-lg py-1.5 text-xs font-bold tabular-nums transition-transform active:scale-90",
|
||||
mio === v
|
||||
? "bg-accent text-accent-foreground"
|
||||
: "bg-card text-foreground",
|
||||
@@ -119,6 +122,6 @@ export function Pagelle({
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user