Alleggerisce Squadra e Classifica con sezioni a tendina e limita i prossimi eventi a 4.

Rimuove anche Scout Live dalle statistiche di squadra per snellire la schermata.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Cacciari
2026-09-04 12:01:13 +02:00
co-authored by Cursor
parent 9aef361bf0
commit fe1ac5434c
4 changed files with 77 additions and 31 deletions
+39 -1
View File
@@ -1,4 +1,5 @@
import type { ReactNode } from "react"; import { useState, type ReactNode } from "react";
import { ChevronDown } from "lucide-react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { statoMeta, type Stato } from "@/lib/crapp-data"; import { statoMeta, type Stato } from "@/lib/crapp-data";
import { Reveal } from "@/components/motion/Reveal"; import { Reveal } from "@/components/motion/Reveal";
@@ -52,6 +53,43 @@ export function Section({
); );
} }
/** Sezione con titolo cliccabile: il contenuto si apre e chiude. `anteprima` resta sempre visibile. */
export function SezioneTendina({
titolo,
children,
anteprima,
defaultAperta = false,
indice = 0,
}: {
titolo: string;
children: ReactNode;
anteprima?: ReactNode;
defaultAperta?: boolean;
indice?: number;
}) {
const [aperta, setAperta] = useState(defaultAperta);
return (
<Reveal as="section" indice={indice} className="px-5 py-4">
<button
type="button"
onClick={() => setAperta((v) => !v)}
className="mb-3 flex w-full items-center justify-between gap-3 text-left active:scale-[0.99]"
aria-expanded={aperta}
>
<h2 className="font-display text-lg uppercase tracking-wide">{titolo}</h2>
<ChevronDown
className={cn(
"h-4 w-4 shrink-0 text-muted-foreground transition-transform",
aperta && "rotate-180",
)}
/>
</button>
{anteprima}
{aperta ? children : null}
</Reveal>
);
}
export function StatoBadge({ stato, className }: { stato: Stato; className?: string }) { export function StatoBadge({ stato, className }: { stato: Stato; className?: string }) {
const meta = statoMeta[stato]; const meta = statoMeta[stato];
return ( return (
+11 -3
View File
@@ -128,6 +128,14 @@ function Calendario() {
? (eventiPerGiorno.get(giornoSelezionato) ?? []) ? (eventiPerGiorno.get(giornoSelezionato) ?? [])
: []; : [];
// Prossimi 4 eventi da oggi in avanti (indipendenti dal mese selezionato nella griglia).
const oggiIso = oggi
? `${oggi.anno}-${pad2(oggi.mese + 1)}-${pad2(oggi.giorno)}`
: null;
const prossimiEventi = oggiIso
? eventi.filter((e) => e.data >= oggiIso).slice(0, 4)
: [];
return ( return (
<> <>
<PageHeader titolo="Calendario" sottotitolo={`${mesiIT[mese]} ${anno} · Stagione 2026/27`} /> <PageHeader titolo="Calendario" sottotitolo={`${mesiIT[mese]} ${anno} · Stagione 2026/27`} />
@@ -267,14 +275,14 @@ function Calendario() {
<Section titolo="Prossimi eventi"> <Section titolo="Prossimi eventi">
<div className="space-y-3"> <div className="space-y-3">
{eventiMese.length > 0 ? ( {prossimiEventi.length > 0 ? (
eventiMese.map((e) => { prossimiEventi.map((e) => {
const link = linkPerEvento(e); const link = linkPerEvento(e);
return <EventoCard key={e.id} evento={e} {...(link ? { linkTo: link } : {})} />; return <EventoCard key={e.id} evento={e} {...(link ? { linkTo: link } : {})} />;
}) })
) : ( ) : (
<p className="rounded-3xl bg-card p-4 text-center text-sm text-muted-foreground shadow-card"> <p className="rounded-3xl bg-card p-4 text-center text-sm text-muted-foreground shadow-card">
Nessun evento in {mesiIT[mese]!.toLowerCase()} Nessun evento in programma
</p> </p>
)} )}
</div> </div>
+3 -3
View File
@@ -2,7 +2,7 @@ import { createFileRoute, Link } from "@tanstack/react-router";
import { ChevronRight, RefreshCw } from "lucide-react"; import { ChevronRight, RefreshCw } from "lucide-react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { formatData } from "@/lib/crapp-data"; import { formatData } from "@/lib/crapp-data";
import { PageHeader, Section } from "@/components/crapp/ui-bits"; import { PageHeader, Section, SezioneTendina } from "@/components/crapp/ui-bits";
import { useScoutMatches } from "@/lib/scout-store"; import { useScoutMatches } from "@/lib/scout-store";
import { useCsi } from "@/lib/csi"; import { useCsi } from "@/lib/csi";
import { isNostraSquadra, matchDaPartitaCsi, partiteGiocate } from "@/lib/csi-core"; import { isNostraSquadra, matchDaPartitaCsi, partiteGiocate } from "@/lib/csi-core";
@@ -123,7 +123,7 @@ function Classifica() {
</div> </div>
</Section> </Section>
<Section titolo="Storico match"> <SezioneTendina titolo="Storico match">
{tuttiMatch.length === 0 ? ( {tuttiMatch.length === 0 ? (
<p className="rounded-3xl bg-card p-4 text-center text-xs text-muted-foreground shadow-card"> <p className="rounded-3xl bg-card p-4 text-center text-xs text-muted-foreground shadow-card">
Nessun match disponibile. Nessun match disponibile.
@@ -194,7 +194,7 @@ function Classifica() {
})} })}
</div> </div>
)} )}
</Section> </SezioneTendina>
</> </>
); );
} }
+24 -24
View File
@@ -2,7 +2,7 @@ import { useState } from "react";
import { createFileRoute } from "@tanstack/react-router"; import { createFileRoute } from "@tanstack/react-router";
import { Cake, ChevronDown, Crown } from "lucide-react"; import { Cake, ChevronDown, Crown } from "lucide-react";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { PageHeader, Section } from "@/components/crapp/ui-bits"; import { PageHeader, Section, SezioneTendina } from "@/components/crapp/ui-bits";
import { Avatar } from "@/components/crapp/Avatar"; import { Avatar } from "@/components/crapp/Avatar";
import { formatData } from "@/lib/crapp-data"; import { formatData } from "@/lib/crapp-data";
import { microcopyObiettivo, progressoObiettivo } from "@/lib/obiettivi"; import { microcopyObiettivo, progressoObiettivo } from "@/lib/obiettivi";
@@ -12,7 +12,6 @@ import { totaliSquadra, useScoutMatches } from "@/lib/scout-store";
import { useCsi } from "@/lib/csi"; import { useCsi } from "@/lib/csi";
import { partiteGiocate } from "@/lib/csi-core"; import { partiteGiocate } from "@/lib/csi-core";
import { mediaSquadra, usePagelle } from "@/lib/pagelle"; import { mediaSquadra, usePagelle } from "@/lib/pagelle";
import { ScoutEntry } from "@/components/crapp/ScoutEntry";
import { StatTile } from "@/components/crapp/ui-bits"; import { StatTile } from "@/components/crapp/ui-bits";
import { Reveal } from "@/components/motion/Reveal"; import { Reveal } from "@/components/motion/Reveal";
import { Barra } from "@/components/motion/Barra"; import { Barra } from "@/components/motion/Barra";
@@ -232,12 +231,9 @@ function Squadra() {
<StatTile valore={team.ace} label="Ace squadra" /> <StatTile valore={team.ace} label="Ace squadra" />
<StatTile valore={team.muri} label="Muri squadra" /> <StatTile valore={team.muri} label="Muri squadra" />
</div> </div>
<div className="mt-3">
<ScoutEntry />
</div>
</Section> </Section>
<Section titolo="Classifica giocatori"> <SezioneTendina titolo="Classifica giocatori">
<div className="mb-3 flex flex-nowrap gap-1.5"> <div className="mb-3 flex flex-nowrap gap-1.5">
{criteri.map((c) => ( {criteri.map((c) => (
<button <button
@@ -286,25 +282,29 @@ function Squadra() {
</div> </div>
))} ))}
</div> </div>
</Section> </SezioneTendina>
<Section titolo="Obiettivi di squadra"> <SezioneTendina
<div className="mb-3 rounded-3xl bg-hero p-4 text-primary-foreground shadow-card"> titolo="Obiettivi di squadra"
<div className="flex items-end justify-between gap-3"> anteprima={
<div> <div className="mb-3 rounded-3xl bg-hero p-4 text-primary-foreground shadow-card">
<p className="text-[11px] font-semibold uppercase tracking-wide text-primary-foreground/60"> <div className="flex items-end justify-between gap-3">
Progresso collettivo <div>
</p> <p className="text-[11px] font-semibold uppercase tracking-wide text-primary-foreground/60">
<p className="font-display text-4xl leading-none"> Progresso collettivo
<Numero valore={mediaObiettivi} suffisso="%" /> </p>
<p className="font-display text-4xl leading-none">
<Numero valore={mediaObiettivi} suffisso="%" />
</p>
</div>
<p className="text-xs text-primary-foreground/70">
{completati}/{obiettivi.length} completati
</p> </p>
</div> </div>
<p className="text-xs text-primary-foreground/70"> <Barra percentuale={mediaObiettivi} trackClassName="mt-3 bg-primary-foreground/15" />
{completati}/{obiettivi.length} completati
</p>
</div> </div>
<Barra percentuale={mediaObiettivi} trackClassName="mt-3 bg-primary-foreground/15" /> }
</div> >
<div className="space-y-2"> <div className="space-y-2">
{obiettivi.map((o, i) => { {obiettivi.map((o, i) => {
const pct = progressoObiettivo(o); const pct = progressoObiettivo(o);
@@ -346,9 +346,9 @@ function Squadra() {
); );
})} })}
</div> </div>
</Section> </SezioneTendina>
<Section titolo="Badge sbloccabili"> <SezioneTendina titolo="Badge sbloccabili">
<div className="space-y-2"> <div className="space-y-2">
{badgeDefs.map((b) => { {badgeDefs.map((b) => {
const Icon = b.icon; const Icon = b.icon;
@@ -392,7 +392,7 @@ function Squadra() {
); );
})} })}
</div> </div>
</Section> </SezioneTendina>
</> </>
); );
} }