diff options
| author | alex <[email protected]> | 2026-11-10 21:04:55 +0100 |
|---|---|---|
| committer | alex <[email protected]> | 2026-11-10 21:04:55 +0100 |
| commit | 51f7f58bbb6bdcfd5df86e6b0756545fa251b524 (patch) | |
| tree | e90458fa9f89352dca4cbfb7f8bf6b400578c0ca | |
| parent | 5bdac896f505b850142682a12e3f5961f775efb7 (diff) | |
| download | wheel-of-names-clone.git-51f7f58bbb6bdcfd5df86e6b0756545fa251b524.tar.xz wheel-of-names-clone.git-51f7f58bbb6bdcfd5df86e6b0756545fa251b524.zip | |
only has the wheel now
| -rw-r--r-- | public/app.js | 40 | ||||
| -rw-r--r-- | public/index.html | 21 | ||||
| -rw-r--r-- | public/styles.css | 167 |
3 files changed, 12 insertions, 216 deletions
diff --git a/public/app.js b/public/app.js index a757086..9c8e6a8 100644 --- a/public/app.js +++ b/public/app.js @@ -1,9 +1,6 @@ const socket = io(); const wheelEl = document.getElementById("wheel"); -const winnerChip = document.getElementById("winnerChip"); -const exampleCommandsEl = document.getElementById("exampleCommands"); - const ctx = wheelEl.getContext("2d"); const radius = wheelEl.width / 2; const center = { x: radius, y: radius }; @@ -12,7 +9,6 @@ const palette = ["#d95d39", "#f2a541", "#4f6d7a", "#90be6d", "#f28482", "#8d5a97 const appState = { entries: [], - selectedWinner: null, angle: 0, spinning: false, }; @@ -68,23 +64,6 @@ const drawWheel = () => { ctx.restore(); }; -const normalizeAngle = (angle) => { - const full = Math.PI * 2; - return ((angle % full) + full) % full; -}; - -const indexAtPointer = () => { - const count = appState.entries.length; - if (!count) { - return -1; - } - - const slice = (Math.PI * 2) / count; - const pointerAngle = -Math.PI / 2; - const relative = normalizeAngle(pointerAngle - appState.angle); - return Math.floor(relative / slice) % count; -}; - const targetAngleForWinner = (winner) => { const entries = appState.entries; const winnerIndex = entries.indexOf(winner); @@ -130,13 +109,6 @@ const animateSpin = (winner) => { appState.angle = final; drawWheel(); appState.spinning = false; - - const idx = indexAtPointer(); - const landed = idx >= 0 ? appState.entries[idx] : winner; - winnerChip.textContent = `Winner: ${landed}`; - winnerChip.classList.remove("pulse"); - void winnerChip.offsetWidth; - winnerChip.classList.add("pulse"); }; requestAnimationFrame(frame); @@ -144,19 +116,7 @@ const animateSpin = (winner) => { const setState = (next) => { appState.entries = Array.isArray(next.entries) ? next.entries : []; - appState.selectedWinner = next.selectedWinner || null; drawWheel(); - - if (!appState.selectedWinner) { - winnerChip.textContent = "Waiting for spin..."; - } - - const commands = [ - `curl -X POST http://localhost:3000/api/entries \\\n+ -H 'Content-Type: application/json' \\\n+ -d '{"entries":["Alice","Bob","Charlie","Diana"]}'`, - `curl -X POST http://localhost:3000/api/spin \\\n+ -H 'Content-Type: application/json' \\\n+ -d '{"winner":"Charlie"}'`, - ]; - - exampleCommandsEl.textContent = commands.join("\n\n"); }; socket.on("state", setState); diff --git a/public/index.html b/public/index.html index f27fc20..00a14da 100644 --- a/public/index.html +++ b/public/index.html @@ -13,31 +13,10 @@ <link rel="stylesheet" href="styles.css" /> </head> <body> - <div class="background-shape shape-one"></div> - <div class="background-shape shape-two"></div> <main class="app-shell"> - <header class="hero"> - <p class="label">Show Mode Wheel</p> - <h1>Pick the winner from your terminal</h1> - <p class="subtitle"> - This wheel is controlled by API calls. The spin animation is visual-only, - while you choose the winner in advance. - </p> - </header> - <section class="wheel-area"> <canvas id="wheel" width="640" height="640" aria-label="Wheel"></canvas> <div class="pointer" aria-hidden="true"></div> - <div class="winner-chip" id="winnerChip">Waiting for spin...</div> - </section> - - <section class="controls"> - <h2>How to control it</h2> - <ol> - <li>Set names via <code>POST /api/entries</code></li> - <li>Trigger winner via <code>POST /api/spin</code></li> - </ol> - <pre><code id="exampleCommands"></code></pre> </section> </main> diff --git a/public/styles.css b/public/styles.css index a35ab47..720aadb 100644 --- a/public/styles.css +++ b/public/styles.css @@ -1,15 +1,6 @@ :root { - --bg: #f6efe6; - --ink: #1f1b18; - --muted: #5c5249; - --panel: #fff8f0; - --accent-a: #d95d39; - --accent-b: #f2a541; - --accent-c: #4f6d7a; - --accent-d: #90be6d; - --accent-e: #f28482; - --accent-f: #8d5a97; - --shadow: 0 24px 48px rgba(31, 27, 24, 0.16); + --bg-a: #fdf2e4; + --bg-b: #f2e5d5; } * { @@ -18,103 +9,40 @@ body { margin: 0; - min-height: 100vh; + min-height: 100dvh; + display: grid; + place-items: center; font-family: "Alegreya Sans", sans-serif; - color: var(--ink); - background: radial-gradient(circle at 10% 10%, #fff7ec 0%, #f6efe6 50%, #efe4d6 100%); + background: radial-gradient(circle at 50% 20%, var(--bg-a) 0%, var(--bg-b) 100%); overflow-x: hidden; } -.background-shape { - position: fixed; - border-radius: 999px; - opacity: 0.5; - filter: blur(2px); - pointer-events: none; - z-index: 0; -} - -.shape-one { - width: 360px; - height: 360px; - top: -100px; - left: -120px; - background: linear-gradient(140deg, #f2a541, #d95d39); -} - -.shape-two { - width: 340px; - height: 340px; - right: -100px; - bottom: -110px; - background: linear-gradient(160deg, #90be6d, #4f6d7a); -} - .app-shell { position: relative; - z-index: 1; + width: 100%; display: grid; - grid-template-columns: minmax(280px, 720px); - justify-content: center; - gap: 1.5rem; - padding: 2rem 1rem 2.5rem; -} - -.hero { - background: color-mix(in oklab, var(--panel), white 35%); - border: 1px solid rgba(31, 27, 24, 0.1); - border-radius: 20px; - padding: 1rem 1.2rem; - box-shadow: var(--shadow); - animation: riseIn 500ms ease-out both; -} - -.label { - margin: 0; - color: var(--muted); - font-size: 0.95rem; - letter-spacing: 0.06em; - text-transform: uppercase; - font-weight: 700; -} - -h1 { - margin: 0.2rem 0 0; - font-family: "Fraunces", serif; - font-size: clamp(1.8rem, 4vw, 2.6rem); - line-height: 1.1; -} - -.subtitle { - margin: 0.7rem 0 0; - color: var(--muted); - font-size: 1.08rem; + place-items: center; + padding: 1rem; } .wheel-area { position: relative; display: grid; justify-items: center; - gap: 0.8rem; - padding: 1rem; - background: color-mix(in oklab, var(--panel), white 30%); - border: 1px solid rgba(31, 27, 24, 0.09); - border-radius: 20px; - box-shadow: var(--shadow); + padding: 0.75rem; animation: riseIn 650ms ease-out both; } #wheel { - width: min(88vw, 560px); + width: min(92vmin, 640px); height: auto; border-radius: 50%; box-shadow: inset 0 0 0 10px #fdf6ea, 0 10px 24px rgba(31, 27, 24, 0.2); - transform: rotate(0deg); } .pointer { position: absolute; - top: 12px; + top: 8px; width: 0; height: 0; border-left: 16px solid transparent; @@ -123,57 +51,6 @@ h1 { filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.2)); } -.winner-chip { - min-height: 40px; - display: grid; - place-items: center; - border-radius: 999px; - padding: 0.5rem 1rem; - background: #fff; - border: 1px solid rgba(31, 27, 24, 0.15); - font-weight: 700; -} - -.winner-chip.pulse { - animation: pulse 480ms ease; -} - -.controls { - background: color-mix(in oklab, var(--panel), white 25%); - border-radius: 20px; - border: 1px solid rgba(31, 27, 24, 0.09); - box-shadow: var(--shadow); - padding: 1rem 1.2rem; - animation: riseIn 800ms ease-out both; -} - -h2 { - margin: 0; - font-family: "Fraunces", serif; -} - -ol { - margin: 0.5rem 0 0; - padding-left: 1.2rem; -} - -li { - margin: 0.4rem 0; -} - -pre { - margin: 0.8rem 0 0; - background: #1f1b18; - color: #f7efe5; - border-radius: 12px; - padding: 0.9rem; - overflow-x: auto; -} - -code { - font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; -} - @keyframes riseIn { from { transform: translateY(12px); @@ -185,28 +62,8 @@ code { } } -@keyframes pulse { - 0% { - transform: scale(1); - } - 45% { - transform: scale(1.07); - } - 100% { - transform: scale(1); - } -} - @media (max-width: 640px) { - .app-shell { - padding-top: 1rem; - } - .pointer { top: 8px; } - - .subtitle { - font-size: 1rem; - } } |
