Replaces the plain proof-of-concept page with a proper design: shadcn/ui component foundation, dark theme by default, a brand bar + country selector pill nav, lottery cards with real number chips and win-state highlighting, and a shared Loki mark reskinned per country via a single --accent CSS variable (set from lib/countries.ts's flag-derived OKLCH palette) — one mascot, one layout, color is the only thing that changes per country, as specified. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
130 lines
4.6 KiB
TypeScript
130 lines
4.6 KiB
TypeScript
import { Suspense } from "react"
|
|
import { Users, Dices, Trophy } from "lucide-react"
|
|
import { COUNTRIES, countryTheme } from "@/lib/countries"
|
|
import { getArmyFeed } from "@/lib/lokilab-feed"
|
|
import { CountrySelector } from "@/components/country-selector"
|
|
import { LotteryCard } from "@/components/lottery-card"
|
|
import { ArmyStat } from "@/components/army-stat"
|
|
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">
|
|
<BrandBar />
|
|
<Suspense fallback={<HomeSkeleton />}>
|
|
<HomeContent activeCode={activeCode} />
|
|
</Suspense>
|
|
</main>
|
|
)
|
|
}
|
|
|
|
function BrandBar() {
|
|
return (
|
|
<div className="border-b border-border/60 bg-background/95 backdrop-blur">
|
|
<div className="mx-auto flex max-w-6xl items-center gap-2 px-4 py-3 sm:px-6">
|
|
<LokiMark className="h-7 w-7 text-accent" />
|
|
<span className="text-lg font-extrabold tracking-tight">LokiLoto</span>
|
|
<span className="ml-1 hidden text-sm text-muted-foreground sm:inline">
|
|
pronostics et statistiques de loterie, pays par pays
|
|
</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)
|
|
|
|
return (
|
|
<div style={{ "--accent": theme.accent, "--accent-soft": theme.accentSoft } as React.CSSProperties}>
|
|
<header className="relative overflow-hidden border-b border-border/60">
|
|
<div
|
|
className="absolute inset-0 -z-10"
|
|
style={{
|
|
background:
|
|
"radial-gradient(ellipse 90% 60% at 15% 0%, var(--accent-soft), transparent 70%)",
|
|
}}
|
|
/>
|
|
<div className="mx-auto max-w-6xl px-4 pt-6 pb-5 sm:px-6">
|
|
<CountrySelector active={activeCode} />
|
|
|
|
<div className="mt-4 flex items-center gap-3">
|
|
<LokiMark className="h-10 w-10 shrink-0 text-accent" />
|
|
<div>
|
|
<h2 className="text-xl font-bold tracking-tight">{theme.name}</h2>
|
|
<p className="text-sm text-muted-foreground">
|
|
Statistiques et pronostics de Loki pour les loteries suivies.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div className="mt-4 grid grid-cols-1 gap-3 sm:grid-cols-3">
|
|
<ArmyStat
|
|
icon={Users}
|
|
label="Membres dans l'armée"
|
|
value={feed.army.total.toLocaleString("fr-CA")}
|
|
/>
|
|
<ArmyStat
|
|
icon={Dices}
|
|
label={`Loteries suivies — ${theme.name}`}
|
|
value={lotteries.length.toString()}
|
|
/>
|
|
<ArmyStat
|
|
icon={Trophy}
|
|
label="Gains de Loki"
|
|
value={totalTracked > 0 ? `${totalWins} / ${totalTracked}` : "—"}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</header>
|
|
|
|
<section className="mx-auto w-full max-w-6xl flex-1 px-4 py-6 sm:px-6">
|
|
{lotteries.length > 0 ? (
|
|
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
{lotteries.map((entry) => (
|
|
<LotteryCard key={entry.id} entry={entry} />
|
|
))}
|
|
</div>
|
|
) : (
|
|
<div className="rounded-xl border border-dashed border-border py-16 text-center text-sm text-muted-foreground">
|
|
Aucune loterie suivie pour {theme.name} pour le moment.
|
|
</div>
|
|
)}
|
|
</section>
|
|
|
|
<footer className="border-t border-border/60 px-4 py-4 text-center text-xs text-muted-foreground sm:px-6">
|
|
Données fournies par LokiLab. Statistiques descriptives seulement — aucune garantie de
|
|
gain.
|
|
</footer>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function HomeSkeleton() {
|
|
return (
|
|
<div className="mx-auto w-full max-w-6xl px-4 py-8 sm:px-6">
|
|
<Skeleton className="h-10 w-full" />
|
|
<Skeleton className="mt-4 h-10 w-64" />
|
|
<div className="mt-6 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
|
{Array.from({ length: 6 }).map((_, i) => (
|
|
<Skeleton key={i} className="h-48 w-full" />
|
|
))}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|