@kumix/ui 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -12
- package/dist/components/agents/approval-card/index.js +0 -1
- package/dist/components/agents/approval-card/index.js.map +1 -1
- package/dist/components/agents/prompt-input.js +0 -1
- package/dist/components/agents/prompt-input.js.map +1 -1
- package/dist/components/charts/bar-chart/context.d.ts.map +1 -1
- package/dist/components/charts/line-chart/context.d.ts.map +1 -1
- package/dist/components/charts/returns-calendar.d.ts.map +1 -1
- package/dist/components/charts/treemap.d.ts.map +1 -1
- package/dist/components/motion/bouncy-accordion.d.ts.map +1 -1
- package/dist/components/motion/bouncy-accordion.js +20 -34
- package/dist/components/motion/bouncy-accordion.js.map +1 -1
- package/dist/components/motion/crash/crash-balloon.d.ts +9 -0
- package/dist/components/motion/crash/crash-balloon.d.ts.map +1 -0
- package/dist/components/motion/crash/crash-balloon.js +829 -0
- package/dist/components/motion/crash/crash-balloon.js.map +1 -0
- package/dist/components/motion/crash/crash-parts.d.ts +59 -0
- package/dist/components/motion/crash/crash-parts.d.ts.map +1 -0
- package/dist/components/motion/crash/crash-parts.js +2 -0
- package/dist/components/motion/crash/crash-tower.d.ts +9 -0
- package/dist/components/motion/crash/crash-tower.d.ts.map +1 -0
- package/dist/components/motion/crash/crash-tower.js +370 -0
- package/dist/components/motion/crash/crash-tower.js.map +1 -0
- package/dist/components/motion/crash.d.ts +9 -0
- package/dist/components/motion/crash.d.ts.map +1 -0
- package/dist/components/motion/crash.js +590 -0
- package/dist/components/motion/crash.js.map +1 -0
- package/dist/components/motion/feedback-widget.js +0 -1
- package/dist/components/motion/feedback-widget.js.map +1 -1
- package/dist/components/motion/liquid.js +2 -2
- package/dist/components/motion/liquid.js.map +1 -1
- package/dist/components/motion/mines.d.ts +41 -0
- package/dist/components/motion/mines.d.ts.map +1 -0
- package/dist/components/motion/mines.js +762 -0
- package/dist/components/motion/mines.js.map +1 -0
- package/dist/components/motion/plinko.d.ts +59 -0
- package/dist/components/motion/plinko.d.ts.map +1 -0
- package/dist/components/motion/plinko.js +385 -0
- package/dist/components/motion/plinko.js.map +1 -0
- package/dist/components/motion/signup-form.js +0 -1
- package/dist/components/motion/signup-form.js.map +1 -1
- package/dist/components/motion/swap.d.ts +1 -1
- package/dist/components/motion/tooltip.d.ts +2 -2
- package/dist/components/motion/tooltip.d.ts.map +1 -1
- package/dist/components/motion/wallet-card/index.js +0 -1
- package/dist/components/motion/wallet-card/index.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/code-block/code-block.d.ts +1 -0
- package/dist/components/reui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts +1 -1
- package/dist/components/reui/data-grid/data-grid-table.d.ts.map +1 -1
- package/dist/components/reui/frame.d.ts +1 -1
- package/dist/components/reui/icon-tile.d.ts +1 -1
- package/dist/components/reui/tree.d.ts +1 -0
- package/dist/components/reui/tree.d.ts.map +1 -1
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/bubble.d.ts +1 -1
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/empty.d.ts +1 -1
- package/dist/components/ui/item.d.ts +1 -1
- package/dist/components/ui/marker.d.ts +1 -1
- package/dist/components/ui/tabs.d.ts +1 -1
- package/dist/crash-parts-CUv5gFYQ.js +1053 -0
- package/dist/crash-parts-CUv5gFYQ.js.map +1 -0
- package/dist/{ease-CHhXKlG3.d.ts → ease-DjhlGGZO.d.ts} +4 -2
- package/dist/ease-DjhlGGZO.d.ts.map +1 -0
- package/dist/hooks/use-highlighted-code.d.ts +1 -1
- package/dist/hooks/use-highlighted-code.d.ts.map +1 -1
- package/dist/lib/audio-context.d.ts +11 -0
- package/dist/lib/audio-context.d.ts.map +1 -0
- package/dist/lib/audio-context.js +37 -0
- package/dist/lib/audio-context.js.map +1 -0
- package/dist/lib/ease.d.ts +2 -2
- package/dist/lib/ease.js +8 -1
- package/dist/lib/ease.js.map +1 -1
- package/dist/lib/game-sounds.d.ts +18 -0
- package/dist/lib/game-sounds.d.ts.map +1 -0
- package/dist/lib/game-sounds.js +142 -0
- package/dist/lib/game-sounds.js.map +1 -0
- package/dist/lib/tick-sound.d.ts +4 -3
- package/dist/lib/tick-sound.d.ts.map +1 -1
- package/dist/lib/tick-sound.js +30 -37
- package/dist/lib/tick-sound.js.map +1 -1
- package/dist/tooltip-CNEYdIX3.d.ts.map +1 -1
- package/dist/use-crash-game-B3RHxFkm.d.ts +108 -0
- package/dist/use-crash-game-B3RHxFkm.d.ts.map +1 -0
- package/package.json +7 -7
- package/dist/ease-CHhXKlG3.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mines.js","names":[],"sources":["../../../src/components/motion/mines.tsx"],"sourcesContent":["\"use client\";\n\nimport { type KeyboardEvent, type ReactNode, useEffect, useRef, useState } from \"react\";\nimport { Gem, Volume2, VolumeX } from \"lucide-react\";\nimport { AnimatePresence, motion, useAnimate, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_OUT } from \"../../lib/ease\";\nimport { createGameSounds, type GameSounds } from \"../../lib/game-sounds\";\nimport { PresenceGate, type PresenceGateRenderProps } from \"../../lib/presence-gate\";\nimport { ActionSwapCascadeIcon } from \"./action-swap-cascade\";\nimport {\n AdaptiveStepper,\n AdaptiveStepperDecrement,\n AdaptiveStepperIncrement,\n AdaptiveStepperValue,\n} from \"./adaptive-stepper\";\nimport { Button } from \"./button\";\nimport { NumberTicker } from \"./number-ticker\";\nimport { Tooltip } from \"./tooltip\";\n\nexport type MinesTile = \"gem\" | \"mine\";\n\nexport interface MinesProps {\n /** Tiles per side, rounded, at least 2. Default 5 (a 5 × 5 board). Changing it ends the round. */\n size?: number;\n /** Mines on the board (controlled), rounded and kept between 1 and tiles − 1. Takes effect from the next round. */\n mines?: number;\n /** Initial mine count when uncontrolled. Default 3. */\n defaultMines?: number;\n /** Called when the mine count changes between rounds. */\n onMinesChange?: (mines: number) => void;\n /** Called for every tile picked during a round; a mine reports multiplier 0 and ends it. */\n onReveal?: (tile: number, result: MinesTile, multiplier: number) => void;\n /** Called when the player cashes out, or clears every gem. */\n onCashOut?: (multiplier: number, gems: number) => void;\n /** Play synthesized sounds (controlled): gem chimes, a mine blast and a cash-out arpeggio. */\n sound?: boolean;\n /** Initial sound state when uncontrolled. Default false. */\n defaultSound?: boolean;\n /** Called when the sound button is toggled. */\n onSoundChange?: (sound: boolean) => void;\n /** Show the result card when a round ends. Default true. */\n showResult?: boolean;\n /** Accessible name for the game. Default \"Mines\". */\n \"aria-label\"?: string;\n className?: string;\n}\n\ntype Phase = \"idle\" | \"playing\" | \"busted\" | \"cashed\";\n\n/**\n * Fair payout after `gems` safe picks on a board of `tiles` with `mines`:\n * the inverse of the chance of picking that many gems in a row. `mines` is\n * kept between 0 and tiles − 1 and `gems` between 0 and the safe tiles, so\n * the result is always finite.\n */\nexport function minesMultiplier(tiles: number, mines: number, gems: number) {\n const safeMines = Math.max(0, Math.min(Math.round(mines), tiles - 1));\n const safeGems = Math.max(0, Math.min(Math.round(gems), tiles - safeMines));\n let multiplier = 1;\n for (let i = 0; i < safeGems; i++) multiplier *= (tiles - i) / (tiles - safeMines - i);\n return multiplier;\n}\n\n// Revealed icons arrive from a quarter size, transparent and blurred, on a\n// spring with no bounce. A round's closing reveal ripples outward from the\n// last pick, one ring of tiles every 25ms.\nconst ICON_SPRING = { type: \"spring\", duration: 0.3, bounce: 0 } as const;\nconst RIPPLE_STEP = 0.025;\n// A mine shakes once, quickly: 300ms, settling to rest.\nconst SHAKE = { duration: 0.3, ease: EASE_OUT } as const;\n// A found gem's tile springs back from a slight squash.\nconst GEM_POP = { type: \"spring\", duration: 0.35, bounce: 0.4 } as const;\n// The cash-out pulse runs through the picked gems 40ms apart over 350ms, in\n// seconds. The result opens once the last tile's closing animation is done.\nconst PULSE_STEP = 0.04;\nconst PULSE_TIME = 0.35;\n// Exits are shorter than entrances.\nconst EXIT = { duration: 0.12, ease: EASE_OUT } as const;\n\n/**\n * A mines board: pick tiles to find gems, each raising the multiplier, and\n * cash out before you hit a mine. The round's end reveals every tile.\n */\nexport function Mines({\n size: sizeProp = 5,\n mines: minesProp,\n defaultMines = 3,\n onMinesChange,\n onReveal,\n onCashOut,\n sound,\n defaultSound = false,\n onSoundChange,\n showResult = true,\n \"aria-label\": ariaLabel = \"Mines\",\n className,\n}: MinesProps) {\n const reduce = useReducedMotion() ?? false;\n const size = Math.max(2, Math.round(sizeProp) || 2);\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && size !== sizeProp)\n console.warn(`Mines: size must be a whole number of at least 2; using ${size}.`);\n }, [size, sizeProp]);\n const tiles = size * size;\n const [internalMines, setInternalMines] = useState(defaultMines);\n const chosenMines = Math.min(Math.max(1, Math.round(minesProp ?? internalMines) || 1), tiles - 1);\n const [phase, setPhase] = useState<Phase>(\"idle\");\n const [mineSet, setMineSet] = useState<ReadonlySet<number>>(new Set());\n const [picked, setPicked] = useState<number[]>([]);\n const [cursor, setCursor] = useState(0);\n const [announcement, setAnnouncement] = useState(\"\");\n const [resultOpen, setResultOpen] = useState(false);\n const sectionRef = useRef<HTMLElement>(null);\n const mainButtonRef = useRef<HTMLButtonElement>(null);\n const tileRefs = useRef<(HTMLButtonElement | null)[]>([]);\n const [, animate] = useAnimate();\n\n // Only sets state, so the render-time size reset below can call it.\n const resetBoard = () => {\n setPhase(\"idle\");\n setPicked([]);\n setMineSet(new Set());\n setResultOpen(false);\n };\n\n // A new size renumbers every tile, so the mines placed for the old board no\n // longer match it. End the round in the same render.\n const [boardSize, setBoardSize] = useState(size);\n if (boardSize !== size) {\n setBoardSize(size);\n resetBoard();\n setCursor(0);\n }\n\n // Once a round starts, its payout follows the mines actually on the board,\n // even if a controlled `mines` changes before the next round.\n const mines = phase === \"idle\" ? chosenMines : mineSet.size;\n const gems = picked.filter((tile) => !mineSet.has(tile)).length;\n const multiplier = minesMultiplier(tiles, mines, gems);\n const next = minesMultiplier(tiles, mines, gems + 1);\n const over = phase === \"busted\" || phase === \"cashed\";\n // Chance the next pick is a gem.\n const safe = (tiles - mines - gems) / (tiles - gems);\n const lastPick = picked.at(-1) ?? Math.floor(tiles / 2);\n // Turning showResult off hides an open ticket too.\n const resultShown = resultOpen && showResult && over;\n\n const [internalSound, setInternalSound] = useState(defaultSound);\n const soundOn = sound ?? internalSound;\n const player = useRef<GameSounds | null>(null);\n const getPlayer = () => {\n if (!player.current) player.current = createGameSounds();\n return player.current;\n };\n useEffect(\n () => () => {\n player.current?.dispose();\n player.current = null;\n },\n [],\n );\n\n const setMines = (value: number) => {\n // A finished board shows the old count's mines; clear it for the new one.\n if (over) resetBoard();\n if (minesProp === undefined) setInternalMines(value);\n onMinesChange?.(value);\n };\n\n const closeResult = () => {\n setResultOpen(false);\n mainButtonRef.current?.focus();\n };\n\n const start = () => {\n resetBoard();\n // Mines are placed when the round starts, never on the server.\n const order = Array.from({ length: tiles }, (_, i) => i);\n for (let i = order.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [order[i], order[j]] = [order[j], order[i]];\n }\n setMineSet(new Set(order.slice(0, chosenMines)));\n setPhase(\"playing\");\n if (!reduce) {\n tileRefs.current.forEach((tile, index) => {\n if (!tile) return;\n const wave = Math.floor(index / size) + (index % size);\n animate(\n tile,\n { scale: [0.94, 1], opacity: [0.5, 1] },\n { duration: 0.2, delay: wave * 0.025, ease: EASE_OUT },\n );\n });\n }\n setAnnouncement(`Round started with ${chosenMines} ${chosenMines === 1 ? \"mine\" : \"mines\"}.`);\n if (soundOn) getPlayer().prepare();\n };\n\n const cashOut = (finalGems = gems) => {\n if (phase !== \"playing\" || finalGems === 0) return;\n const value = minesMultiplier(tiles, mines, finalGems);\n setPhase(\"cashed\");\n setAnnouncement(`Cashed out at ${formatMultiplier(value)}.`);\n if (soundOn) getPlayer().cashOut();\n onCashOut?.(value, finalGems);\n };\n\n const pick = (tile: number) => {\n if (phase !== \"playing\" || picked.includes(tile)) return;\n setPicked((current) => [...current, tile]);\n if (mineSet.has(tile)) {\n setPhase(\"busted\");\n setAnnouncement(\"Mine. The round is over.\");\n if (soundOn) getPlayer().mine();\n onReveal?.(tile, \"mine\", 0);\n return;\n }\n const found = gems + 1;\n const node = tileRefs.current[tile];\n if (node && !reduce) animate(node, { scale: [0.92, 1] }, GEM_POP);\n const value = minesMultiplier(tiles, mines, found);\n if (soundOn) getPlayer().gem(found);\n onReveal?.(tile, \"gem\", value);\n if (found === tiles - mines) {\n cashOut(found);\n return;\n }\n setAnnouncement(`Gem. ${formatMultiplier(value)}.`);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>, tile: number) => {\n const row = Math.floor(tile / size);\n const col = tile % size;\n const target = {\n ArrowRight: row * size + Math.min(size - 1, col + 1),\n ArrowLeft: row * size + Math.max(0, col - 1),\n ArrowDown: Math.min(size - 1, row + 1) * size + col,\n ArrowUp: Math.max(0, row - 1) * size + col,\n Home: row * size,\n End: row * size + size - 1,\n }[event.key];\n if (target === undefined) return;\n event.preventDefault();\n setCursor(target);\n tileRefs.current[target]?.focus();\n };\n\n // When the board's closing animation ends, in seconds: unpicked tiles\n // reveal in a ripple from the last pick, and picked gems pulse on a cash out.\n let closingEnd = 0;\n if (over) {\n for (let tile = 0; tile < tiles; tile++) {\n const order = picked.indexOf(tile);\n const end =\n order === -1\n ? ringFrom(lastPick, tile, size) * RIPPLE_STEP + ICON_SPRING.duration\n : phase === \"cashed\" && !reduce\n ? order * PULSE_STEP + PULSE_TIME\n : 0;\n closingEnd = Math.max(closingEnd, end);\n }\n }\n\n // The ticket rises once the closing animation has played. A timer, not an\n // animation callback, so a cut-short animation can't keep it shut; a new\n // round or a reset clears it.\n useEffect(() => {\n if (!over || !showResult) return;\n const id = setTimeout(() => {\n // The main button already says Play again, so a player still on the\n // board lands there. Focus elsewhere on the page stays put.\n if (sectionRef.current?.contains(document.activeElement))\n mainButtonRef.current?.focus({ preventScroll: true });\n setResultOpen(true);\n }, closingEnd * 1000);\n return () => clearTimeout(id);\n }, [over, showResult, closingEnd]);\n\n const toggleSound = () => {\n const nextSound = !soundOn;\n if (nextSound) getPlayer().prepare();\n if (sound === undefined) setInternalSound(nextSound);\n onSoundChange?.(nextSound);\n };\n\n return (\n <section\n ref={sectionRef}\n aria-label={ariaLabel}\n className={cn(\"flex w-full max-w-md flex-col gap-4\", className)}\n onKeyDown={(event) => {\n if (event.key !== \"Escape\" || !resultShown) return;\n // Escape is used up here; an enclosing dialog must not close too.\n event.stopPropagation();\n closeResult();\n }}\n >\n <div className=\"flex flex-wrap items-center justify-between gap-3\">\n <AdaptiveStepper\n value={chosenMines}\n onValueChange={setMines}\n min={1}\n max={tiles - 1}\n disabled={phase === \"playing\"}\n formatValueText={(value) => `${value} ${value === 1 ? \"mine\" : \"mines\"}`}\n aria-label=\"Mine count\"\n >\n <AdaptiveStepperDecrement />\n <AdaptiveStepperValue>\n {(value) => (\n <span className=\"inline-flex items-center gap-1.5\">\n <MineIcon className=\"text-muted-foreground size-4\" />\n {value}\n </span>\n )}\n </AdaptiveStepperValue>\n <AdaptiveStepperIncrement />\n </AdaptiveStepper>\n\n <div className=\"text-right\">\n <div className=\"text-foreground text-2xl font-semibold\">\n {phase === \"busted\" ? (\n // The multiplier is lost: struck through, as on the ticket. A plain\n // span, since a line-through skips the ticker's inline-block digits.\n <span className=\"text-muted-foreground tabular-nums line-through decoration-2\">\n {formatMultiplier(multiplier)}\n </span>\n ) : (\n <NumberTicker\n value={multiplier}\n decimals={2}\n format={compact}\n suffix=\"×\"\n startOnView={false}\n duration={0.35}\n />\n )}\n </div>\n <p className=\"text-muted-foreground flex items-center justify-end gap-1.5 text-xs tabular-nums\">\n {over ? (\n phase === \"busted\" ? (\n \"Multiplier lost\"\n ) : (\n \"Multiplier\"\n )\n ) : (\n <>\n <OddsRing safe={safe} reduce={reduce} />\n {phase === \"playing\"\n ? `${Math.round(safe * 100)}% safe · next ${formatMultiplier(next)}`\n : `First pick ${Math.round(safe * 100)}% safe`}\n </>\n )}\n </p>\n </div>\n </div>\n\n {/* Board panel: 12px tiles + 12px padding give the 24px outer radius. */}\n <div className=\"bg-muted/40 relative rounded-3xl p-3\">\n {/* Under the result card the tiles leave the tab order. */}\n <fieldset\n inert={resultShown}\n className=\"m-0 grid min-w-0 gap-2 border-0 p-0\"\n style={{ gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))` }}\n >\n <legend className=\"sr-only\">Tiles</legend>\n {Array.from({ length: tiles }, (_, tile) => {\n const isPicked = picked.includes(tile);\n const isMine = mineSet.has(tile);\n const shown = isPicked || over;\n const content: MinesTile | null = shown ? (isMine ? \"mine\" : \"gem\") : null;\n const hit = isPicked && isMine;\n const row = Math.floor(tile / size);\n const col = tile % size;\n const ripple = ringFrom(lastPick, tile, size);\n const order = picked.indexOf(tile);\n const celebrate = phase === \"cashed\" && isPicked && !reduce;\n const interactive = phase === \"playing\" && !isPicked;\n return (\n <motion.button\n key={tile}\n ref={(node) => {\n tileRefs.current[tile] = node;\n }}\n type=\"button\"\n tabIndex={tile === cursor ? 0 : -1}\n aria-disabled={!interactive}\n aria-label={`Row ${row + 1}, column ${col + 1}, ${tileState(content, isPicked, order)}`}\n onFocus={() => setCursor(tile)}\n onClick={() => pick(tile)}\n onKeyDown={(event) => onKeyDown(event, tile)}\n animate={hit && !reduce ? { x: [0, -5, 5, -3, 3, 0] } : { x: 0 }}\n transition={SHAKE}\n className={cn(\n \"relative grid aspect-square place-items-center rounded-xl border outline-none\",\n // The mine's shockwave paints over its neighbours.\n hit && \"z-10\",\n \"transition-[translate,scale,background-color,border-color] duration-150 ease-out\",\n \"focus-visible:ring-ring focus-visible:ring-2\",\n interactive\n ? \"border-border bg-card cursor-pointer hover:-translate-y-0.5 hover:border-(--color-border-strong) active:scale-[0.96]\"\n : \"cursor-default border-transparent\",\n !interactive && !shown && \"bg-card/60\",\n content === \"gem\" && (isPicked ? \"bg-primary/15\" : \"bg-card/40\"),\n content === \"mine\" && (hit ? \"bg-rose-500/20\" : \"bg-card/40\"),\n )}\n >\n {hit && !reduce ? (\n <motion.span\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-0 rounded-xl border-2 border-rose-500\"\n initial={{ scale: 1, opacity: 0.7 }}\n animate={{ scale: 1.7, opacity: 0 }}\n transition={{ duration: 0.45, ease: EASE_OUT }}\n />\n ) : null}\n {isPicked && !isMine ? (\n <motion.span\n aria-hidden=\"true\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n transition={{ duration: 0.15, ease: EASE_OUT, delay: 0.1 }}\n className=\"text-primary/70 absolute top-1.5 left-2 text-[10px] font-medium tabular-nums\"\n >\n {order + 1}\n </motion.span>\n ) : null}\n <AnimatePresence initial={false}>\n {content ? (\n <motion.span\n key={content}\n aria-hidden=\"true\"\n initial={\n reduce ? { opacity: 0 } : { opacity: 0, scale: 0.25, filter: \"blur(4px)\" }\n }\n animate={\n celebrate\n ? { opacity: 1, scale: [1, 1.2, 1], filter: \"blur(0px)\" }\n : { opacity: isPicked ? 1 : 0.4, scale: 1, filter: \"blur(0px)\" }\n }\n exit={\n reduce\n ? { opacity: 0, transition: EXIT }\n : { opacity: 0, scale: 0.9, transition: EXIT }\n }\n transition={\n celebrate\n ? { duration: PULSE_TIME, ease: EASE_OUT, delay: order * PULSE_STEP }\n : { ...ICON_SPRING, delay: isPicked ? 0 : ripple * RIPPLE_STEP }\n }\n className={cn(\n \"grid place-items-center\",\n content === \"gem\" ? \"text-primary\" : \"text-rose-500 dark:text-rose-400\",\n )}\n >\n {content === \"gem\" ? (\n <Gem className=\"size-[45%] min-h-5 min-w-5\" strokeWidth={2} />\n ) : (\n <MineIcon className=\"size-[45%] min-h-5 min-w-5\" />\n )}\n </motion.span>\n ) : null}\n </AnimatePresence>\n </motion.button>\n );\n })}\n </fieldset>\n\n <AnimatePresence>\n {resultShown ? (\n <PresenceGate key=\"result\">\n {({ gate }) => (\n <ResultCard\n gate={gate}\n outcome={phase === \"cashed\" ? \"cashed\" : \"busted\"}\n multiplier={multiplier}\n gems={gems}\n safeTiles={tiles - mines}\n mines={mines}\n size={size}\n picked={picked}\n mineSet={mineSet}\n reduce={reduce}\n onClose={closeResult}\n />\n )}\n </PresenceGate>\n ) : null}\n </AnimatePresence>\n </div>\n\n <div className=\"flex items-center gap-2\">\n {/* aria-disabled, not disabled: Start turns into this button, and a\n disabled button would drop the keyboard focus that pressed it. */}\n <Button\n ref={mainButtonRef}\n className=\"flex-1 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\"\n pressScale={0.96}\n aria-disabled={(phase === \"playing\" && gems === 0) || undefined}\n onClick={() => (phase === \"playing\" ? cashOut() : start())}\n >\n {phase === \"playing\"\n ? `Cash out ${formatMultiplier(multiplier)}`\n : over\n ? \"Play again\"\n : \"Start\"}\n </Button>\n {/* aria-label names the button; the tooltip shows the same label on hover\n and focus. Tooltip's asLabel would hydrate differently from the server. */}\n <Tooltip content=\"Sound\" side=\"top\">\n <Button\n variant=\"secondary\"\n onClick={toggleSound}\n aria-label=\"Sound\"\n aria-pressed={soundOn}\n pressScale={0.96}\n className={cn(\"w-10 px-0\", soundOn ? \"text-foreground\" : \"text-muted-foreground\")}\n >\n <ActionSwapCascadeIcon value={soundOn ? \"on\" : \"off\"} className=\"size-4\">\n {soundOn ? (\n <Volume2 aria-hidden=\"true\" className=\"size-4\" />\n ) : (\n <VolumeX aria-hidden=\"true\" className=\"size-4\" />\n )}\n </ActionSwapCascadeIcon>\n </Button>\n </Tooltip>\n </div>\n\n <p aria-live=\"polite\" className=\"sr-only\">\n {announcement}\n </p>\n </section>\n );\n}\n\n// The ticket's tear line sits this far down; the side notches are cut there.\nconst TEAR = 104;\nconst NOTCH_MASK = `radial-gradient(circle 9px at 0 ${TEAR}px, transparent 98%, black), radial-gradient(circle 9px at 100% ${TEAR}px, transparent 98%, black)`;\n// Rises with a little settle (a rare, end-of-round moment), leaves quickly.\nconst CARD_IN = { type: \"spring\", duration: 0.4, bounce: 0.15 } as const;\nconst CARD_OUT = { duration: 0.15, ease: EASE_OUT } as const;\n\ninterface ResultProps {\n gate: PresenceGateRenderProps[\"gate\"];\n outcome: \"cashed\" | \"busted\";\n multiplier: number;\n gems: number;\n safeTiles: number;\n mines: number;\n size: number;\n picked: number[];\n mineSet: ReadonlySet<number>;\n reduce: boolean;\n onClose: () => void;\n}\n\n/**\n * The end-of-round summary over a dimmed board. It has no buttons: the main\n * action below the board already says Play again, and tapping anywhere on\n * the board (or Escape) puts the card away to study the board.\n */\nfunction ResultCard(props: ResultProps) {\n const { gate, reduce, onClose } = props;\n return (\n <>\n <motion.button\n type=\"button\"\n aria-label=\"Hide result and show the board\"\n onClick={onClose}\n {...gate}\n className=\"bg-background/55 focus-visible:ring-ring absolute inset-0 z-20 cursor-default rounded-3xl backdrop-blur-[2px] outline-none focus-visible:ring-2\"\n initial={{ opacity: 0 }}\n animate={{ opacity: 1 }}\n exit={{ opacity: 0, transition: CARD_OUT }}\n transition={{ duration: 0.2, ease: EASE_OUT }}\n />\n <div\n inert={gate.inert}\n className=\"pointer-events-none absolute inset-0 z-20 grid place-items-center p-4\"\n >\n <motion.div\n role=\"group\"\n aria-label=\"Round result\"\n // Sized here: the ticket is a size container, so it can't take its\n // width from its contents.\n className={cn(\"w-full max-w-[17rem]\", TICKET_SHADOW)}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 16, scale: 0.96 }}\n animate={{ opacity: 1, y: 0, scale: 1 }}\n exit={\n reduce\n ? { opacity: 0, transition: CARD_OUT }\n : { opacity: 0, y: 8, scale: 0.98, transition: CARD_OUT }\n }\n transition={reduce ? { duration: 0.2 } : CARD_IN}\n >\n <Ticket {...props} />\n </motion.div>\n </div>\n </>\n );\n}\n\n// Inside the ticket, chunks arrive in reading order: outcome, multiplier,\n// stats, then the run replays on the mini map in pick order.\nconst STAGE = { duration: 0.25, ease: EASE_OUT } as const;\nconst REPLAY_START = 0.3;\nconst REPLAY_STEP = 0.05;\n// Mini map cells pop in with a small overshoot: each is 8px, so a bounce\n// reads as a cell landing rather than a wobble.\nconst CELL_SPRING = { type: \"spring\", duration: 0.3, bounce: 0.3 } as const;\n\nfunction Stage({\n delay,\n reduce,\n className,\n children,\n}: {\n delay: number;\n reduce: boolean;\n className?: string;\n children: ReactNode;\n}) {\n return (\n <motion.div\n className={className}\n initial={reduce ? { opacity: 0 } : { opacity: 0, y: 6 }}\n animate={{ opacity: 1, y: 0 }}\n transition={{ ...STAGE, delay: reduce ? 0 : delay }}\n >\n {children}\n </motion.div>\n );\n}\n\nfunction MiniMap({\n size,\n picked,\n mineSet,\n reduce,\n}: Pick<ResultProps, \"size\" | \"picked\" | \"mineSet\" | \"reduce\">) {\n const hit = picked.at(-1);\n // 8px cells 3px apart, kept within 88px so big boards leave the stats room.\n const gap = size > 10 ? 1 : 3;\n return (\n <div\n aria-hidden=\"true\"\n className=\"grid shrink-0\"\n style={{\n gridTemplateColumns: `repeat(${size}, minmax(0, 1fr))`,\n gap,\n width: Math.min(88, size * 8 + (size - 1) * gap),\n }}\n >\n {Array.from({ length: size * size }, (_, tile) => {\n const isMine = mineSet.has(tile);\n const isPicked = picked.includes(tile);\n const order = picked.indexOf(tile);\n return (\n <motion.span\n key={tile}\n initial={isPicked && !reduce ? { opacity: 0, scale: 0.4 } : false}\n animate={{ opacity: 1, scale: 1 }}\n transition={{ ...CELL_SPRING, delay: REPLAY_START + order * REPLAY_STEP }}\n className={cn(\n \"aspect-square rounded-[2px]\",\n isPicked && !isMine && \"bg-primary\",\n isPicked && isMine && tile === hit && \"bg-rose-500\",\n !isPicked && isMine && \"ring-1 ring-rose-500/60 ring-inset\",\n !isPicked && !isMine && \"bg-foreground/10\",\n )}\n />\n );\n })}\n </div>\n );\n}\n\n// A drop-shadow on the ticket's wrapper: the notch mask would clip a\n// box-shadow on the ticket itself.\nconst TICKET_SHADOW =\n \"[filter:drop-shadow(0_1px_1px_rgb(0_0_0/0.12))_drop-shadow(0_12px_16px_rgb(0_0_0/0.3))]\";\n\n/** A ticket stub, notched at a dashed tear line. */\nfunction Ticket({\n outcome,\n multiplier,\n gems,\n safeTiles,\n mines,\n size,\n picked,\n mineSet,\n reduce,\n}: ResultProps) {\n const cashed = outcome === \"cashed\";\n return (\n <div\n className=\"bg-card text-foreground @container w-full rounded-2xl\"\n style={{\n WebkitMaskImage: NOTCH_MASK,\n WebkitMaskComposite: \"source-in\",\n maskImage: NOTCH_MASK,\n maskComposite: \"intersect\",\n }}\n >\n <div\n className={cn(\n \"flex flex-col items-center justify-center gap-1 rounded-t-2xl px-5 text-center\",\n cashed ? \"bg-primary/10\" : \"bg-rose-500/10\",\n )}\n style={{ height: TEAR }}\n >\n <Stage delay={0.05} reduce={reduce}>\n <p\n className={cn(\n \"text-xs font-medium tracking-wide uppercase\",\n cashed ? \"text-primary\" : \"text-rose-600 dark:text-rose-400\",\n )}\n >\n {cashed ? \"Cashed out\" : \"Mine hit\"}\n </p>\n </Stage>\n <Stage delay={0.1} reduce={reduce}>\n <p\n className={cn(\n \"text-3xl font-semibold\",\n !cashed && \"text-muted-foreground line-through decoration-2\",\n )}\n >\n {cashed ? (\n <NumberTicker\n value={multiplier}\n decimals={2}\n format={compact}\n suffix=\"×\"\n startOnView={false}\n duration={0.6}\n stagger={0.05}\n />\n ) : (\n <span className=\"tabular-nums\">{formatMultiplier(multiplier)}</span>\n )}\n </p>\n </Stage>\n </div>\n <div aria-hidden=\"true\" className=\"border-border mx-4 border-t-2 border-dashed\" />\n <div className=\"flex items-center gap-4 px-5 pt-4 pb-5\">\n <Stage delay={0.18} reduce={reduce} className=\"flex-1\">\n <dl className=\"grid gap-1.5 text-xs\">\n <Row label=\"Gems\" value={`${gems} of ${safeTiles}`} />\n <Row label=\"Mines\" value={mines} />\n <Row\n label={cashed ? \"Odds beaten\" : \"Lost on pick\"}\n value={cashed ? `1 in ${compact(multiplier)}` : picked.length}\n />\n </dl>\n </Stage>\n {/* A narrow ticket keeps the stats on one line each and drops the map. */}\n <Stage delay={0.24} reduce={reduce} className=\"@max-[15rem]:hidden\">\n <MiniMap size={size} picked={picked} mineSet={mineSet} reduce={reduce} />\n </Stage>\n </div>\n </div>\n );\n}\n\nfunction Row({ label, value }: { label: string; value: string | number }) {\n return (\n <div className=\"flex justify-between gap-2 whitespace-nowrap\">\n <dt className=\"text-muted-foreground\">{label}</dt>\n <dd className=\"font-medium tabular-nums\">{value}</dd>\n </div>\n );\n}\n\n// The classic minesweeper mine: a solid ball (so it never reads as a sun),\n// four thick spikes on the axes and four shorter ones on the diagonals.\nconst SPIKES = Array.from({ length: 8 }, (_, i) => {\n const angle = (i * Math.PI) / 4;\n const main = i % 2 === 0;\n const [cos, sin] = [Math.cos(angle), Math.sin(angle)];\n const reach = main ? 10.5 : 9;\n return { main, x1: 12 + cos * 6, y1: 12 + sin * 6, x2: 12 + cos * reach, y2: 12 + sin * reach };\n});\n\n/** A mine on Lucide's 24px grid, sized to pair with the gem. */\nfunction MineIcon({ className }: { className?: string }) {\n // Decorative: tiles and the stepper name the mine in text.\n return (\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n fill=\"currentColor\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n className={className}\n >\n {SPIKES.map((spike) => (\n <line\n key={`${spike.x2.toFixed(2)}-${spike.y2.toFixed(2)}`}\n x1={spike.x1}\n y1={spike.y1}\n x2={spike.x2}\n y2={spike.y2}\n strokeWidth={spike.main ? 2.5 : 2}\n />\n ))}\n <circle cx={12} cy={12} r={6.5} stroke=\"none\" />\n <circle cx={9.75} cy={9.75} r={1.6} fill=\"white\" fillOpacity={0.75} stroke=\"none\" />\n </svg>\n );\n}\n\n/** A small ring that fills with the chance the next pick is safe. */\nfunction OddsRing({ safe, reduce }: { safe: number; reduce: boolean }) {\n return (\n <svg aria-hidden=\"true\" viewBox=\"0 0 14 14\" className=\"size-3.5 -rotate-90\">\n <circle cx={7} cy={7} r={5.5} fill=\"none\" strokeWidth={2} className=\"stroke-foreground/10\" />\n <motion.circle\n cx={7}\n cy={7}\n r={5.5}\n fill=\"none\"\n strokeWidth={2}\n strokeLinecap=\"round\"\n className={safe < 0.5 ? \"stroke-rose-500 dark:stroke-rose-400\" : \"stroke-primary\"}\n initial={false}\n animate={{ pathLength: safe }}\n transition={reduce ? { duration: 0 } : { duration: 0.2, ease: EASE_OUT }}\n />\n </svg>\n );\n}\n\n/** What a tile shows, and for revealed tiles whether the player picked it. */\nfunction tileState(content: MinesTile | null, isPicked: boolean, order: number) {\n if (!content) return \"hidden\";\n if (!isPicked) return `${content}, not picked`;\n return content === \"mine\" ? \"mine, hit\" : `gem, pick ${order + 1}`;\n}\n\n/** Rings between two tiles: 0 for the same tile, 1 for its neighbours. */\nfunction ringFrom(from: number, tile: number, size: number) {\n return Math.max(\n Math.abs(Math.floor(tile / size) - Math.floor(from / size)),\n Math.abs((tile % size) - (from % size)),\n );\n}\n\n// Payouts grow without limit (a cleared 5 × 5 board with 12 mines pays over\n// five million), so big ones are shortened to fit: 5.2M, then 1.3E29.\nconst SHORT = new Intl.NumberFormat(\"en\", { notation: \"compact\", maximumFractionDigits: 1 });\nconst SCIENTIFIC = new Intl.NumberFormat(\"en\", {\n notation: \"scientific\",\n maximumFractionDigits: 1,\n});\n\nfunction compact(multiplier: number) {\n if (multiplier < 10_000) return multiplier.toFixed(2);\n return (multiplier < 1e15 ? SHORT : SCIENTIFIC).format(multiplier);\n}\n\n/** A multiplier as Mines shows it: 2.50×, or shortened when large (5.2M×). */\nexport function formatMultiplier(multiplier: number) {\n return `${compact(multiplier)}×`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyDA,SAAgB,gBAAgB,OAAe,OAAe,MAAc;CAC1E,MAAM,YAAY,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC;CACpE,MAAM,WAAW,KAAK,IAAI,GAA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AAQ,YAAoB;CACnC,IAAI,aAAa,KAAQ,OAAO,WAAW,QAAQ,CAAC;CACpD,QAAQ,aAAa,kBAAO,QAAQ,WAAA,CAAY,OAAO,UAAU;AACnE;;AAGA,SAAgB,iBAAiB,YAAoB;CACnD,OAAO,GAAG,QAAQ,UAAU,EAAE;AAChC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type PlinkoValue = string | number;
|
|
2
|
+
export interface PlinkoProps {
|
|
3
|
+
/** Rows of pegs when `slots` isn't passed. Default 12. */
|
|
4
|
+
rows?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Slot values, left to right. Their count sets the board: n slots get
|
|
7
|
+
* n - 1 rows of pegs, so `rows` is ignored when this is passed. Without it
|
|
8
|
+
* the slots come from `plinkoSlots(rows)`. Fewer than 2 slots render nothing.
|
|
9
|
+
*/
|
|
10
|
+
slots?: PlinkoValue[];
|
|
11
|
+
/** Called with the slot index and its value when a ball lands. */
|
|
12
|
+
onLand?: (slot: number, value: PlinkoValue) => void;
|
|
13
|
+
/** Balls allowed in flight at once. Default 12. */
|
|
14
|
+
maxBalls?: number;
|
|
15
|
+
/** Label of the drop button. Default "Drop ball". */
|
|
16
|
+
dropLabel?: string;
|
|
17
|
+
/** Flash each peg as the ball hits it (controlled). Its button is hidden with reduced motion, where no pegs are hit. */
|
|
18
|
+
pegFlash?: boolean;
|
|
19
|
+
/** Initial peg flash state when uncontrolled. Default true. */
|
|
20
|
+
defaultPegFlash?: boolean;
|
|
21
|
+
/** Called when the peg flash button is toggled. */
|
|
22
|
+
onPegFlashChange?: (pegFlash: boolean) => void;
|
|
23
|
+
/** Tooltip and accessible name of the peg flash button. Default "Peg flash". */
|
|
24
|
+
pegFlashLabel?: string;
|
|
25
|
+
/** Click on every peg hit and landing (controlled). */
|
|
26
|
+
sound?: boolean;
|
|
27
|
+
/** Initial sound state when uncontrolled. Default false. */
|
|
28
|
+
defaultSound?: boolean;
|
|
29
|
+
/** Called when the sound button is toggled. */
|
|
30
|
+
onSoundChange?: (sound: boolean) => void;
|
|
31
|
+
/** Tooltip and accessible name of the sound button. Default "Sound". */
|
|
32
|
+
soundLabel?: string;
|
|
33
|
+
/** Accessible name for the board. Default "Plinko board". */
|
|
34
|
+
"aria-label"?: string;
|
|
35
|
+
className?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A Plinko board: balls drop through rows of pegs, bounce left or right off
|
|
39
|
+
* each one and land in a slot. Pegs flash when hit and the slot pulses on
|
|
40
|
+
* landing. Optional sound clicks on every peg and lands with a thunk that
|
|
41
|
+
* brightens toward the rarer edge slots. With reduced motion a ball lands at
|
|
42
|
+
* once.
|
|
43
|
+
*/
|
|
44
|
+
export declare function Plinko({ rows: rowsProp, slots, onLand, maxBalls, dropLabel, pegFlash, defaultPegFlash, onPegFlashChange, pegFlashLabel, sound, defaultSound, onSoundChange, soundLabel, "aria-label": ariaLabel, className }: PlinkoProps): import("react").JSX.Element | null;
|
|
45
|
+
/**
|
|
46
|
+
* Slot values for a board of `rows`: `center` in the middle, growing evenly
|
|
47
|
+
* (geometrically) to `edge` at both ends, where landing is rarest. Rounded to
|
|
48
|
+
* readable numbers: 12 rows give 100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100.
|
|
49
|
+
* Values from 1 to 10 round to whole numbers, the rest to one significant
|
|
50
|
+
* figure, so fractional curves work: 8 rows with `center: 0.5, edge: 10`
|
|
51
|
+
* give 10, 5, 2, 1, 0.5, 1, 2, 5, 10.
|
|
52
|
+
* `rows` is rounded to at least 1, `center` raised to at least 0.01 and
|
|
53
|
+
* `edge` to at least `center`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function plinkoSlots(rowCount: number, options?: {
|
|
56
|
+
center?: number;
|
|
57
|
+
edge?: number;
|
|
58
|
+
}): number[];
|
|
59
|
+
//# sourceMappingURL=plinko.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plinko.d.ts","names":[],"sources":["../../../src/components/motion/plinko.tsx"],"mappings":"A,YAaY;iBAEK;;EAEf;;;;;;EAMA,QAAQ;;EAER,UAAU,cAAc,OAAO;;EAE/B;;EAEA;;EAEA;;EAEA;;EAEA,oBAAoB;;EAEpB;;EAEA;;EAEA;;EAEA,iBAAiB;;EAEjB;;EAEA;EACA;;;;;;;;;wBA6Ec,SACd,MAAM,UACN,OACA,QACA,UACA,WACA,UACA,iBACA,kBACA,eACA,OACA,cACA,eACA,0BACc,WACd,aACC,8BAAW,IAAA;;;;;;;;;;;wBAsSE,YACd,kBACA;EAAW;EAAiB"}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { EASE_IN, EASE_OUT } from "../../lib/ease.js";
|
|
3
|
+
import { createTickPlayer } from "../../lib/tick-sound.js";
|
|
4
|
+
import { ActionSwapCascadeIcon } from "./action-swap-cascade.js";
|
|
5
|
+
import { Button } from "./button/base.js";
|
|
6
|
+
import { t as Tooltip } from "../../tooltip-CuHpilPN.js";
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
import { cn } from "@kumix/utils";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { AnimatePresence, motion, useAnimate, useReducedMotion } from "motion/react";
|
|
11
|
+
import { Volume2, VolumeX, Zap, ZapOff } from "lucide-react";
|
|
12
|
+
// src/components/motion/plinko.tsx
|
|
13
|
+
const GAP = 32;
|
|
14
|
+
const ROW = 30;
|
|
15
|
+
const PEG = 3.5;
|
|
16
|
+
const BALL = 7;
|
|
17
|
+
const TOP = 48;
|
|
18
|
+
const SLOT = 34;
|
|
19
|
+
const RISE = [
|
|
20
|
+
0,
|
|
21
|
+
.55,
|
|
22
|
+
.45,
|
|
23
|
+
1
|
|
24
|
+
];
|
|
25
|
+
const HOP_TIME = .09;
|
|
26
|
+
const DROP_TIME = .16;
|
|
27
|
+
const HOP_HEIGHT = 7;
|
|
28
|
+
const LANDING_RATE = .55;
|
|
29
|
+
const LANDING_SPREAD = .4;
|
|
30
|
+
let nextBall = 0;
|
|
31
|
+
/** Height of the ball's centre where it touches a peg on `row`. */
|
|
32
|
+
const contactY = (row) => TOP + row * ROW - PEG - BALL;
|
|
33
|
+
/** Random left/right steps from the top peg to a slot, as keyframes. */
|
|
34
|
+
function plan(rows, width) {
|
|
35
|
+
const center = width / 2;
|
|
36
|
+
const points = [{
|
|
37
|
+
x: center,
|
|
38
|
+
y: BALL
|
|
39
|
+
}];
|
|
40
|
+
const steps = [.22];
|
|
41
|
+
const pegs = [];
|
|
42
|
+
let k = 0;
|
|
43
|
+
for (let row = 0; row < rows; row++) {
|
|
44
|
+
const x = center + (k - row / 2) * GAP;
|
|
45
|
+
pegs.push(`${row}-${k}`);
|
|
46
|
+
points.push({
|
|
47
|
+
x,
|
|
48
|
+
y: contactY(row)
|
|
49
|
+
});
|
|
50
|
+
const right = Math.random() < .5;
|
|
51
|
+
points.push({
|
|
52
|
+
x: x + (right ? GAP / 4 : -8),
|
|
53
|
+
y: contactY(row) - HOP_HEIGHT
|
|
54
|
+
});
|
|
55
|
+
steps.push(HOP_TIME, DROP_TIME);
|
|
56
|
+
if (right) k++;
|
|
57
|
+
}
|
|
58
|
+
const slotY = TOP + rows * ROW - BALL + 3;
|
|
59
|
+
points.push({
|
|
60
|
+
x: center + (k - rows / 2) * GAP,
|
|
61
|
+
y: slotY
|
|
62
|
+
});
|
|
63
|
+
const duration = steps.reduce((sum, step) => sum + step, 0);
|
|
64
|
+
const times = [0];
|
|
65
|
+
for (const step of steps) times.push(times[times.length - 1] + step / duration);
|
|
66
|
+
return {
|
|
67
|
+
path: points,
|
|
68
|
+
times,
|
|
69
|
+
slot: k,
|
|
70
|
+
duration,
|
|
71
|
+
pegs
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A Plinko board: balls drop through rows of pegs, bounce left or right off
|
|
76
|
+
* each one and land in a slot. Pegs flash when hit and the slot pulses on
|
|
77
|
+
* landing. Optional sound clicks on every peg and lands with a thunk that
|
|
78
|
+
* brightens toward the rarer edge slots. With reduced motion a ball lands at
|
|
79
|
+
* once.
|
|
80
|
+
*/
|
|
81
|
+
function Plinko({ rows: rowsProp = 12, slots, onLand, maxBalls = 12, dropLabel = "Drop ball", pegFlash, defaultPegFlash = true, onPegFlashChange, pegFlashLabel = "Peg flash", sound, defaultSound = false, onSoundChange, soundLabel = "Sound", "aria-label": ariaLabel = "Plinko board", className }) {
|
|
82
|
+
const reduce = useReducedMotion() ?? false;
|
|
83
|
+
const [scope, animate] = useAnimate();
|
|
84
|
+
const [balls, setBalls] = useState([]);
|
|
85
|
+
const [announcement, setAnnouncement] = useState("");
|
|
86
|
+
const [lastSlot, setLastSlot] = useState(null);
|
|
87
|
+
const [internalSound, setInternalSound] = useState(defaultSound);
|
|
88
|
+
const soundOn = sound ?? internalSound;
|
|
89
|
+
const [internalFlash, setInternalFlash] = useState(defaultPegFlash);
|
|
90
|
+
const flashOn = pegFlash ?? internalFlash;
|
|
91
|
+
const landings = useRef(0);
|
|
92
|
+
const players = useRef(null);
|
|
93
|
+
const getPlayers = () => {
|
|
94
|
+
if (!players.current) players.current = {
|
|
95
|
+
peg: createTickPlayer(),
|
|
96
|
+
landing: createTickPlayer()
|
|
97
|
+
};
|
|
98
|
+
return players.current;
|
|
99
|
+
};
|
|
100
|
+
useEffect(() => () => {
|
|
101
|
+
players.current?.peg.dispose();
|
|
102
|
+
players.current?.landing.dispose();
|
|
103
|
+
players.current = null;
|
|
104
|
+
}, []);
|
|
105
|
+
const togglePegFlash = () => {
|
|
106
|
+
const next = !flashOn;
|
|
107
|
+
if (pegFlash === void 0) setInternalFlash(next);
|
|
108
|
+
onPegFlashChange?.(next);
|
|
109
|
+
};
|
|
110
|
+
const toggleSound = () => {
|
|
111
|
+
const next = !soundOn;
|
|
112
|
+
if (next) getPlayers().peg.prepare();
|
|
113
|
+
if (sound === void 0) setInternalSound(next);
|
|
114
|
+
onSoundChange?.(next);
|
|
115
|
+
};
|
|
116
|
+
const labels = slots ?? plinkoSlots(rowsProp);
|
|
117
|
+
const rows = labels.length - 1;
|
|
118
|
+
const invalid = labels.length < 2;
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
if (process.env.NODE_ENV !== "production" && invalid) console.warn("Plinko needs at least 2 slots; it renders nothing until it has them.");
|
|
121
|
+
}, [invalid]);
|
|
122
|
+
const [boardRows, setBoardRows] = useState(rows);
|
|
123
|
+
if (boardRows !== rows) {
|
|
124
|
+
setBoardRows(rows);
|
|
125
|
+
setBalls([]);
|
|
126
|
+
setLastSlot(null);
|
|
127
|
+
}
|
|
128
|
+
const width = (rows + 2) * GAP;
|
|
129
|
+
const height = TOP + rows * ROW + SLOT;
|
|
130
|
+
const pegs = Array.from({ length: rows }, (_, row) => Array.from({ length: row + 3 }, (_, i) => ({
|
|
131
|
+
id: `${row}-${i - 1}`,
|
|
132
|
+
x: width / 2 + (i - 1 - row / 2) * GAP,
|
|
133
|
+
y: TOP + row * ROW
|
|
134
|
+
}))).flat();
|
|
135
|
+
const land = (slot) => {
|
|
136
|
+
animate(`[data-slot="${slot}"]`, { opacity: [.9, 0] }, {
|
|
137
|
+
duration: .3,
|
|
138
|
+
ease: EASE_OUT
|
|
139
|
+
});
|
|
140
|
+
if (soundOn) getPlayers().landing.play(LANDING_RATE + LANDING_SPREAD * (Math.abs(slot - rows / 2) / (rows / 2)));
|
|
141
|
+
setLastSlot(slot);
|
|
142
|
+
landings.current++;
|
|
143
|
+
setAnnouncement(`Ball ${landings.current} landed in slot ${slot + 1}: ${labels[slot]}`);
|
|
144
|
+
onLand?.(slot, labels[slot]);
|
|
145
|
+
};
|
|
146
|
+
const hitPegs = (ball, y) => {
|
|
147
|
+
const rising = y < ball.y;
|
|
148
|
+
const row = Math.round((Math.max(ball.y, y) - contactY(0)) / ROW);
|
|
149
|
+
if (rising && !ball.rising && row > ball.lastRow && row < ball.pegs.length) {
|
|
150
|
+
ball.lastRow = row;
|
|
151
|
+
const peg = ball.pegs[row];
|
|
152
|
+
if (flashOn) animate(`[data-peg="${peg}"]`, {
|
|
153
|
+
scale: [
|
|
154
|
+
1,
|
|
155
|
+
1.8,
|
|
156
|
+
1
|
|
157
|
+
],
|
|
158
|
+
opacity: [
|
|
159
|
+
.4,
|
|
160
|
+
1,
|
|
161
|
+
.4
|
|
162
|
+
]
|
|
163
|
+
}, {
|
|
164
|
+
duration: .3,
|
|
165
|
+
times: [
|
|
166
|
+
0,
|
|
167
|
+
.3,
|
|
168
|
+
1
|
|
169
|
+
],
|
|
170
|
+
ease: EASE_OUT
|
|
171
|
+
});
|
|
172
|
+
if (soundOn) getPlayers().peg.play();
|
|
173
|
+
}
|
|
174
|
+
ball.y = y;
|
|
175
|
+
ball.rising = rising;
|
|
176
|
+
};
|
|
177
|
+
const full = balls.length >= maxBalls;
|
|
178
|
+
const drop = () => {
|
|
179
|
+
if (full) return;
|
|
180
|
+
const ball = {
|
|
181
|
+
id: nextBall++,
|
|
182
|
+
lastRow: -1,
|
|
183
|
+
y: 0,
|
|
184
|
+
rising: false,
|
|
185
|
+
...plan(rows, width)
|
|
186
|
+
};
|
|
187
|
+
if (soundOn) getPlayers().peg.prepare();
|
|
188
|
+
if (reduce) {
|
|
189
|
+
land(ball.slot);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
setBalls((current) => [...current, ball]);
|
|
193
|
+
};
|
|
194
|
+
if (invalid) return null;
|
|
195
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
196
|
+
"aria-label": ariaLabel,
|
|
197
|
+
className: cn("flex w-full flex-col items-center gap-4", className),
|
|
198
|
+
children: [
|
|
199
|
+
/* @__PURE__ */ jsxs("svg", {
|
|
200
|
+
ref: scope,
|
|
201
|
+
viewBox: `0 0 ${width} ${height}`,
|
|
202
|
+
style: { maxWidth: width * 1.4 },
|
|
203
|
+
className: "w-full",
|
|
204
|
+
"aria-hidden": "true",
|
|
205
|
+
children: [
|
|
206
|
+
pegs.map((peg) => /* @__PURE__ */ jsx("circle", {
|
|
207
|
+
"data-peg": peg.id,
|
|
208
|
+
cx: peg.x,
|
|
209
|
+
cy: peg.y,
|
|
210
|
+
r: PEG,
|
|
211
|
+
className: "fill-foreground origin-center opacity-40 transform-fill"
|
|
212
|
+
}, peg.id)),
|
|
213
|
+
labels.map((label, slot) => {
|
|
214
|
+
const x = width / 2 + (slot - rows / 2) * GAP - GAP / 2;
|
|
215
|
+
const y = TOP + rows * ROW;
|
|
216
|
+
return /* @__PURE__ */ jsxs("g", { children: [
|
|
217
|
+
/* @__PURE__ */ jsx("rect", {
|
|
218
|
+
x: x + 2,
|
|
219
|
+
y,
|
|
220
|
+
width: 28,
|
|
221
|
+
height: 30,
|
|
222
|
+
rx: 6,
|
|
223
|
+
className: slot === lastSlot ? "fill-primary/20" : "fill-muted"
|
|
224
|
+
}),
|
|
225
|
+
/* @__PURE__ */ jsx("rect", {
|
|
226
|
+
"data-slot": slot,
|
|
227
|
+
x: x + 2,
|
|
228
|
+
y,
|
|
229
|
+
width: 28,
|
|
230
|
+
height: 30,
|
|
231
|
+
rx: 6,
|
|
232
|
+
className: "fill-primary opacity-0"
|
|
233
|
+
}),
|
|
234
|
+
/* @__PURE__ */ jsx("text", {
|
|
235
|
+
x: x + GAP / 2,
|
|
236
|
+
y: y + 15,
|
|
237
|
+
textAnchor: "middle",
|
|
238
|
+
dominantBaseline: "central",
|
|
239
|
+
fontSize: Math.min(9, 24 / (String(label).length * .6)),
|
|
240
|
+
className: cn("fill-foreground tabular-nums", slot === lastSlot ? "font-semibold" : "font-medium"),
|
|
241
|
+
children: label
|
|
242
|
+
})
|
|
243
|
+
] }, slot);
|
|
244
|
+
}),
|
|
245
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: balls.map((ball) => /* @__PURE__ */ jsx(motion.circle, {
|
|
246
|
+
r: BALL,
|
|
247
|
+
cx: 0,
|
|
248
|
+
cy: 0,
|
|
249
|
+
className: "fill-primary",
|
|
250
|
+
initial: {
|
|
251
|
+
x: ball.path[0].x,
|
|
252
|
+
y: ball.path[0].y,
|
|
253
|
+
opacity: 0,
|
|
254
|
+
scale: .9
|
|
255
|
+
},
|
|
256
|
+
animate: {
|
|
257
|
+
x: ball.path.map((point) => point.x),
|
|
258
|
+
y: ball.path.map((point) => point.y),
|
|
259
|
+
opacity: 1,
|
|
260
|
+
scale: 1
|
|
261
|
+
},
|
|
262
|
+
exit: {
|
|
263
|
+
opacity: 0,
|
|
264
|
+
y: (ball.path.at(-1)?.y ?? 0) + 4,
|
|
265
|
+
transition: {
|
|
266
|
+
duration: .12,
|
|
267
|
+
ease: EASE_OUT
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
transition: {
|
|
271
|
+
opacity: {
|
|
272
|
+
duration: .15,
|
|
273
|
+
ease: EASE_OUT
|
|
274
|
+
},
|
|
275
|
+
scale: {
|
|
276
|
+
duration: .15,
|
|
277
|
+
ease: EASE_OUT
|
|
278
|
+
},
|
|
279
|
+
x: {
|
|
280
|
+
duration: ball.duration,
|
|
281
|
+
times: ball.times,
|
|
282
|
+
ease: "linear"
|
|
283
|
+
},
|
|
284
|
+
y: {
|
|
285
|
+
duration: ball.duration,
|
|
286
|
+
times: ball.times,
|
|
287
|
+
ease: ball.times.slice(1).map((_, i) => i % 2 === 1 ? RISE : EASE_IN)
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
onUpdate: (latest) => {
|
|
291
|
+
if (typeof latest.y === "number") hitPegs(ball, latest.y);
|
|
292
|
+
},
|
|
293
|
+
onAnimationComplete: () => {
|
|
294
|
+
if (ball.landed) return;
|
|
295
|
+
ball.landed = true;
|
|
296
|
+
land(ball.slot);
|
|
297
|
+
setBalls((current) => current.filter((other) => other.id !== ball.id));
|
|
298
|
+
}
|
|
299
|
+
}, ball.id)) }, rows)
|
|
300
|
+
]
|
|
301
|
+
}),
|
|
302
|
+
/* @__PURE__ */ jsxs("div", {
|
|
303
|
+
className: "flex items-center gap-2",
|
|
304
|
+
children: [
|
|
305
|
+
/* @__PURE__ */ jsx(Button, {
|
|
306
|
+
onClick: drop,
|
|
307
|
+
"aria-disabled": full || void 0,
|
|
308
|
+
pressScale: .96,
|
|
309
|
+
className: "aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
|
|
310
|
+
children: dropLabel
|
|
311
|
+
}),
|
|
312
|
+
reduce ? null : /* @__PURE__ */ jsx(ToggleButton, {
|
|
313
|
+
on: flashOn,
|
|
314
|
+
onToggle: togglePegFlash,
|
|
315
|
+
label: pegFlashLabel,
|
|
316
|
+
onIcon: Zap,
|
|
317
|
+
offIcon: ZapOff
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ jsx(ToggleButton, {
|
|
320
|
+
on: soundOn,
|
|
321
|
+
onToggle: toggleSound,
|
|
322
|
+
label: soundLabel,
|
|
323
|
+
onIcon: Volume2,
|
|
324
|
+
offIcon: VolumeX
|
|
325
|
+
})
|
|
326
|
+
]
|
|
327
|
+
}),
|
|
328
|
+
/* @__PURE__ */ jsx("p", {
|
|
329
|
+
"aria-live": "polite",
|
|
330
|
+
className: "sr-only",
|
|
331
|
+
children: announcement
|
|
332
|
+
})
|
|
333
|
+
]
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Slot values for a board of `rows`: `center` in the middle, growing evenly
|
|
338
|
+
* (geometrically) to `edge` at both ends, where landing is rarest. Rounded to
|
|
339
|
+
* readable numbers: 12 rows give 100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100.
|
|
340
|
+
* Values from 1 to 10 round to whole numbers, the rest to one significant
|
|
341
|
+
* figure, so fractional curves work: 8 rows with `center: 0.5, edge: 10`
|
|
342
|
+
* give 10, 5, 2, 1, 0.5, 1, 2, 5, 10.
|
|
343
|
+
* `rows` is rounded to at least 1, `center` raised to at least 0.01 and
|
|
344
|
+
* `edge` to at least `center`.
|
|
345
|
+
*/
|
|
346
|
+
function plinkoSlots(rowCount, options = {}) {
|
|
347
|
+
const rows = Math.max(1, Math.round(rowCount) || 1);
|
|
348
|
+
const center = Math.max(.01, options.center ?? 1);
|
|
349
|
+
const edge = Math.max(center, options.edge ?? 100);
|
|
350
|
+
const half = rows / 2;
|
|
351
|
+
return Array.from({ length: rows + 1 }, (_, slot) => {
|
|
352
|
+
const value = center * (edge / center) ** (Math.abs(slot - half) / half);
|
|
353
|
+
if (value >= 1 && value < 10) return Math.round(value);
|
|
354
|
+
return Number(value.toPrecision(1));
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/** An icon button that shows and toggles one on/off setting. */
|
|
358
|
+
function ToggleButton({ on, onToggle, label, onIcon: OnIcon, offIcon: OffIcon }) {
|
|
359
|
+
return /* @__PURE__ */ jsx(Tooltip, {
|
|
360
|
+
content: label,
|
|
361
|
+
side: "top",
|
|
362
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
363
|
+
variant: "secondary",
|
|
364
|
+
onClick: onToggle,
|
|
365
|
+
"aria-label": label,
|
|
366
|
+
"aria-pressed": on,
|
|
367
|
+
pressScale: .96,
|
|
368
|
+
className: cn("w-10 px-0", on ? "text-foreground" : "text-muted-foreground"),
|
|
369
|
+
children: /* @__PURE__ */ jsx(ActionSwapCascadeIcon, {
|
|
370
|
+
value: on ? "on" : "off",
|
|
371
|
+
className: "size-4",
|
|
372
|
+
children: on ? /* @__PURE__ */ jsx(OnIcon, {
|
|
373
|
+
"aria-hidden": "true",
|
|
374
|
+
className: "size-4"
|
|
375
|
+
}) : /* @__PURE__ */ jsx(OffIcon, {
|
|
376
|
+
"aria-hidden": "true",
|
|
377
|
+
className: "size-4"
|
|
378
|
+
})
|
|
379
|
+
})
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
export { Plinko, plinkoSlots };
|
|
384
|
+
|
|
385
|
+
//# sourceMappingURL=plinko.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plinko.js","names":[],"sources":["../../../src/components/motion/plinko.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport { type LucideIcon, Volume2, VolumeX, Zap, ZapOff } from \"lucide-react\";\nimport { AnimatePresence, motion, useAnimate, useReducedMotion } from \"motion/react\";\n\nimport { cn } from \"@kumix/utils\";\nimport { EASE_IN, EASE_OUT } from \"../../lib/ease\";\nimport { createTickPlayer } from \"../../lib/tick-sound\";\nimport { ActionSwapCascadeIcon } from \"./action-swap-cascade\";\nimport { Button } from \"./button\";\nimport { Tooltip } from \"./tooltip\";\n\nexport type PlinkoValue = string | number;\n\nexport interface PlinkoProps {\n /** Rows of pegs when `slots` isn't passed. Default 12. */\n rows?: number;\n /**\n * Slot values, left to right. Their count sets the board: n slots get\n * n - 1 rows of pegs, so `rows` is ignored when this is passed. Without it\n * the slots come from `plinkoSlots(rows)`. Fewer than 2 slots render nothing.\n */\n slots?: PlinkoValue[];\n /** Called with the slot index and its value when a ball lands. */\n onLand?: (slot: number, value: PlinkoValue) => void;\n /** Balls allowed in flight at once. Default 12. */\n maxBalls?: number;\n /** Label of the drop button. Default \"Drop ball\". */\n dropLabel?: string;\n /** Flash each peg as the ball hits it (controlled). Its button is hidden with reduced motion, where no pegs are hit. */\n pegFlash?: boolean;\n /** Initial peg flash state when uncontrolled. Default true. */\n defaultPegFlash?: boolean;\n /** Called when the peg flash button is toggled. */\n onPegFlashChange?: (pegFlash: boolean) => void;\n /** Tooltip and accessible name of the peg flash button. Default \"Peg flash\". */\n pegFlashLabel?: string;\n /** Click on every peg hit and landing (controlled). */\n sound?: boolean;\n /** Initial sound state when uncontrolled. Default false. */\n defaultSound?: boolean;\n /** Called when the sound button is toggled. */\n onSoundChange?: (sound: boolean) => void;\n /** Tooltip and accessible name of the sound button. Default \"Sound\". */\n soundLabel?: string;\n /** Accessible name for the board. Default \"Plinko board\". */\n \"aria-label\"?: string;\n className?: string;\n}\n\n// Board geometry in SVG units; the board scales to its container's width.\nconst GAP = 32; // horizontal space between pegs\nconst ROW = 30; // vertical space between peg rows\nconst PEG = 3.5;\nconst BALL = 7;\nconst TOP = 48; // first peg row\nconst SLOT = 34; // slot height\n\n// A ball falls between pegs under gravity and rises a little after each hit.\n// A drop speeds up (EASE_IN); RISE, its mirror, slows down like a hop and is\n// local because only a bounce needs it.\nconst RISE = [0, 0.55, 0.45, 1] as const;\nconst HOP_TIME = 0.09; // seconds rising after a peg\nconst DROP_TIME = 0.16; // seconds falling to the next peg\nconst HOP_HEIGHT = 7;\n// Landing tick playback rates: 0.55 in the centre slot, up to 0.95 at the edges.\nconst LANDING_RATE = 0.55;\nconst LANDING_SPREAD = 0.4;\n\ntype Ball = {\n id: number;\n path: { x: number; y: number }[];\n times: number[];\n slot: number;\n duration: number;\n /** Id of the peg hit on each row, top to bottom. */\n pegs: string[];\n /** Row of the last peg hit, -1 before the first. */\n lastRow: number;\n /** Last rendered y, to catch the frame the ball turns back up off a peg. */\n y: number;\n /** Moving up on the last frame: still on the hop from the last peg. */\n rising: boolean;\n /** Set once the ball reaches its slot; its exit fade must not land again. */\n landed?: boolean;\n};\n\nlet nextBall = 0;\n\n/** Height of the ball's centre where it touches a peg on `row`. */\nconst contactY = (row: number) => TOP + row * ROW - PEG - BALL;\n\n/** Random left/right steps from the top peg to a slot, as keyframes. */\nfunction plan(rows: number, width: number): Omit<Ball, \"id\" | \"lastRow\" | \"y\" | \"rising\"> {\n const center = width / 2;\n const points = [{ x: center, y: BALL }]; // enters fully inside the board\n const steps: number[] = [0.22]; // first fall from the chute to the top peg\n const pegs: string[] = [];\n let k = 0; // rightward steps so far\n for (let row = 0; row < rows; row++) {\n const x = center + (k - row / 2) * GAP;\n pegs.push(`${row}-${k}`);\n points.push({ x, y: contactY(row) });\n const right = Math.random() < 0.5;\n points.push({ x: x + (right ? GAP / 4 : -GAP / 4), y: contactY(row) - HOP_HEIGHT });\n steps.push(HOP_TIME, DROP_TIME);\n if (right) k++;\n }\n // Come to rest just inside the slot's top edge, clear of its label.\n const slotY = TOP + rows * ROW - BALL + 3;\n points.push({ x: center + (k - rows / 2) * GAP, y: slotY });\n const duration = steps.reduce((sum, step) => sum + step, 0);\n const times = [0];\n for (const step of steps) times.push(times[times.length - 1] + step / duration);\n return { path: points, times, slot: k, duration, pegs };\n}\n\n/**\n * A Plinko board: balls drop through rows of pegs, bounce left or right off\n * each one and land in a slot. Pegs flash when hit and the slot pulses on\n * landing. Optional sound clicks on every peg and lands with a thunk that\n * brightens toward the rarer edge slots. With reduced motion a ball lands at\n * once.\n */\nexport function Plinko({\n rows: rowsProp = 12,\n slots,\n onLand,\n maxBalls = 12,\n dropLabel = \"Drop ball\",\n pegFlash,\n defaultPegFlash = true,\n onPegFlashChange,\n pegFlashLabel = \"Peg flash\",\n sound,\n defaultSound = false,\n onSoundChange,\n soundLabel = \"Sound\",\n \"aria-label\": ariaLabel = \"Plinko board\",\n className,\n}: PlinkoProps) {\n const reduce = useReducedMotion() ?? false;\n const [scope, animate] = useAnimate();\n const [balls, setBalls] = useState<Ball[]>([]);\n const [announcement, setAnnouncement] = useState(\"\");\n // The last slot hit stays marked after its flash fades.\n const [lastSlot, setLastSlot] = useState<number | null>(null);\n const [internalSound, setInternalSound] = useState(defaultSound);\n const soundOn = sound ?? internalSound;\n const [internalFlash, setInternalFlash] = useState(defaultPegFlash);\n const flashOn = pegFlash ?? internalFlash;\n\n // Landings are numbered so a second ball in the same slot still changes\n // the live region's text and is announced again.\n const landings = useRef(0);\n // Each player cuts its own previous tick, so landings get their own player:\n // another ball's peg click would otherwise cut the longer landing thunk.\n const players = useRef<Record<\"peg\" | \"landing\", ReturnType<typeof createTickPlayer>> | null>(\n null,\n );\n const getPlayers = () => {\n if (!players.current)\n players.current = { peg: createTickPlayer(), landing: createTickPlayer() };\n return players.current;\n };\n useEffect(\n () => () => {\n players.current?.peg.dispose();\n players.current?.landing.dispose();\n players.current = null;\n },\n [],\n );\n\n const togglePegFlash = () => {\n const next = !flashOn;\n if (pegFlash === undefined) setInternalFlash(next);\n onPegFlashChange?.(next);\n };\n\n const toggleSound = () => {\n const next = !soundOn;\n // Unlock audio inside the click, where browsers allow it.\n if (next) getPlayers().peg.prepare();\n if (sound === undefined) setInternalSound(next);\n onSoundChange?.(next);\n };\n\n const labels = slots ?? plinkoSlots(rowsProp);\n const rows = labels.length - 1;\n const invalid = labels.length < 2;\n useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && invalid)\n console.warn(\"Plinko needs at least 2 slots; it renders nothing until it has them.\");\n }, [invalid]);\n\n // A new board size makes every ball in flight point at pegs that moved, so\n // drop them in the same render. Clearing them in an effect would mount them\n // in the new board first, and their exit would land in a slot that may not\n // exist any more.\n const [boardRows, setBoardRows] = useState(rows);\n if (boardRows !== rows) {\n setBoardRows(rows);\n setBalls([]);\n setLastSlot(null);\n }\n\n const width = (rows + 2) * GAP;\n const height = TOP + rows * ROW + SLOT;\n // Each row runs one peg past the ball's reach on both sides, so the board\n // reads as a triangle that widens down to the slots.\n const pegs = Array.from({ length: rows }, (_, row) =>\n Array.from({ length: row + 3 }, (_, i) => ({\n id: `${row}-${i - 1}`,\n x: width / 2 + (i - 1 - row / 2) * GAP,\n y: TOP + row * ROW,\n })),\n ).flat();\n\n const land = (slot: number) => {\n animate(`[data-slot=\"${slot}\"]`, { opacity: [0.9, 0] }, { duration: 0.3, ease: EASE_OUT });\n // A lower thunk than a peg hit marks the landing. It brightens toward\n // the edges, where landing is rarest, so a good drop is heard.\n if (soundOn)\n getPlayers().landing.play(\n LANDING_RATE + LANDING_SPREAD * (Math.abs(slot - rows / 2) / (rows / 2)),\n );\n setLastSlot(slot);\n landings.current++;\n setAnnouncement(`Ball ${landings.current} landed in slot ${slot + 1}: ${labels[slot]}`);\n onLand?.(slot, labels[slot]);\n };\n\n // Flash and click a peg on the frame the ball turns back up off it. Reading\n // the ball's own frames keeps both on its clock: a background tab pauses\n // them together. motion rebinds onUpdate every render, so the settings\n // read here are always current.\n const hitPegs = (ball: Ball, y: number) => {\n const rising = y < ball.y;\n // The row comes from where the ball turned, not from counting turns, so\n // a slow frame that skips a whole hop misses only that peg. Both frames\n // sit within a hop height above the contact, which rounds to its row.\n const row = Math.round((Math.max(ball.y, y) - contactY(0)) / ROW);\n if (rising && !ball.rising && row > ball.lastRow && row < ball.pegs.length) {\n ball.lastRow = row;\n const peg = ball.pegs[row];\n if (flashOn) {\n // Fast attack, slower decay: the pop peaks a third of the way in.\n animate(\n `[data-peg=\"${peg}\"]`,\n { scale: [1, 1.8, 1], opacity: [0.4, 1, 0.4] },\n { duration: 0.3, times: [0, 0.3, 1], ease: EASE_OUT },\n );\n }\n if (soundOn) getPlayers().peg.play();\n }\n ball.y = y;\n ball.rising = rising;\n };\n\n const full = balls.length >= maxBalls;\n const drop = () => {\n if (full) return;\n const ball: Ball = { id: nextBall++, lastRow: -1, y: 0, rising: false, ...plan(rows, width) };\n if (soundOn) getPlayers().peg.prepare();\n if (reduce) {\n land(ball.slot);\n return;\n }\n setBalls((current) => [...current, ball]);\n };\n\n if (invalid) return null;\n\n return (\n <section\n aria-label={ariaLabel}\n className={cn(\"flex w-full flex-col items-center gap-4\", className)}\n >\n <svg\n ref={scope}\n viewBox={`0 0 ${width} ${height}`}\n // Grow with the board so pegs keep the same on-screen spacing at any\n // row count, until the container's width runs out.\n style={{ maxWidth: width * 1.4 }}\n className=\"w-full\"\n aria-hidden=\"true\"\n >\n {pegs.map((peg) => (\n <circle\n key={peg.id}\n data-peg={peg.id}\n cx={peg.x}\n cy={peg.y}\n r={PEG}\n className=\"fill-foreground origin-center opacity-40 transform-fill\"\n />\n ))}\n\n {labels.map((label, slot) => {\n const x = width / 2 + (slot - rows / 2) * GAP - GAP / 2;\n const y = TOP + rows * ROW;\n return (\n <g key={slot}>\n <rect\n x={x + 2}\n y={y}\n width={GAP - 4}\n height={SLOT - 4}\n rx={6}\n className={slot === lastSlot ? \"fill-primary/20\" : \"fill-muted\"}\n />\n <rect\n data-slot={slot}\n x={x + 2}\n y={y}\n width={GAP - 4}\n height={SLOT - 4}\n rx={6}\n className=\"fill-primary opacity-0\"\n />\n <text\n x={x + GAP / 2}\n y={y + (SLOT - 4) / 2}\n textAnchor=\"middle\"\n dominantBaseline=\"central\"\n // Long values shrink to fit their slot.\n fontSize={Math.min(9, (GAP - 8) / (String(label).length * 0.6))}\n className={cn(\n \"fill-foreground tabular-nums\",\n slot === lastSlot ? \"font-semibold\" : \"font-medium\",\n )}\n >\n {label}\n </text>\n </g>\n );\n })}\n\n {/* Keyed by size: balls from a board that changed size leave at once. */}\n <AnimatePresence key={rows}>\n {balls.map((ball) => (\n <motion.circle\n key={ball.id}\n r={BALL}\n cx={0}\n cy={0}\n className=\"fill-primary\"\n // Enters from 90% scale and transparent, never from nothing. The\n // circle is drawn at 0,0 and placed by translate, so it scales\n // about its own centre.\n initial={{ x: ball.path[0].x, y: ball.path[0].y, opacity: 0, scale: 0.9 }}\n animate={{\n x: ball.path.map((point) => point.x),\n y: ball.path.map((point) => point.y),\n opacity: 1,\n scale: 1,\n }}\n // Settle into the slot: a short fade with a small drop.\n exit={{\n opacity: 0,\n y: (ball.path.at(-1)?.y ?? 0) + 4,\n transition: { duration: 0.12, ease: EASE_OUT },\n }}\n transition={{\n opacity: { duration: 0.15, ease: EASE_OUT },\n scale: { duration: 0.15, ease: EASE_OUT },\n x: { duration: ball.duration, times: ball.times, ease: \"linear\" },\n y: {\n duration: ball.duration,\n times: ball.times,\n // Fall into the first peg, then hop up and fall down per row.\n ease: ball.times.slice(1).map((_, i) => (i % 2 === 1 ? RISE : EASE_IN)),\n },\n }}\n onUpdate={(latest) => {\n if (typeof latest.y === \"number\") hitPegs(ball, latest.y);\n }}\n onAnimationComplete={() => {\n if (ball.landed) return;\n ball.landed = true;\n land(ball.slot);\n setBalls((current) => current.filter((other) => other.id !== ball.id));\n }}\n />\n ))}\n </AnimatePresence>\n </svg>\n\n <div className=\"flex items-center gap-2\">\n {/* aria-disabled, not disabled: a disabled button drops keyboard focus. */}\n <Button\n onClick={drop}\n aria-disabled={full || undefined}\n pressScale={0.96}\n className=\"aria-disabled:cursor-not-allowed aria-disabled:opacity-50\"\n >\n {dropLabel}\n </Button>\n {/* With reduced motion balls land at once and hit no pegs. */}\n {reduce ? null : (\n <ToggleButton\n on={flashOn}\n onToggle={togglePegFlash}\n label={pegFlashLabel}\n onIcon={Zap}\n offIcon={ZapOff}\n />\n )}\n <ToggleButton\n on={soundOn}\n onToggle={toggleSound}\n label={soundLabel}\n onIcon={Volume2}\n offIcon={VolumeX}\n />\n </div>\n <p aria-live=\"polite\" className=\"sr-only\">\n {announcement}\n </p>\n </section>\n );\n}\n\n/**\n * Slot values for a board of `rows`: `center` in the middle, growing evenly\n * (geometrically) to `edge` at both ends, where landing is rarest. Rounded to\n * readable numbers: 12 rows give 100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100.\n * Values from 1 to 10 round to whole numbers, the rest to one significant\n * figure, so fractional curves work: 8 rows with `center: 0.5, edge: 10`\n * give 10, 5, 2, 1, 0.5, 1, 2, 5, 10.\n * `rows` is rounded to at least 1, `center` raised to at least 0.01 and\n * `edge` to at least `center`.\n */\nexport function plinkoSlots(\n rowCount: number,\n options: { center?: number; edge?: number } = {},\n): number[] {\n const rows = Math.max(1, Math.round(rowCount) || 1);\n // Any positive center works; zero or below would divide by zero.\n const center = Math.max(0.01, options.center ?? 1);\n const edge = Math.max(center, options.edge ?? 100);\n const half = rows / 2;\n return Array.from({ length: rows + 1 }, (_, slot) => {\n const value = center * (edge / center) ** (Math.abs(slot - half) / half);\n if (value >= 1 && value < 10) return Math.round(value);\n // One significant figure: 46 reads as 50, 315 as 300, 0.46 as 0.5.\n return Number(value.toPrecision(1));\n });\n}\n\n/** An icon button that shows and toggles one on/off setting. */\nfunction ToggleButton({\n on,\n onToggle,\n label,\n onIcon: OnIcon,\n offIcon: OffIcon,\n}: {\n on: boolean;\n onToggle: () => void;\n label: string;\n onIcon: LucideIcon;\n offIcon: LucideIcon;\n}) {\n return (\n // aria-label names the button; the tooltip shows the same label on hover\n // and focus. Tooltip's asLabel would hydrate differently from the server.\n <Tooltip content={label} side=\"top\">\n <Button\n variant=\"secondary\"\n onClick={onToggle}\n aria-label={label}\n aria-pressed={on}\n pressScale={0.96}\n // Full strength when on, muted when off: the slash alone is a thin cue.\n className={cn(\"w-10 px-0\", on ? \"text-foreground\" : \"text-muted-foreground\")}\n >\n <ActionSwapCascadeIcon value={on ? \"on\" : \"off\"} className=\"size-4\">\n {on ? (\n <OnIcon aria-hidden=\"true\" className=\"size-4\" />\n ) : (\n <OffIcon aria-hidden=\"true\" className=\"size-4\" />\n )}\n </ActionSwapCascadeIcon>\n </Button>\n </Tooltip>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoDA,MAAM,MAAM;AACZ,MAAM,MAAM;AACZ,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;AACZ,MAAM,OAAO;AAKb,MAAM,OAAO;CAAC;CAAG;CAAM;CAAM;AAAC;AAC9B,MAAM,WAAW;AACjB,MAAM,YAAY;AAClB,MAAM,aAAa;AAEnB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AAoBvB,IAAI,WAAW;;AAGf,MAAM,YAAY,QAAgB,MAAM,MAAM,MAAM,MAAM;;AAG1D,SAAS,KAAK,MAAc,OAA8D;CACxF,MAAM,SAAS,QAAQ;CACvB,MAAM,SAAS,CAAC;EAAE,GAAG;EAAQ,GAAG;CAAK,CAAC;CACtC,MAAM,QAAkB,CAAC,GAAI;CAC7B,MAAM,OAAiB,CAAC;CACxB,IAAI,IAAI;CACR,KAAK,IAAI,MAAM,GAAG,MAAM,MAAM,OAAO;EACnC,MAAM,IAAI,UAAU,IAAI,MAAM,KAAK;EACnC,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG;EACvB,OAAO,KAAK;GAAE;GAAG,GAAG,SAAS,GAAG;EAAE,CAAC;EACnC,MAAM,QAAQ,KAAK,OAAO,IAAI;EAC9B,OAAO,KAAK;GAAE,GAAG,KAAK,QAAQ,MAAM,I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V,MAAM,OAAO,KAAK,IAAI,GAAG,KAAK,MAAM,QAAQ,KAAK,CAAC;CAElD,MAAM,SAAS,KAAK,IAAI,KAAM,QAAQ,UAAU,CAAC;CACjD,MAAM,OAAO,KAAK,IAAI,QAAQ,QAAQ,QAAQ,GAAG;CACjD,MAAM,OAAO,OAAO;CACpB,OAAO,MAAM,KAAK,EAAE,QAAQ,OAAO,EAAE,IAAI,GAAG,SAAS;EACnD,MAAM,QAAQ,UAAU,OAAO,YAAY,KAAK,IAAI,OAAO,IAAI,IAAI;EACnE,IAAI,SAAS,KAAK,QAAQ,IAAI,OAAO,KAAK,MAAM,KAAK;EAErD,OAAO,OAAO,MAAM,YAAY,CAAC,CAAC;CACpC,CAAC;AACH;;AAGA,SAAS,aAAa,EACpB,IACA,UACA,OACA,QAAQ,QACR,SAAS,WAOR;CACD,OAGE,oBAAC,SAAD;EAAS,SAAS;EAAO,MAAK;EAC5B,UAAA,oBAAC,QAAD;GACE,SAAQ;GACR,SAAS;GACT,cAAY;GACZ,gBAAc;GACd,YAAY;GAEZ,WAAW,GAAG,aAAa,KAAK,oBAAoB,uBAAuB;GAE3E,UAAA,oBAAC,uBAAD;IAAuB,OAAO,KAAK,OAAO;IAAO,WAAU;IACxD,UAAA,KACC,oBAAC,QAAD;KAAQ,eAAY;KAAO,WAAU;IAAU,CAAA,IAE/C,oBAAC,SAAD;KAAS,eAAY;KAAO,WAAU;IAAU,CAAA;GAE7B,CAAA;EACjB,CAAA;CACD,CAAA;AAEb"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { EASE_OUT, SPRING_LAYOUT } from "../../lib/ease.js";
|
|
3
3
|
import { StatefulButton } from "./button/stateful.js";
|
|
4
|
-
import "./button/index.js";
|
|
5
4
|
import { Checkbox } from "./checkbox.js";
|
|
6
5
|
import { Input } from "./input.js";
|
|
7
6
|
import { useCallback, useId, useMemo, useState } from "react";
|