Skip to content

Write HTML. Render video. Built for agents.

7.6 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>Icon Swap - 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: #f7f7f8;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .demo-frame {\n        display: grid;\n        place-items: center;\n        min-width: 760px;\n        min-height: 480px;\n        padding: 56px;\n        /* ponytail: scale wrapper (not a GSAP target) to fill ~65% of frame */\n        transform: scale(1.47);\n      }\n      .hf-transition-icon-swap {\n        position: relative;\n        display: grid;\n        place-items: center;\n        width: 58px;\n        height: 58px;\n        border: 0;\n        border-radius: 16px;\n        background: #18181b;\n        color: #fff;\n        font:\n          900 28px/1 Inter,\n          system-ui,\n          sans-serif;\n        box-shadow: 0 18px 44px rgba(24, 24, 27, 0.22);\n      }\n      .hf-transition-icon-swap span {\n        position: absolute;\n        filter: blur(var(--hf-icon-blur, 0px));\n        transform: scale(var(--hf-icon-scale, 1)) rotate(var(--hf-icon-rotate, 0deg));\n        will-change: transform, filter, opacity;\n      }\n      .hf-transition-icon-swap .to {\n        opacity: 0;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"icon-swap-demo\"\n      data-start=\"0\"\n      data-width=\"1920\"\n      data-height=\"1080\"\n      data-duration=\"5\"\n    >\n      <div class=\"demo-frame\">\n        <button\n          class=\"hf-transition-icon-swap\"\n          type=\"button\"\n          data-composition-variables='[\n    { \"id\": \"tone\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Tone\", \"description\": \"Button fill and glyph colour. Accent rides --brand.\", \"default\": \"dark\", \"options\": [{ \"value\": \"dark\", \"label\": \"Dark\" }, { \"value\": \"light\", \"label\": \"Light\" }, { \"value\": \"accent\", \"label\": \"Accent\" }] },\n    { \"id\": \"size\", \"type\": \"enum\", \"role\": \"layout\", \"label\": \"Size\", \"description\": \"Button box and glyph size, from a toolbar chip to a hero action.\", \"default\": \"standard\", \"options\": [{ \"value\": \"small\", \"label\": \"Small\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"large\", \"label\": \"Large\" }] },\n    { \"id\": \"shape\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Shape\", \"description\": \"Corner treatment of the button box.\", \"default\": \"rounded\", \"options\": [{ \"value\": \"rounded\", \"label\": \"Rounded\" }, { \"value\": \"circle\", \"label\": \"Circle\" }, { \"value\": \"square\", \"label\": \"Square\" }] },\n    { \"id\": \"blur\", \"type\": \"enum\", \"role\": \"motion\", \"label\": \"Blur\", \"description\": \"Scales the blur radius the timeline drives through the swap, from a light haze to a full smear.\", \"default\": \"standard\", \"options\": [{ \"value\": \"soft\", \"label\": \"Soft\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"heavy\", \"label\": \"Heavy\" }] }\n  ]'\n        >\n          <span class=\"from\">+</span><span class=\"to\">OK</span>\n        </button>\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          var tones = {\n            dark: { bg: \"#18181b\", fg: \"#ffffff\" },\n            light: { bg: \"#fafafa\", fg: \"#18181b\" },\n            accent: { bg: \"var(--brand, #34d399)\", fg: \"#052e21\" },\n          };\n          var sizes = {\n            small: { box: \"44px\", font: \"22px\" },\n            standard: { box: \"58px\", font: \"28px\" },\n            large: { box: \"76px\", font: \"38px\" },\n          };\n          var shapes = { rounded: \"16px\", circle: \"50%\", square: \"6px\" };\n          var blurScales = { soft: 0.45, standard: 1, heavy: 2.2 };\n\n          var tone = tones[pick(tones, vars.tone, \"dark\")];\n          var size = sizes[pick(sizes, vars.size, \"standard\")];\n          var shape = shapes[pick(shapes, vars.shape, \"rounded\")];\n          var blurScale = blurScales[pick(blurScales, vars.blur, \"standard\")];\n\n          var roots = document.querySelectorAll(\".hf-transition-icon-swap\");\n          for (var i = 0; i < roots.length; i += 1) {\n            roots[i].style.setProperty(\"--hf-icon-bg\", tone.bg);\n            roots[i].style.setProperty(\"--hf-icon-fg\", tone.fg);\n            roots[i].style.setProperty(\"--hf-icon-size\", size.box);\n            roots[i].style.setProperty(\"--hf-icon-font-size\", size.font);\n            roots[i].style.setProperty(\"--hf-icon-radius\", shape);\n            roots[i].style.setProperty(\"--hf-icon-blur-scale\", String(blurScale));\n          }\n        })();\n      </script>\n      <script>\n        const tl = gsap.timeline({ paused: true });\n        const startTime = 0.5;\n        tl.to(\n          \".hf-transition-icon-swap .from\",\n          {\n            opacity: 0,\n            \"--hf-icon-scale\": 0.55,\n            \"--hf-icon-blur\": \"8px\",\n            \"--hf-icon-rotate\": \"-18deg\",\n            duration: 0.18,\n            ease: \"power2.in\",\n          },\n          startTime,\n        );\n        tl.fromTo(\n          \".hf-transition-icon-swap .to\",\n          {\n            opacity: 0,\n            \"--hf-icon-scale\": 1.35,\n            \"--hf-icon-blur\": \"8px\",\n            \"--hf-icon-rotate\": \"18deg\",\n          },\n          {\n            opacity: 1,\n            \"--hf-icon-scale\": 1,\n            \"--hf-icon-blur\": \"0px\",\n            \"--hf-icon-rotate\": \"0deg\",\n            duration: 0.26,\n            ease: \"back.out(1.7)\",\n          },\n          startTime + 0.12,\n        );\n        tl.set({}, {}, 5);\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"icon-swap-demo\"] = tl;\n      </script>\n    </div>\n    <style>\n      .hf-transition-icon-swap {\n        position: relative;\n        display: grid;\n        place-items: center;\n        width: var(--hf-icon-size, 58px);\n        height: var(--hf-icon-size, 58px);\n        border: 0;\n        border-radius: var(--hf-icon-radius, 16px);\n        background: var(--hf-icon-bg, #18181b);\n        color: var(--hf-icon-fg, #fff);\n        font:\n          900 28px/1 Inter,\n          system-ui,\n          sans-serif;\n        font-size: var(--hf-icon-font-size, 28px);\n        box-shadow: 0 18px 44px rgba(24, 24, 27, 0.22);\n      }\n      .hf-transition-icon-swap span {\n        position: absolute;\n        filter: blur(calc(var(--hf-icon-blur, 0px) * var(--hf-icon-blur-scale, 1)));\n        transform: scale(var(--hf-icon-scale, 1)) rotate(var(--hf-icon-rotate, 0deg));\n        will-change: transform, filter, opacity;\n      }\n      .hf-transition-icon-swap .to {\n        opacity: 0;\n      }\n    </style>\n  </body>\n</html>\n"}