Codex (independent /codex consult) reviewed the prior card-grid layout and called it an unstructured "starter dashboard" look: too much chrome before the data, duplicated card containers competing for attention, community size outweighing actual draw results, and a real bug — CardHeader's base class is `grid`, so the `flex-row` override on LotteryCard never applied. Rebuilds around a shared data panel instead of isolated cards: - CountryNav: 200px sidebar (desktop) / horizontal scroller (mobile), replacing pill-tab filters that read as tags rather than navigation - LotteryResultsPanel + LotteryRow: one table-like panel with column headers (Loterie / Résultat / Choix / Score / Historique), not N separate bordered cards — makes draws directly comparable - LotteryMobileCard: dedicated compact mobile layout, not a shrunk desktop row - NumberSequence: shared ball component used by both layouts - --success token, independent of --accent: a winning number is always green, never the country's accent color (previously a win in France would render in France's red, which reads as a loss) - --primary now stays neutral, decoupled from --accent, so generic shadcn control states don't inherit a country's color as if it meant something semantically - New surface/text palette (page/header/panel/divider tiers) replacing the flat near-black scale - Redrawn LokiMark: clearer two-ear fox silhouette, legible at 20-24px Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
121 lines
4.3 KiB
TypeScript
121 lines
4.3 KiB
TypeScript
import { Suspense } from "react"
|
|
import { COUNTRIES, countryTheme } from "@/lib/countries"
|
|
import { getArmyFeed } from "@/lib/lokilab-feed"
|
|
import { CountryNav, CountryNavMobile } from "@/components/country-nav"
|
|
import { LotteryResultsPanel } from "@/components/lottery-results-panel"
|
|
import { LokiMark } from "@/components/loki-mark"
|
|
import { Skeleton } from "@/components/ui/skeleton"
|
|
|
|
export const instant = false
|
|
|
|
export default async function Home({
|
|
searchParams,
|
|
}: {
|
|
searchParams: Promise<{ country?: string }>
|
|
}) {
|
|
const sp = await searchParams
|
|
const activeCode = sp.country && COUNTRIES.some((c) => c.code === sp.country) ? sp.country : "CA-QC"
|
|
|
|
return (
|
|
<main className="flex flex-1 flex-col">
|
|
<AppHeader />
|
|
<Suspense fallback={<HomeSkeleton />}>
|
|
<HomeContent activeCode={activeCode} />
|
|
</Suspense>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
function AppHeader() {
|
|
return (
|
|
<div className="h-14 border-b border-border/60 bg-card">
|
|
<div className="mx-auto flex h-full max-w-6xl items-center gap-2 px-4 sm:px-6">
|
|
<LokiMark className="h-8 w-8 shrink-0 text-accent" />
|
|
<span className="text-base font-bold tracking-tight">LokiLoto</span>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
async function HomeContent({ activeCode }: { activeCode: string }) {
|
|
const feed = await getArmyFeed()
|
|
const theme = countryTheme(activeCode)
|
|
const lotteries = feed.lotteries.filter((l) => l.country === activeCode)
|
|
const totalWins = lotteries.reduce((sum, l) => sum + l.lifetime.wins, 0)
|
|
const totalTracked = lotteries.reduce((sum, l) => sum + l.lifetime.picksTracked, 0)
|
|
const countryMembers = feed.army.byCountry[activeCode] ?? 0
|
|
|
|
return (
|
|
<div
|
|
style={{ "--accent": theme.accent, "--accent-soft": theme.accentSoft } as React.CSSProperties}
|
|
className="mx-auto w-full max-w-6xl flex-1 px-4 py-4 sm:px-6"
|
|
>
|
|
<div className="sm:hidden mb-3">
|
|
<CountryNavMobile active={activeCode} />
|
|
</div>
|
|
|
|
<div className="flex gap-5">
|
|
<aside className="hidden w-[200px] shrink-0 sm:block">
|
|
<CountryNav active={activeCode} />
|
|
</aside>
|
|
|
|
<div className="min-w-0 flex-1 space-y-3">
|
|
<div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
|
|
<h1 className="text-[22px] font-bold tracking-tight">{theme.name}</h1>
|
|
<p className="text-xs text-muted-foreground">
|
|
{lotteries.length} loterie{lotteries.length === 1 ? "" : "s"} suivie
|
|
{lotteries.length === 1 ? "" : "s"}
|
|
</p>
|
|
</div>
|
|
|
|
<div className="flex h-11 items-center divide-x divide-border rounded-md border border-border/60 bg-panel px-4 text-sm">
|
|
<Stat value={feed.army.total.toLocaleString("fr-CA")} label="Armée (global)" />
|
|
<Stat value={countryMembers.toLocaleString("fr-CA")} label={`Membres — ${theme.name}`} />
|
|
<Stat
|
|
value={totalTracked > 0 ? `${totalWins} / ${totalTracked}` : "—"}
|
|
label="Grilles gagnantes"
|
|
/>
|
|
</div>
|
|
|
|
{lotteries.length > 0 ? (
|
|
<LotteryResultsPanel lotteries={lotteries} />
|
|
) : (
|
|
<div className="rounded-md border border-dashed border-border py-16 text-center text-sm text-muted-foreground">
|
|
Aucune loterie suivie pour {theme.name} pour le moment.
|
|
</div>
|
|
)}
|
|
|
|
<p className="text-[11px] text-muted-foreground">
|
|
Données fournies par LokiLab. Statistiques descriptives seulement — aucune garantie
|
|
de gain.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function Stat({ value, label }: { value: string; label: string }) {
|
|
return (
|
|
<div className="flex items-baseline gap-1.5 whitespace-nowrap px-4 first:pl-0">
|
|
<span className="font-semibold tabular-nums">{value}</span>
|
|
<span className="text-xs text-muted-foreground">{label}</span>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function HomeSkeleton() {
|
|
return (
|
|
<div className="mx-auto w-full max-w-6xl px-4 py-4 sm:px-6">
|
|
<div className="flex gap-5">
|
|
<Skeleton className="hidden h-96 w-[200px] shrink-0 sm:block" />
|
|
<div className="min-w-0 flex-1 space-y-3">
|
|
<Skeleton className="h-7 w-48" />
|
|
<Skeleton className="h-11 w-full" />
|
|
<Skeleton className="h-64 w-full" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|