Skip to content

Write HTML. Render video. Built for agents.

8.5 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>Menu Morph - 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        min-width: 760px;\n        min-height: 480px;\n        padding: 56px;\n        /* ponytail: scale the wrapper — GSAP animates children, not this element */\n        transform: scale(3.4);\n      }\n      .hf-transition-menu-morph {\n        position: relative;\n        display: grid;\n        place-items: center;\n        width: 360px;\n        height: 280px;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-menu-button {\n        z-index: 2;\n        display: grid;\n        place-items: center;\n        gap: 5px;\n        width: 68px;\n        height: 68px;\n        border: 0;\n        border-radius: 999px;\n        background: #18181b;\n        box-shadow: 0 22px 58px rgba(0, 0, 0, 0.22);\n      }\n      .hf-transition-menu-button span {\n        width: 24px;\n        height: 3px;\n        border-radius: 999px;\n        background: #ffffff;\n        transform-origin: center;\n      }\n      .hf-transition-menu-actions {\n        position: absolute;\n        display: flex;\n        gap: 10px;\n        bottom: 20px;\n      }\n      .hf-transition-menu-actions div {\n        padding: 10px 16px;\n        border-radius: 999px;\n        background: #ffffff;\n        color: #18181b;\n        font-size: 14px;\n        font-weight: 700;\n        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);\n        border: 1px solid #e4e4e7;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"menu-morph-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-menu-morph\"\n          data-composition-variables='[\n    { \"id\": \"actions\", \"type\": \"string\", \"role\": \"content\", \"label\": \"Actions\", \"description\": \"Comma separated labels for the pills that fan out under the button. Up to six.\", \"default\": \"Text, Image, Audio\" },\n    { \"id\": \"tone\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Tone\", \"description\": \"Colour of the round button behind the white bars.\", \"default\": \"ink\", \"options\": [{ \"value\": \"ink\", \"label\": \"Ink\" }, { \"value\": \"green\", \"label\": \"Green\" }, { \"value\": \"blue\", \"label\": \"Blue\" }, { \"value\": \"violet\", \"label\": \"Violet\" }] },\n    { \"id\": \"size\", \"type\": \"number\", \"role\": \"layout\", \"label\": \"Button size\", \"description\": \"Diameter of the round button in pixels. The bars scale with it.\", \"default\": 68, \"min\": 52, \"max\": 112, \"step\": 4, \"unit\": \"px\" }\n  ]'\n        >\n          <button class=\"hf-transition-menu-button\" type=\"button\" aria-label=\"Menu\">\n            <span></span><span></span><span></span>\n          </button>\n          <div class=\"hf-transition-menu-actions\">\n            <div>Text</div>\n            <div>Image</div>\n            <div>Audio</div>\n          </div>\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          // Anything missing or invalid returns to its declared default.\n          // The button is the one accent-carrying element here, so the three\n          // chromatic options ride the composition's own tokens and fall back to ink.\n          var tones = {\n            ink: \"#18181b\",\n            green: \"var(--brand, #18181b)\",\n            blue: \"var(--accent, #18181b)\",\n            violet: \"var(--accent-2, #18181b)\",\n          };\n\n          function pick(table, value, fallback) {\n            return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;\n          }\n\n          var labels = [];\n          if (typeof vars.actions === \"string\") {\n            var parts = vars.actions.split(\",\");\n            for (var p = 0; p < parts.length && labels.length < 6; p += 1) {\n              var label = parts[p].trim();\n              if (label) {\n                labels.push(label);\n              }\n            }\n          }\n          if (!labels.length) {\n            labels = [\"Text\", \"Image\", \"Audio\"];\n          }\n\n          var size =\n            typeof vars.size === \"number\" || typeof vars.size === \"string\"\n              ? Number(vars.size)\n              : NaN;\n          size = isFinite(size) && size > 0 ? Math.min(112, Math.max(52, size)) : 68;\n\n          var tone = tones[pick(tones, vars.tone, \"ink\")];\n\n          var roots = document.querySelectorAll(\".hf-transition-menu-morph\");\n          for (var i = 0; i < roots.length; i += 1) {\n            roots[i].style.setProperty(\"--hf-menu-size\", size + \"px\");\n            roots[i].style.setProperty(\"--hf-menu-bg\", tone);\n            var row = roots[i].querySelector(\".hf-transition-menu-actions\");\n            if (!row) {\n              continue;\n            }\n            while (row.firstChild) {\n              row.removeChild(row.firstChild);\n            }\n            for (var j = 0; j < labels.length; j += 1) {\n              var pill = document.createElement(\"div\");\n              pill.textContent = labels[j];\n              row.appendChild(pill);\n            }\n          }\n        })();\n      </script>\n      <script>\n        const tl = gsap.timeline({ paused: true });\n        tl.fromTo(\n          \".hf-transition-menu-button\",\n          { scale: 0.72, opacity: 0 },\n          { scale: 1, opacity: 1, duration: 0.34, ease: \"back.out(1.8)\" },\n          0.3,\n        );\n        tl.to(\n          \".hf-transition-menu-button span:nth-child(1)\",\n          { y: 8, rotation: 45, duration: 0.24, ease: \"power2.inOut\" },\n          0.78,\n        );\n        tl.to(\n          \".hf-transition-menu-button span:nth-child(2)\",\n          { opacity: 0, duration: 0.18, ease: \"power1.out\" },\n          0.78,\n        );\n        tl.to(\n          \".hf-transition-menu-button span:nth-child(3)\",\n          { y: -8, rotation: -45, duration: 0.24, ease: \"power2.inOut\" },\n          0.78,\n        );\n        tl.fromTo(\n          \".hf-transition-menu-actions div\",\n          { y: 28, opacity: 0, scale: 0.86 },\n          { y: 0, opacity: 1, scale: 1, duration: 0.26, stagger: 0.06, ease: \"back.out(1.6)\" },\n          0.96,\n        );\n        tl.set({}, {}, 5);\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"menu-morph-demo\"] = tl;\n      </script>\n    </div>\n    <style>\n      .hf-transition-menu-morph {\n        position: relative;\n        display: grid;\n        place-items: center;\n        width: 360px;\n        height: 220px;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-menu-button {\n        z-index: 2;\n        display: grid;\n        place-items: center;\n        gap: 5px;\n        width: var(--hf-menu-size, 68px);\n        height: var(--hf-menu-size, 68px);\n        border: 0;\n        border-radius: 999px;\n        background: var(--hf-menu-bg, #18181b);\n        box-shadow: 0 22px 58px rgba(0, 0, 0, 0.22);\n      }\n      .hf-transition-menu-button span {\n        width: calc(var(--hf-menu-size, 68px) * 6 / 17);\n        height: 3px;\n        border-radius: 999px;\n        background: #ffffff;\n        transform-origin: center;\n      }\n      .hf-transition-menu-actions {\n        position: absolute;\n        display: flex;\n        gap: 10px;\n        bottom: 20px;\n      }\n      .hf-transition-menu-actions div {\n        padding: 9px 13px;\n        border-radius: 999px;\n        background: #ffffff;\n        color: #18181b;\n        font-size: 13px;\n        font-weight: 850;\n        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.12);\n      }\n    </style>\n  </body>\n</html>\n"}