import { useState } from "react" import { useLocation } from "wouter" import { motion } from "framer-motion" import { LogIn, Sparkles } from "lucide-react" import { Button } from "@workspace/ui/components/button" import { useRoomStore } from "@/store/room" import { useI18n } from "@/i18n/context" import { errorMessage } from "@/i18n/error" import { LanguageToggle } from "@/i18n/language-toggle" import { ThemeToggle } from "@/components/theme-toggle" import { WhatsNew } from "@/components/whats-new" const inputClass = "border-input bg-background ring-offset-background focus-visible:ring-ring h-10 w-full rounded-md border px-3 py-2 text-sm focus-visible:ring-2 focus-visible:outline-none disabled:opacity-50" // Emojis geek qui flottent en fond. const FLOATERS = [ { emoji: "🎮", x: "8%", y: "18%", delay: 0 }, { emoji: "🎧", x: "82%", y: "22%", delay: 0.6 }, { emoji: "🧠", x: "15%", y: "72%", delay: 1.2 }, { emoji: "👾", x: "78%", y: "70%", delay: 0.3 }, { emoji: "🕹️", x: "45%", y: "12%", delay: 0.9 }, { emoji: "🎬", x: "60%", y: "82%", delay: 1.5 }, ] export function HomePage() { const [, navigate] = useLocation() const { t } = useI18n() const createRoom = useRoomStore((s) => s.createRoom) const joinRoom = useRoomStore((s) => s.joinRoom) const connected = useRoomStore((s) => s.connected) const [code, setCode] = useState("") const [error, setError] = useState(null) const [busy, setBusy] = useState(false) async function handleCreate() { setError(null) setBusy(true) try { const { roomCode } = await createRoom() navigate(`/room/${roomCode}`) } catch (err) { setError(errorMessage(t, err)) } finally { setBusy(false) } } async function handleJoin() { setError(null) setBusy(true) try { const { roomCode } = await joinRoom(code.trim().toUpperCase()) navigate(`/room/${roomCode}`) } catch (err) { setError(errorMessage(t, err)) } finally { setBusy(false) } } return (
{/* Halo animé */} {/* Emojis flottants */} {FLOATERS.map((f) => ( {f.emoji} ))}
NerdWare

{t.home.tagline}

{t.home.orJoin}
setCode(e.target.value)} onKeyDown={(e) => e.key === "Enter" && code.trim() && handleJoin()} />
{!connected && (

{t.home.connecting}

)} {error && (

{error}

)}
) }