Skip to content

Write HTML. Render video. Built for agents.

8.1 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>Badge Pop - 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: #f4f4f5;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .demo-frame {\n        display: grid;\n        place-items: center;\n        padding: 56px;\n        transform: scale(\n          3\n        ); /* ponytail: scale wrapper (hugs content — no min-width inflation), not GSAP targets */\n        transform-origin: center;\n      }\n      .hf-transition-badge-pop {\n        position: relative;\n        display: inline-grid;\n        place-items: center;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-badge-button {\n        display: grid;\n        place-items: center;\n        width: 76px;\n        height: 76px;\n        border: 1px solid #e4e4e7;\n        border-radius: 22px;\n        background: #ffffff;\n        color: #18181b;\n        box-shadow: 0 20px 58px rgba(0, 0, 0, 0.12);\n      }\n      .hf-transition-badge-button svg {\n        width: 30px;\n        height: 30px;\n        fill: none;\n        stroke: currentColor;\n        stroke-width: 2.2;\n        stroke-linecap: round;\n        stroke-linejoin: round;\n      }\n      .hf-transition-badge-count {\n        position: absolute;\n        right: -8px;\n        top: -8px;\n        display: grid;\n        place-items: center;\n        min-width: 30px;\n        height: 30px;\n        padding: 0 8px;\n        border: 3px solid #ffffff;\n        border-radius: 999px;\n        background: #ef4444;\n        color: #ffffff;\n        font-size: 13px;\n        font-weight: 900;\n        transform-origin: center;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"badge-pop-demo\"\n      data-start=\"0\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n      data-duration=\"5\"\n    >\n      <div class=\"demo-frame\">\n        <div\n          class=\"hf-transition-badge-pop\"\n          data-composition-variables='[\n    { \"id\": \"count\", \"type\": \"string\", \"role\": \"style\", \"label\": \"Count\", \"description\": \"Text shown inside the notification badge, up to four characters.\", \"default\": \"3\", \"maxLength\": 4 },\n    { \"id\": \"accent\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Accent\", \"description\": \"Colour family of the badge.\", \"default\": \"red\", \"options\": [{ \"value\": \"red\", \"label\": \"Red\" }, { \"value\": \"blue\", \"label\": \"Blue\" }, { \"value\": \"green\", \"label\": \"Green\" }, { \"value\": \"violet\", \"label\": \"Violet\" }] },\n    { \"id\": \"surface\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Surface\", \"description\": \"Chrome of the button and the badge ring: light for bright frames, dark for dark ones.\", \"default\": \"light\", \"options\": [{ \"value\": \"light\", \"label\": \"Light\" }, { \"value\": \"dark\", \"label\": \"Dark\" }] }\n  ]'\n        >\n          <button class=\"hf-transition-badge-button\" type=\"button\" aria-label=\"Notifications\">\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n              <path d=\"M18 8a6 6 0 10-12 0c0 7-3 7-3 7h18s-3 0-3-7\" />\n              <path d=\"M10 20a2 2 0 004 0\" />\n            </svg>\n          </button>\n          <span class=\"hf-transition-badge-count\">3</span>\n        </div>\n      </div>\n      <script>\n        (function () {\n          \"use strict\";\n\n          var vars =\n            window.__hyperframes && window.__hyperframes.getVariables\n              ? window.__hyperframes.getVariables()\n              : {};\n\n          // Unrecognised overrides return to their declared defaults.\n          function pick(table, value, fallback) {\n            return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;\n          }\n\n          // The badge is the one accent-carrying element here. red is the literal\n          // notification convention and stays; the decorative options ride the\n          // composition's own tokens and fall back to ink.\n          var accents = {\n            red: \"#ef4444\",\n            blue: \"var(--accent, #18181b)\",\n            green: \"var(--brand, #18181b)\",\n            violet: \"var(--accent-2, #18181b)\",\n          };\n          var surfaces = {\n            light: { surface: \"#ffffff\", border: \"#e4e4e7\", ink: \"#18181b\" },\n            dark: { surface: \"#101014\", border: \"#2a2a32\", ink: \"#fafafa\" },\n          };\n\n          var accent = accents[pick(accents, vars.accent, \"red\")];\n          var surface = surfaces[pick(surfaces, vars.surface, \"light\")];\n          var count =\n            typeof vars.count === \"string\" && vars.count.trim()\n              ? vars.count.trim().slice(0, 4)\n              : \"3\";\n\n          var roots = document.querySelectorAll(\".hf-transition-badge-pop\");\n          for (var i = 0; i < roots.length; i += 1) {\n            var root = roots[i];\n            root.style.setProperty(\"--hf-badge-pop-accent\", accent);\n            root.style.setProperty(\"--hf-badge-pop-surface\", surface.surface);\n            root.style.setProperty(\"--hf-badge-pop-border\", surface.border);\n            root.style.setProperty(\"--hf-badge-pop-ink\", surface.ink);\n            var label = root.querySelector(\".hf-transition-badge-count\");\n            if (label) {\n              label.textContent = count;\n            }\n          }\n        })();\n      </script>\n      <script>\n        const tl = gsap.timeline({ paused: true });\n        tl.fromTo(\n          \".hf-transition-badge-button\",\n          { y: 18, opacity: 0 },\n          { y: 0, opacity: 1, duration: 0.34, ease: \"power2.out\" },\n          0.35,\n        );\n        tl.fromTo(\n          \".hf-transition-badge-count\",\n          { scale: 0, opacity: 0 },\n          { scale: 1, opacity: 1, duration: 0.42, ease: \"back.out(2.4)\" },\n          0.7,\n        );\n        tl.to(\n          \".hf-transition-badge-count\",\n          { scale: 1.18, duration: 0.12, yoyo: true, repeat: 1, ease: \"power1.inOut\" },\n          1.15,\n        );\n        tl.set({}, {}, 5);\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"badge-pop-demo\"] = tl;\n      </script>\n    </div>\n    <style>\n      .hf-transition-badge-pop {\n        --hf-badge-pop-accent: #ef4444;\n        --hf-badge-pop-surface: #ffffff;\n        --hf-badge-pop-border: #e4e4e7;\n        --hf-badge-pop-ink: #18181b;\n        position: relative;\n        display: inline-grid;\n        place-items: center;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-badge-button {\n        display: grid;\n        place-items: center;\n        width: 76px;\n        height: 76px;\n        border: 1px solid var(--hf-badge-pop-border);\n        border-radius: 22px;\n        background: var(--hf-badge-pop-surface);\n        color: var(--hf-badge-pop-ink);\n        box-shadow: 0 20px 58px rgba(0, 0, 0, 0.12);\n      }\n      .hf-transition-badge-button svg {\n        width: 30px;\n        height: 30px;\n        fill: none;\n        stroke: currentColor;\n        stroke-width: 2.2;\n        stroke-linecap: round;\n        stroke-linejoin: round;\n      }\n      .hf-transition-badge-count {\n        position: absolute;\n        right: -8px;\n        top: -8px;\n        display: grid;\n        place-items: center;\n        min-width: 30px;\n        height: 30px;\n        padding: 0 8px;\n        border: 3px solid var(--hf-badge-pop-surface);\n        border-radius: 999px;\n        background: var(--hf-badge-pop-accent);\n        color: #ffffff;\n        font-size: 13px;\n        font-weight: 900;\n        transform-origin: center;\n      }\n    </style>\n  </body>\n</html>\n"}