Skip to content

Write HTML. Render video. Built for agents.

8.9 KB
Raw Blame
{"html":"<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <meta name=\"viewport\" content=\"width=1920, height=1080\" />\n    <title>Number Wheel - Demo</title>\n    <script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/gsap.min.js\"></script>\n    <style>\n      * {\n        box-sizing: border-box;\n      }\n      html,\n      body {\n        margin: 0;\n        width: 1920px;\n        height: 1080px;\n        overflow: hidden;\n      }\n      #demo {\n        width: 1920px;\n        height: 1080px;\n        display: grid;\n        place-items: center;\n        background: #071b16;\n        color: #ecfff8;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .metric {\n        text-align: center;\n        /* ponytail: zoom scales the non-animated wrapper; GSAP owns .label and .hf-number-wheel-strip transforms */\n        zoom: 2.8;\n      }\n      .label {\n        color: #68d8b5;\n        font-size: 38px;\n        font-weight: 800;\n        text-transform: uppercase;\n        letter-spacing: 0.1em;\n      }\n      .hf-number-wheel {\n        margin-top: 36px;\n        display: inline-flex;\n        align-items: baseline;\n        gap: 0.02em;\n        font-size: 172px;\n        font-weight: 900;\n        font-variant-numeric: tabular-nums;\n      }\n      .hf-number-wheel-digit {\n        display: inline-block;\n        height: 1em;\n        overflow: hidden;\n      }\n      .hf-number-wheel-strip {\n        display: grid;\n        transform: translateY(0em);\n        will-change: transform;\n      }\n      .hf-number-wheel-strip span {\n        height: 1em;\n        line-height: 1em;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"number-wheel-demo\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n      data-duration=\"5\"\n      data-composition-variables='[\n    { \"id\": \"spin\", \"type\": \"enum\", \"role\": \"motion\", \"label\": \"Spin\", \"description\": \"How many full 0 to 9 revolutions each column adds before it lands, which is how far the reel travels in the same time.\", \"default\": \"single\", \"options\": [{ \"value\": \"single\", \"label\": \"Single\" }, { \"value\": \"double\", \"label\": \"Double\" }, { \"value\": \"triple\", \"label\": \"Triple\" }] },\n    { \"id\": \"spacing\", \"type\": \"enum\", \"role\": \"layout\", \"label\": \"Spacing\", \"description\": \"Gap between the digit columns.\", \"default\": \"standard\", \"options\": [{ \"value\": \"tight\", \"label\": \"Tight\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"wide\", \"label\": \"Wide\" }] },\n    { \"id\": \"tone\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Tone\", \"description\": \"Digit colour: inherit keeps the surrounding text colour, ink suits light frames, paper suits dark ones, accent rides --brand.\", \"default\": \"inherit\", \"options\": [{ \"value\": \"inherit\", \"label\": \"Inherit\" }, { \"value\": \"ink\", \"label\": \"Ink\" }, { \"value\": \"paper\", \"label\": \"Paper\" }, { \"value\": \"accent\", \"label\": \"Accent\" }] }\n  ]'\n    >\n      <div class=\"metric\">\n        <div class=\"label\">GitHub stars</div>\n        <span class=\"hf-number-wheel\" data-value=\"30222\"></span>\n      </div>\n      <script>\n        (function () {\n          const vars =\n            window.__hyperframes && window.__hyperframes.getVariables\n              ? window.__hyperframes.getVariables()\n              : {};\n\n          // Unrecognised overrides return to their declared defaults.\n          const spins = { single: 0, double: 1, triple: 2 };\n          const gaps = { tight: \"0em\", standard: \"0.02em\", wide: \"0.14em\" };\n          const tones = {\n            inherit: \"inherit\",\n            ink: \"#18181b\",\n            paper: \"#fafafa\",\n            accent: \"var(--brand, #34d399)\",\n          };\n          const pick = (table, value, fallback) =>\n            Object.prototype.hasOwnProperty.call(table, value) ? table[value] : table[fallback];\n\n          const cycles = pick(spins, vars.spin, \"single\");\n          const gap = pick(gaps, vars.spacing, \"standard\");\n          const tone = pick(tones, vars.tone, \"inherit\");\n\n          document.querySelectorAll(\".hf-number-wheel\").forEach((el) => {\n            if (el.dataset.hfNumberWheelReady === \"1\") return;\n            el.style.setProperty(\"--hf-wheel-gap\", gap);\n            el.style.setProperty(\"--hf-wheel-color\", tone);\n            const value = el.dataset.value || \"0\";\n            el.textContent = \"\";\n            for (const char of value) {\n              if (!/\\d/.test(char)) {\n                el.append(document.createTextNode(char));\n                continue;\n              }\n              const stops = cycles * 10 + Number(char);\n              const frame = document.createElement(\"span\");\n              frame.className = \"hf-number-wheel-digit\";\n              const strip = document.createElement(\"span\");\n              strip.className = \"hf-number-wheel-strip\";\n              strip.style.setProperty(\"--hf-number-target-y\", `${-stops}em`);\n              for (let i = 0; i <= stops; i++) {\n                const step = document.createElement(\"span\");\n                step.textContent = String(i % 10);\n                strip.appendChild(step);\n              }\n              frame.appendChild(strip);\n              el.appendChild(frame);\n            }\n            el.dataset.hfNumberWheelReady = \"1\";\n          });\n        })();\n      </script>\n      <script>\n        document.querySelectorAll(\".hf-number-wheel\").forEach((el) => {\n          const value = el.dataset.value || \"0\";\n          el.textContent = \"\";\n          for (const char of value) {\n            if (!/\\d/.test(char)) {\n              el.append(document.createTextNode(char));\n              continue;\n            }\n            const digit = Number(char);\n            const frame = document.createElement(\"span\");\n            frame.className = \"hf-number-wheel-digit\";\n            const strip = document.createElement(\"span\");\n            strip.className = \"hf-number-wheel-strip\";\n            strip.style.setProperty(\"--hf-number-target-y\", `${-digit}em`);\n            for (let i = 0; i <= digit; i++) {\n              const step = document.createElement(\"span\");\n              step.textContent = String(i);\n              strip.appendChild(step);\n            }\n            frame.appendChild(strip);\n            el.appendChild(frame);\n          }\n        });\n        const tl = gsap.timeline({ paused: true });\n        tl.from(\".label\", { opacity: 0, y: 18, duration: 0.5, ease: \"power3.out\" }, 0.2);\n        tl.to(\n          \".hf-number-wheel-strip\",\n          {\n            y: (_, strip) => strip.style.getPropertyValue(\"--hf-number-target-y\"),\n            duration: 1.2,\n            ease: \"power3.out\",\n            stagger: 0.06,\n          },\n          0.65,\n        );\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"number-wheel-demo\"] = tl;\n      </script>\n    </div>\n    <style\n      data-composition-variables='[\n    { \"id\": \"spin\", \"type\": \"enum\", \"role\": \"motion\", \"label\": \"Spin\", \"description\": \"How many full 0 to 9 revolutions each column adds before it lands, which is how far the reel travels in the same time.\", \"default\": \"single\", \"options\": [{ \"value\": \"single\", \"label\": \"Single\" }, { \"value\": \"double\", \"label\": \"Double\" }, { \"value\": \"triple\", \"label\": \"Triple\" }] },\n    { \"id\": \"spacing\", \"type\": \"enum\", \"role\": \"layout\", \"label\": \"Spacing\", \"description\": \"Gap between the digit columns.\", \"default\": \"standard\", \"options\": [{ \"value\": \"tight\", \"label\": \"Tight\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"wide\", \"label\": \"Wide\" }] },\n    { \"id\": \"tone\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Tone\", \"description\": \"Digit colour: inherit keeps the surrounding text colour, ink suits light frames, paper suits dark ones, accent rides --brand.\", \"default\": \"inherit\", \"options\": [{ \"value\": \"inherit\", \"label\": \"Inherit\" }, { \"value\": \"ink\", \"label\": \"Ink\" }, { \"value\": \"paper\", \"label\": \"Paper\" }, { \"value\": \"accent\", \"label\": \"Accent\" }] }\n  ]'\n    >\n      .hf-number-wheel {\n        display: inline-flex;\n        align-items: baseline;\n        gap: var(--hf-wheel-gap, 0.02em);\n        color: var(--hf-wheel-color, inherit);\n        font-variant-numeric: tabular-nums;\n      }\n      .hf-number-wheel-digit {\n        display: inline-block;\n        height: 1em;\n        overflow: hidden;\n      }\n      .hf-number-wheel-strip {\n        display: grid;\n        transform: translateY(0em);\n        will-change: transform;\n      }\n      .hf-number-wheel-strip span {\n        height: 1em;\n        line-height: 1em;\n      }\n    </style>\n  </body>\n</html>\n"}