feature/bots #15
5 changed files with 139 additions and 31 deletions
|
|
@ -178,6 +178,8 @@ export function GameEndView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
|
|
||||||
const [first, second, third] = ranked
|
const [first, second, third] = ranked
|
||||||
const rest = ranked.slice(3)
|
const rest = ranked.slice(3)
|
||||||
|
const hasTracks = !!gameTracks && gameTracks.length > 0
|
||||||
|
const hasRecap = !!gameRecap && gameRecap.length > 0
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex w-full flex-col items-center gap-6">
|
<div className="flex w-full flex-col items-center gap-6">
|
||||||
|
|
@ -256,15 +258,19 @@ export function GameEndView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Détails (musiques + récap) côte à côte sur desktop. */}
|
{/* Détails : musiques + récap côte à côte sur desktop s'il y a les deux,
|
||||||
{((gameTracks && gameTracks.length > 0) ||
|
sinon une seule colonne centrée (sinon le récap se calait à gauche). */}
|
||||||
(gameRecap && gameRecap.length > 0)) && (
|
{(hasTracks || hasRecap) && (
|
||||||
<div className="grid w-full gap-6 md:grid-cols-2 md:items-start">
|
<div
|
||||||
{gameTracks && gameTracks.length > 0 && (
|
className={
|
||||||
<TracksRecap tracks={gameTracks} />
|
hasTracks && hasRecap
|
||||||
)}
|
? "grid w-full gap-6 md:grid-cols-2 md:items-start"
|
||||||
{gameRecap && gameRecap.length > 0 && (
|
: "flex w-full max-w-xl flex-col gap-6"
|
||||||
<RoundsRecap recap={gameRecap} nameOf={nameOf} playerId={playerId} />
|
}
|
||||||
|
>
|
||||||
|
{hasTracks && <TracksRecap tracks={gameTracks!} />}
|
||||||
|
{hasRecap && (
|
||||||
|
<RoundsRecap recap={gameRecap!} nameOf={nameOf} playerId={playerId} />
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,16 @@ const MIX_LABELS: Record<MixMode, string> = {
|
||||||
blindtest: "Blindtest",
|
blindtest: "Blindtest",
|
||||||
}
|
}
|
||||||
import { Button } from "@workspace/ui/components/button"
|
import { Button } from "@workspace/ui/components/button"
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@workspace/ui/components/tooltip"
|
||||||
import { useRoomStore } from "@/store/room"
|
import { useRoomStore } from "@/store/room"
|
||||||
import { Avatar } from "@/components/avatar"
|
import { Avatar } from "@/components/avatar"
|
||||||
|
|
||||||
|
const BLINDTEST_LOCK_HINT = "3 joueurs dont 2 réels (un bot ne peut pas être DJ)"
|
||||||
|
|
||||||
const MAX_TRACKS = 10
|
const MAX_TRACKS = 10
|
||||||
const GAME_TYPES: {
|
const GAME_TYPES: {
|
||||||
value: GameType
|
value: GameType
|
||||||
|
|
@ -309,13 +316,15 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
{GAME_TYPES.map(({ value, label, Icon, needsThree }) => {
|
{GAME_TYPES.map(({ value, label, Icon, needsThree }) => {
|
||||||
const locked = needsThree && !blindtestAvailable
|
const locked = needsThree && !blindtestAvailable
|
||||||
const active = effectiveType === value
|
const active = effectiveType === value
|
||||||
return (
|
const tile = (
|
||||||
<button
|
<button
|
||||||
key={value}
|
key={value}
|
||||||
disabled={locked}
|
aria-disabled={locked}
|
||||||
title={locked ? "3 joueurs dont 2 réels" : undefined}
|
onClick={() => {
|
||||||
onClick={() => updateSettings({ gameType: value })}
|
if (locked) return
|
||||||
className={`flex flex-col items-center gap-1.5 rounded-lg border p-2.5 text-xs font-medium transition-colors disabled:opacity-40 ${
|
updateSettings({ gameType: value })
|
||||||
|
}}
|
||||||
|
className={`flex flex-col items-center gap-1.5 rounded-lg border p-2.5 text-xs font-medium transition-colors aria-disabled:cursor-not-allowed aria-disabled:opacity-40 ${
|
||||||
active
|
active
|
||||||
? "border-primary bg-primary/10"
|
? "border-primary bg-primary/10"
|
||||||
: "border-input hover:bg-muted/60"
|
: "border-input hover:bg-muted/60"
|
||||||
|
|
@ -325,6 +334,14 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
{label}
|
{label}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
return locked ? (
|
||||||
|
<Tooltip key={value}>
|
||||||
|
<TooltipTrigger asChild>{tile}</TooltipTrigger>
|
||||||
|
<TooltipContent>{BLINDTEST_LOCK_HINT}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
tile
|
||||||
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
{!blindtestAvailable && (
|
{!blindtestAvailable && (
|
||||||
|
|
@ -343,13 +360,15 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
{(["quiz", "image", "blindtest"] as const).map((m) => {
|
{(["quiz", "image", "blindtest"] as const).map((m) => {
|
||||||
const locked = m === "blindtest" && !blindtestAvailable
|
const locked = m === "blindtest" && !blindtestAvailable
|
||||||
const on = mixedModes.includes(m) && !locked
|
const on = mixedModes.includes(m) && !locked
|
||||||
return (
|
const tile = (
|
||||||
<button
|
<button
|
||||||
key={m}
|
key={m}
|
||||||
disabled={locked}
|
aria-disabled={locked}
|
||||||
title={locked ? "3 joueurs dont 2 réels" : undefined}
|
onClick={() => {
|
||||||
onClick={() => toggleMix(m)}
|
if (locked) return
|
||||||
className={`flex-1 rounded-lg border px-2 py-1.5 text-xs font-medium transition-colors disabled:opacity-40 ${
|
toggleMix(m)
|
||||||
|
}}
|
||||||
|
className={`flex-1 rounded-lg border px-2 py-1.5 text-xs font-medium transition-colors aria-disabled:cursor-not-allowed aria-disabled:opacity-40 ${
|
||||||
on
|
on
|
||||||
? "border-primary bg-primary/10"
|
? "border-primary bg-primary/10"
|
||||||
: "border-input hover:bg-muted/60"
|
: "border-input hover:bg-muted/60"
|
||||||
|
|
@ -358,6 +377,14 @@ export function LobbyView({ snapshot }: { snapshot: RoomSnapshot }) {
|
||||||
{MIX_LABELS[m]}
|
{MIX_LABELS[m]}
|
||||||
</button>
|
</button>
|
||||||
)
|
)
|
||||||
|
return locked ? (
|
||||||
|
<Tooltip key={m}>
|
||||||
|
<TooltipTrigger asChild>{tile}</TooltipTrigger>
|
||||||
|
<TooltipContent>{BLINDTEST_LOCK_HINT}</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
) : (
|
||||||
|
tile
|
||||||
|
)
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,11 @@ import { Link } from "wouter"
|
||||||
import { Eye, EyeOff, Trash2, Upload } from "lucide-react"
|
import { Eye, EyeOff, Trash2, Upload } from "lucide-react"
|
||||||
import type { QuizFormat } from "@nerdware/shared"
|
import type { QuizFormat } from "@nerdware/shared"
|
||||||
import { Button } from "@workspace/ui/components/button"
|
import { Button } from "@workspace/ui/components/button"
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@workspace/ui/components/tooltip"
|
||||||
import {
|
import {
|
||||||
adminApi,
|
adminApi,
|
||||||
assetUrl,
|
assetUrl,
|
||||||
|
|
@ -187,14 +192,14 @@ function QuestionRow({
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Tooltip>
|
||||||
size="icon-sm"
|
<TooltipTrigger asChild>
|
||||||
variant="secondary"
|
<Button size="icon-sm" variant="secondary" onClick={onToggle}>
|
||||||
onClick={onToggle}
|
{q.active ? <Eye /> : <EyeOff />}
|
||||||
title={q.active ? "Désactiver" : "Activer"}
|
</Button>
|
||||||
>
|
</TooltipTrigger>
|
||||||
{q.active ? <Eye /> : <EyeOff />}
|
<TooltipContent>{q.active ? "Désactiver" : "Activer"}</TooltipContent>
|
||||||
</Button>
|
</Tooltip>
|
||||||
<Button
|
<Button
|
||||||
size="icon-sm"
|
size="icon-sm"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,11 @@ import { Link, useLocation } from "wouter"
|
||||||
import { AnimatePresence, motion } from "framer-motion"
|
import { AnimatePresence, motion } from "framer-motion"
|
||||||
import { LogOut } from "lucide-react"
|
import { LogOut } from "lucide-react"
|
||||||
import { Button } from "@workspace/ui/components/button"
|
import { Button } from "@workspace/ui/components/button"
|
||||||
|
import {
|
||||||
|
Tooltip,
|
||||||
|
TooltipContent,
|
||||||
|
TooltipTrigger,
|
||||||
|
} from "@workspace/ui/components/tooltip"
|
||||||
import { useRoomStore } from "@/store/room"
|
import { useRoomStore } from "@/store/room"
|
||||||
import { LobbyView } from "@/components/lobby-view"
|
import { LobbyView } from "@/components/lobby-view"
|
||||||
import { QuizView } from "@/components/quiz-view"
|
import { QuizView } from "@/components/quiz-view"
|
||||||
|
|
@ -84,10 +89,16 @@ export function RoomPage({ code }: { code: string }) {
|
||||||
<header className="flex items-center justify-between">
|
<header className="flex items-center justify-between">
|
||||||
<RoomCode code={snapshot.code} />
|
<RoomCode code={snapshot.code} />
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-center gap-3">
|
||||||
<span
|
<Tooltip>
|
||||||
className={`size-2.5 rounded-full ${connected ? "bg-green-500" : "bg-red-500"}`}
|
<TooltipTrigger asChild>
|
||||||
title={connected ? "Connecté" : "Déconnecté"}
|
<span
|
||||||
/>
|
className={`size-2.5 rounded-full ${connected ? "bg-green-500" : "bg-red-500"}`}
|
||||||
|
/>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
{connected ? "Connecté" : "Déconnecté"}
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
|
|
|
||||||
59
packages/ui/src/components/tooltip.tsx
Normal file
59
packages/ui/src/components/tooltip.tsx
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
import * as React from "react"
|
||||||
|
import { Tooltip as TooltipPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { cn } from "@workspace/ui/lib/utils"
|
||||||
|
|
||||||
|
function TooltipProvider({
|
||||||
|
delayDuration = 0,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
|
||||||
|
return (
|
||||||
|
<TooltipPrimitive.Provider
|
||||||
|
data-slot="tooltip-provider"
|
||||||
|
delayDuration={delayDuration}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Tooltip({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<TooltipProvider>
|
||||||
|
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
|
||||||
|
</TooltipProvider>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function TooltipTrigger({
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
|
||||||
|
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function TooltipContent({
|
||||||
|
className,
|
||||||
|
sideOffset = 0,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<TooltipPrimitive.Portal>
|
||||||
|
<TooltipPrimitive.Content
|
||||||
|
data-slot="tooltip-content"
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
<TooltipPrimitive.Arrow className="bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" />
|
||||||
|
</TooltipPrimitive.Content>
|
||||||
|
</TooltipPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider }
|
||||||
Loading…
Add table
Reference in a new issue