Skip to content

Write HTML. Render video. Built for agents.

9.8 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>Tabs Slide Indicator - 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 only — GSAP targets .indicator inside, not this element */\n        transform: scale(3.5);\n      }\n      .hf-transition-tabs-slide-indicator {\n        --hf-tab-x: 0px;\n        --hf-tab-offset: var(--hf-tab-x);\n        position: relative;\n        display: inline-grid;\n        grid-template-columns: repeat(3, 86px);\n        padding: 4px;\n        border: 1px solid #e4e4e7;\n        border-radius: 999px;\n        background: #f4f4f5;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-tabs-slide-indicator .indicator {\n        position: absolute;\n        top: 4px;\n        left: 4px;\n        width: 86px;\n        height: 36px;\n        border-radius: 999px;\n        background: #18181b;\n        transform: translateX(var(--hf-tab-offset));\n        box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);\n      }\n      .hf-transition-tabs-slide-indicator button {\n        --hf-tab-highlight-start: clamp(\n          0px,\n          calc(var(--hf-tab-offset) - var(--hf-tab-index) * 86px),\n          86px\n        );\n        --hf-tab-highlight-end: clamp(\n          0px,\n          calc(var(--hf-tab-offset) + 86px - var(--hf-tab-index) * 86px),\n          86px\n        );\n        position: relative;\n        z-index: 1;\n        height: 36px;\n        border: 0;\n        background-color: transparent;\n        background-image: linear-gradient(\n          to right,\n          #6f6f78 0 var(--hf-tab-highlight-start),\n          #fff var(--hf-tab-highlight-start) var(--hf-tab-highlight-end),\n          #6f6f78 var(--hf-tab-highlight-end) 100%\n        );\n        background-clip: text;\n        -webkit-background-clip: text;\n        color: transparent;\n        font-weight: 600;\n      }\n    </style>\n  </head>\n  <body>\n    <div\n      id=\"demo\"\n      data-composition-id=\"tabs-slide-indicator-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-tabs-slide-indicator\"\n          data-composition-variables='[\n    { \"id\": \"accent\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Accent\", \"description\": \"Fill of the sliding pill. ink is literal; the rest ride the composition theme tokens.\", \"default\": \"ink\", \"options\": [{ \"value\": \"ink\", \"label\": \"Ink\" }, { \"value\": \"green\", \"label\": \"Green\" }, { \"value\": \"blue\", \"label\": \"Blue\" }, { \"value\": \"violet\", \"label\": \"Violet\" }] },\n    { \"id\": \"width\", \"type\": \"enum\", \"role\": \"layout\", \"label\": \"Tab width\", \"description\": \"Width of one tab. The slide the timeline drives is scaled to match, so the pill still lands on the next tab.\", \"default\": \"standard\", \"options\": [{ \"value\": \"compact\", \"label\": \"Compact\" }, { \"value\": \"standard\", \"label\": \"Standard\" }, { \"value\": \"wide\", \"label\": \"Wide\" }] },\n    { \"id\": \"shape\", \"type\": \"enum\", \"role\": \"style\", \"label\": \"Shape\", \"description\": \"Corner radius of the track and the pill.\", \"default\": \"pill\", \"options\": [{ \"value\": \"pill\", \"label\": \"Pill\" }, { \"value\": \"rounded\", \"label\": \"Rounded\" }, { \"value\": \"square\", \"label\": \"Square\" }] },\n    { \"id\": \"labels\", \"type\": \"string\", \"role\": \"content\", \"label\": \"Labels\", \"description\": \"The tab names, separated by commas. Two or more names rebuild the row.\", \"default\": \"Plan,Debug,Ask\" }\n  ]'\n        >\n          <span class=\"indicator\"></span><button style=\"--hf-tab-index: 0\">Plan</button\n          ><button style=\"--hf-tab-index: 1\">Debug</button\n          ><button style=\"--hf-tab-index: 2\">Ask</button>\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          // The pill is the one accent-carrying element here, so the three chromatic\n          // options ride the composition's own tokens and fall back to ink.\n          var accents = {\n            ink: \"#18181b\",\n            green: \"var(--brand, #18181b)\",\n            blue: \"var(--accent, #18181b)\",\n            violet: \"var(--accent-2, #18181b)\",\n          };\n          var widths = { compact: 72, standard: 86, wide: 104 };\n          var shapes = { pill: \"999px\", rounded: \"12px\", square: \"4px\" };\n\n          function pick(table, value, fallback) {\n            return Object.prototype.hasOwnProperty.call(table, value) ? value : fallback;\n          }\n\n          var accent = accents[pick(accents, vars.accent, \"ink\")];\n          var width = widths[pick(widths, vars.width, \"standard\")];\n          var radius = shapes[pick(shapes, vars.shape, \"pill\")];\n          var labels =\n            typeof vars.labels === \"string\"\n              ? vars.labels.split(\",\").map(function (part) {\n                  return part.trim();\n                })\n              : [];\n          labels = labels.filter(function (part) {\n            return part.length > 0;\n          });\n\n          var roots = document.querySelectorAll(\".hf-transition-tabs-slide-indicator\");\n          for (var i = 0; i < roots.length; i += 1) {\n            roots[i].style.setProperty(\"--hf-tab-fill\", accent);\n            roots[i].style.setProperty(\"--hf-tab-width\", width + \"px\");\n            // The timeline slides the pill by one standard tab, so scale that slide\n            // to whatever a tab is actually worth here.\n            roots[i].style.setProperty(\"--hf-tab-step\", String(width / 86));\n            roots[i].style.setProperty(\"--hf-tab-radius\", radius);\n            // A single tab has nowhere to slide to, so it is left as authored.\n            if (labels.length > 1) {\n              var old = roots[i].querySelectorAll(\"button\");\n              for (var j = 0; j < old.length; j += 1) {\n                old[j].parentNode.removeChild(old[j]);\n              }\n              for (var k = 0; k < labels.length; k += 1) {\n                var button = document.createElement(\"button\");\n                button.textContent = labels[k];\n                button.style.setProperty(\"--hf-tab-index\", String(k));\n                roots[i].appendChild(button);\n              }\n              roots[i].style.setProperty(\"--hf-tab-count\", String(labels.length));\n            }\n          }\n        })();\n      </script>\n      <script>\n        const tl = gsap.timeline({ paused: true });\n        const startTime = 0.5;\n        tl.fromTo(\n          \".hf-transition-tabs-slide-indicator\",\n          { \"--hf-tab-x\": \"0px\" },\n          { \"--hf-tab-x\": \"86px\", duration: 0.42, ease: \"power3.inOut\" },\n          startTime,\n        );\n        window.__timelines = window.__timelines || {};\n        window.__timelines[\"tabs-slide-indicator-demo\"] = tl;\n      </script>\n    </div>\n    <style>\n      .hf-transition-tabs-slide-indicator {\n        --hf-tab-x: 0px;\n        --hf-tab-offset: calc(var(--hf-tab-x) * var(--hf-tab-step, 1));\n        position: relative;\n        display: inline-grid;\n        grid-template-columns: repeat(var(--hf-tab-count, 3), var(--hf-tab-width, 86px));\n        padding: 4px;\n        border: 1px solid #e4e4e7;\n        border-radius: var(--hf-tab-radius, 999px);\n        background: #f4f4f5;\n        font-family: Inter, system-ui, sans-serif;\n      }\n      .hf-transition-tabs-slide-indicator .indicator {\n        position: absolute;\n        top: 4px;\n        left: 4px;\n        width: var(--hf-tab-width, 86px);\n        height: 36px;\n        border-radius: var(--hf-tab-radius, 999px);\n        background: var(--hf-tab-fill, #18181b);\n        transform: translateX(var(--hf-tab-offset));\n        box-shadow: 0 12px 26px rgba(0, 0, 0, 0.18);\n      }\n      .hf-transition-tabs-slide-indicator button {\n        --hf-tab-highlight-start: clamp(\n          0px,\n          calc(var(--hf-tab-offset) - var(--hf-tab-index) * var(--hf-tab-width, 86px)),\n          var(--hf-tab-width, 86px)\n        );\n        --hf-tab-highlight-end: clamp(\n          0px,\n          calc(\n            var(--hf-tab-offset) + var(--hf-tab-width, 86px) - var(--hf-tab-index) *\n              var(--hf-tab-width, 86px)\n          ),\n          var(--hf-tab-width, 86px)\n        );\n        position: relative;\n        z-index: 1;\n        height: 36px;\n        border: 0;\n        background-color: transparent;\n        background-image: linear-gradient(\n          to right,\n          #6f6f78 0 var(--hf-tab-highlight-start),\n          #fff var(--hf-tab-highlight-start) var(--hf-tab-highlight-end),\n          #6f6f78 var(--hf-tab-highlight-end) 100%\n        );\n        background-clip: text;\n        -webkit-background-clip: text;\n        color: transparent;\n        font-weight: 850;\n      }\n    </style>\n  </body>\n</html>\n"}