Skip to content

Write HTML. Render video. Built for agents.

feat(studio): shared Button, IconButton, Tooltip and Tabs primitives (#3622)

Miguel Ángel01aa446edf6a
diff --git a/.fallowrc.jsonc b/.fallowrc.jsonc
index 3cef6d7b2e..7d2dff4b73 100644
--- a/.fallowrc.jsonc
+++ b/.fallowrc.jsonc
@@ -1,6 +1,8 @@
{
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/config-schema.json",
"entry": [
+ // IconButton, Tabs and cn are exported before their first consumer exists.
+ "packages/studio/src/components/ui/index.ts",
"packages/producer/src/**/*.test.ts",
"packages/aws-lambda/src/**/*.test.ts",
"packages/gcp-cloud-run/src/**/*.test.ts",
diff --git a/bun.lock b/bun.lock
index e668339a15..2f12ae0876 100644
--- a/bun.lock
+++ b/bun.lock
@@ -24,7 +24,7 @@
},
"packages/aws-lambda": {
"name": "@hyperframes/aws-lambda",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@aws-sdk/client-s3": "^3.700.0",
"@aws-sdk/client-sfn": "^3.700.0",
@@ -57,7 +57,7 @@
},
"packages/cli": {
"name": "@hyperframes/cli",
- "version": "0.8.48",
+ "version": "0.8.50",
"bin": {
"hyperframes": "./bin/hyperframes.mjs",
"hyperframes-localize-fonts": "./bin/hyperframes-localize-fonts.mjs",
@@ -109,7 +109,7 @@
},
"packages/core": {
"name": "@hyperframes/core",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@chenglou/pretext": "^0.0.5",
"@hyperframes/lint": "workspace:*",
@@ -134,7 +134,7 @@
},
"packages/engine": {
"name": "@hyperframes/engine",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@hono/node-server": "^2.0.5",
"@hyperframes/core": "workspace:^",
@@ -153,7 +153,7 @@
},
"packages/gcp-cloud-run": {
"name": "@hyperframes/gcp-cloud-run",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@google-cloud/storage": "^7.14.0",
"@google-cloud/workflows": "^4.2.0",
@@ -174,7 +174,7 @@
},
"packages/lint": {
"name": "@hyperframes/lint",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@hyperframes/parsers": "workspace:*",
"htmlparser2": "^10.1.0",
@@ -192,7 +192,7 @@
},
"packages/parsers": {
"name": "@hyperframes/parsers",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@babel/parser": "^7.27.0",
"acorn": "^8.17.0",
@@ -212,7 +212,7 @@
},
"packages/player": {
"name": "@hyperframes/player",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@hyperframes/core": "workspace:*",
},
@@ -227,7 +227,7 @@
},
"packages/producer": {
"name": "@hyperframes/producer",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@fontsource/archivo-black": "^5.2.8",
"@fontsource/eb-garamond": "^5.2.7",
@@ -272,7 +272,7 @@
},
"packages/sdk": {
"name": "@hyperframes/sdk",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@hyperframes/core": "workspace:*",
"@hyperframes/parsers": "workspace:*",
@@ -302,7 +302,7 @@
},
"packages/shader-transitions": {
"name": "@hyperframes/shader-transitions",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"html2canvas": "^1.4.1",
},
@@ -314,8 +314,9 @@
},
"packages/studio": {
"name": "@hyperframes/studio",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
+ "@base-ui/react": "1.7.0",
"@codemirror/autocomplete": "^6.20.1",
"@codemirror/commands": "^6.10.3",
"@codemirror/lang-css": "^6.3.1",
@@ -336,6 +337,7 @@
"@phosphor-icons/react": "^2.1.10",
"@tanstack/react-virtual": "^3.14.6",
"bpm-detective": "^2.0.5",
+ "cn": "0.2.4",
"dockview-react": "8.3.1",
"gsap": "^3.13.0",
"mediabunny": "^1.45.3",
@@ -364,7 +366,7 @@
},
"packages/studio-server": {
"name": "@hyperframes/studio-server",
- "version": "0.8.48",
+ "version": "0.8.50",
"dependencies": {
"@hyperframes/core": "workspace:*",
"@hyperframes/parsers": "workspace:*",
@@ -487,15 +489,15 @@
"@babel/helper-plugin-utils": ["@babel/[email protected]", "", {}, "sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug=="],
- "@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+ "@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw=="],
- "@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+ "@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="],
"@babel/helper-validator-option": ["@babel/[email protected]", "", {}, "sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg=="],
"@babel/helpers": ["@babel/[email protected]", "", { "dependencies": { "@babel/template": "^7.28.6", "@babel/types": "^7.29.0" } }, "sha512-HoGuUs4sCZNezVEKdVcwqmZN8GoHirLUcLaYVNBK2J0DadGtdcqgr3BCbvH8+XUo4NGjNl3VOtSjEKNzqfFgKw=="],
- "@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+ "@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.8" }, "bin": "./bin/babel-parser.js" }, "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA=="],
"@babel/plugin-transform-react-jsx-self": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-plugin-utils": "^7.27.1" }, "peerDependencies": { "@babel/core": "^7.0.0-0" } }, "sha512-6UzkCs+ejGdZ5mFFC/OCUrv028ab2fp1znZmCZjAOBKiBK2jXD1O+BPSfX8X2qjJ75fZBMSnQn3Rq2mrBJK2mw=="],
@@ -507,10 +509,14 @@
"@babel/traverse": ["@babel/[email protected]", "", { "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", "@babel/helper-globals": "^7.28.0", "@babel/parser": "^7.29.0", "@babel/template": "^7.28.6", "@babel/types": "^7.29.0", "debug": "^4.3.1" } }, "sha512-4HPiQr0X7+waHfyXPZpWPfWL/J7dcN1mx9gL6WdQVMbPnF3+ZhSMs8tCxN7oHddJE9fhNE7+lxdnlyemKfJRuA=="],
- "@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+ "@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg=="],
"@balena/dockerignore": ["@balena/[email protected]", "", {}, "sha512-wMue2Sy4GAVTk6Ic4tJVcnfdau+gx2EnG7S+uAEe+TWJFqE4YoWN4/H8MSLj4eYJKxGg26lZwboEniNiNwZQ6Q=="],
+ "@base-ui/react": ["@base-ui/[email protected]", "", { "dependencies": { "@babel/runtime": "^7.29.2", "@base-ui/utils": "0.3.2", "@floating-ui/react-dom": "^2.1.9", "@floating-ui/utils": "^0.2.12", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "@date-fns/tz": "^1.2.0", "@types/react": "^17 || ^18 || ^19", "date-fns": "^4.0.0", "react": "^17 || ^18 || ^19", "react-dom": "^17 || ^18 || ^19" }, "optionalPeers": ["@date-fns/tz", "@types/react", "date-fns"] }, "sha512-j+8QjX44C32jrXD/qyEAGpFr70FRpGL2CY61mQd9nBPWN737CK0xxD1ceJ055rW4RtdvFDT1e7otzdlfxvsYug=="],
+
+ "@base-ui/utils": ["@base-ui/[email protected]", "", { "dependencies": { "@babel/runtime": "^7.29.2", "@floating-ui/utils": "^0.2.12", "reselect": "^5.2.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "@types/react": "^17 || ^18 || ^19", "react": "^17 || ^18 || ^19", "react-dom": "^17 || ^18 || ^19" }, "optionalPeers": ["@types/react"] }, "sha512-oWy1aq/I2GmYjpl4PhEAhzflF8VPGKgZeq0xAWTbfD5KBWyxcN0ZP2+WHSUm/5Z6lVMBDLReLcoXwSYoRc/zNQ=="],
+
"@bcoe/v8-coverage": ["@bcoe/[email protected]", "", {}, "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA=="],
"@bramus/specificity": ["@bramus/[email protected]", "", { "dependencies": { "css-tree": "^3.0.0" }, "bin": { "specificity": "bin/cli.js" } }, "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw=="],
@@ -671,6 +677,14 @@
"@fallow-cli/win32-x64-msvc": ["@fallow-cli/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-h8W+qEOPvyolBQO2Y0H4/pz2XXw/1yHA8/XRPo3/tYRovmN2zoNjDrvaGjjodzFt6fBVLus+T0uo+U4pMgOu/w=="],
+ "@floating-ui/core": ["@floating-ui/[email protected]", "", { "dependencies": { "@floating-ui/utils": "^0.2.12" } }, "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ=="],
+
+ "@floating-ui/dom": ["@floating-ui/[email protected]", "", { "dependencies": { "@floating-ui/core": "^1.8.0", "@floating-ui/utils": "^0.2.12" } }, "sha512-yXSrzeHZBTZadLOlfyhCkJHNeLJnHRnRInwdZ40L7ZiaAtrBwoYlsDrX3v5zB1Utk7CLfzcOVnVVWoXEky7Ceg=="],
+
+ "@floating-ui/react-dom": ["@floating-ui/[email protected]", "", { "dependencies": { "@floating-ui/dom": "^1.8.0" }, "peerDependencies": { "react": ">=16.8.0", "react-dom": ">=16.8.0" } }, "sha512-JDjEFGCpImxDCA7JJKviA0M9+RtmJdj0m/NVU5IMgBK+AmZouAQQ7/+2GLH0GXXY0YMw9oXPB8hKdbPYg5QLYg=="],
+
+ "@floating-ui/utils": ["@floating-ui/[email protected]", "", {}, "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww=="],
+
"@fontsource/archivo-black": ["@fontsource/[email protected]", "", {}, "sha512-3zNj/o9LzWyDl/UEpY5IOHpAQyUtFr3hQaFS7NSKwCLLkXOfH/CMCt1L2b2Z+OF25OURtOYenCadgAebALz7/A=="],
"@fontsource/eb-garamond": ["@fontsource/[email protected]", "", {}, "sha512-V42tTlHDbnDo0+lENnXKWMx63Llq6Gfl2l7ozkoeRQN60S0jm6hEgCLlOT/5YyKAN9QZ0e2ofpy0rGKlz9jBrw=="],
@@ -1353,6 +1367,8 @@
"clone": ["[email protected]", "", {}, "sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="],
+ "cn": ["[email protected]", "", { "bin": { "cn": "bin/cn.mjs" } }, "sha512-SzQvoh5FwizWtQg9+JueKdjWhlfCZMdu5DqNHm9q1wUlRVmKb9WXlepR9bTTbPwzEOyX1ujJ6lcCppmn3bNUCg=="],
+
"color-convert": ["[email protected]", "", { "dependencies": { "color-name": "~1.1.4" } }, "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ=="],
"color-name": ["[email protected]", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="],
@@ -1435,8 +1451,6 @@
"dfa": ["[email protected]", "", {}, "sha512-ED3jP8saaweFTjeGX8HQPjeC1YYyZs98jGNZx6IiBvxW7JG5v492kamAQB3m2wop07CvU/RQmzcKr6bgcC5D/Q=="],
-
-
"dockview": ["[email protected]", "", { "dependencies": { "dockview-core": "^8.3.1" } }, "sha512-2odBC9cDKcVCVx8Db86vq9s9JZKzbgvdkxDzcfsrD9nORLc5UqhLgLvVcJguorBv7CyEpKDzFO1JVLYWJCYrJA=="],
"dockview-core": ["[email protected]", "", {}, "sha512-6Loais9hlIRo25sTQSWGWlgbPr22ddoLBzpGDFaTnocawnC45twp5f2S2WxUz5/HPa/a65I4yxKUqZa8xrcc5Q=="],
@@ -1905,6 +1919,8 @@
"require-from-string": ["[email protected]", "", {}, "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw=="],
+ "reselect": ["[email protected]", "", {}, "sha512-XGoLeRAVzUTcJ1qkxPQhDJyIZ5d6zzZD9nT7AEZOaaU9UbWclhycElmhO+VD5bFeLuzhPBaOV2oXC8uG35ZSpg=="],
+
"resolve-from": ["[email protected]", "", {}, "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw=="],
"resolve-pkg-maps": ["[email protected]", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
@@ -2079,6 +2095,8 @@
"update-browserslist-db": ["[email protected]", "", { "dependencies": { "escalade": "^3.2.0", "picocolors": "^1.1.1" }, "peerDependencies": { "browserslist": ">= 4.21.0" }, "bin": { "update-browserslist-db": "cli.js" } }, "sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w=="],
+ "use-sync-external-store": ["[email protected]", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A=="],
+
"util-deprecate": ["[email protected]", "", {}, "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="],
"utrie": ["[email protected]", "", { "dependencies": { "base64-arraybuffer": "^1.0.2" } }, "sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw=="],
@@ -2149,14 +2167,38 @@
"@aws-cdk/cloud-assembly-schema/semver": ["[email protected]", "", { "bundled": true, "bin": { "semver": "bin/semver.js" } }, "sha512-AcM7dV/5ul4EekoQ29Agm5vri8JNqRyj39o0qpX6vDF2GZrtutZl5RwgD1XnZjiTAfncsJhMI48QQH3sN87YNA=="],
+ "@babel/code-frame/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
"@babel/code-frame/js-tokens": ["[email protected]", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="],
+ "@babel/core/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@babel/core/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
"@babel/core/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
+ "@babel/generator/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@babel/generator/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
"@babel/helper-compilation-targets/lru-cache": ["[email protected]", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
"@babel/helper-compilation-targets/semver": ["[email protected]", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="],
+ "@babel/helper-module-imports/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@babel/helper-module-transforms/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@babel/helpers/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@babel/template/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@babel/template/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@babel/traverse/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@babel/traverse/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
"@codemirror/lang-markdown/@codemirror/view": ["@codemirror/[email protected]", "", { "dependencies": { "@codemirror/state": "^6.6.0", "crelt": "^1.0.6", "style-mod": "^4.1.0", "w3c-keyname": "^2.2.4" } }, "sha512-ToN3oFc0nsxNUYVF5P0ztLgbC4UPPjPtA9aKYhkOKQaZASpOUo6ISXyQLP66ctVwlDc+j6Jv0uK5IFALkiXztg=="],
"@codemirror/lint/@codemirror/view": ["@codemirror/[email protected]", "", { "dependencies": { "@codemirror/state": "^6.6.0", "crelt": "^1.0.6", "style-mod": "^4.1.0", "w3c-keyname": "^2.2.4" } }, "sha512-ToN3oFc0nsxNUYVF5P0ztLgbC4UPPjPtA9aKYhkOKQaZASpOUo6ISXyQLP66ctVwlDc+j6Jv0uK5IFALkiXztg=="],
@@ -2187,6 +2229,18 @@
"@tailwindcss/oxide-wasm32-wasi/tslib": ["[email protected]", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
+ "@types/babel__core/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@types/babel__core/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@types/babel__generator/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@types/babel__template/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.0" }, "bin": "./bin/babel-parser.js" }, "sha512-b3ctpQwp+PROvU/cttc4OYl4MzfJUWy6FZg+PMXfzmt/+39iHVF0sDfqay8TQM3JA2EUOyKcFZt75jWriQijsA=="],
+
+ "@types/babel__template/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
+ "@types/babel__traverse/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.27.1", "@babel/helper-validator-identifier": "^7.28.5" } }, "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A=="],
+
"aws-cdk-lib/yaml": ["[email protected]", "", {}, "sha512-vIYeF1u3CjlhAFekPPAk2h/Kv4T3mAkMox5OymRiJQB0spDP10LHvt+K7G9Ny6NuuMAb25/6n1qyUjAcGNf/AA=="],
"chalk/supports-color": ["[email protected]", "", { "dependencies": { "has-flag": "^4.0.0" } }, "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw=="],
@@ -2227,10 +2281,6 @@
"jsdom/whatwg-mimetype": ["[email protected]", "", {}, "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw=="],
- "magicast/@babel/parser": ["@babel/[email protected]", "", { "dependencies": { "@babel/types": "^7.29.8" }, "bin": "./bin/babel-parser.js" }, "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA=="],
-
- "magicast/@babel/types": ["@babel/[email protected]", "", { "dependencies": { "@babel/helper-string-parser": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7" } }, "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg=="],
-
"minizlib/minipass": ["[email protected]", "", {}, "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A=="],
"mlly/acorn": ["[email protected]", "", { "bin": { "acorn": "bin/acorn" } }, "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw=="],
@@ -2261,8 +2311,32 @@
"vite/postcss": ["[email protected]", "", { "dependencies": { "nanoid": "^3.3.11", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-SoSL4+OSEtR99LHFZQiJLkT59C5B1amGO1NzTwj7TT1qCUgUO6hxOvzkOYxD+vMrXBM3XJIKzokoERdqQq/Zmg=="],
+ "@babel/core/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/core/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@babel/generator/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/generator/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
"@babel/helper-compilation-targets/lru-cache/yallist": ["[email protected]", "", {}, "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="],
+ "@babel/helper-module-imports/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/helper-module-imports/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@babel/helpers/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/helpers/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@babel/template/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/template/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@babel/traverse/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@babel/traverse/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
"@google-cloud/storage/google-auth-library/gcp-metadata": ["[email protected]", "", { "dependencies": { "gaxios": "^6.1.1", "google-logging-utils": "^0.0.2", "json-bigint": "^1.0.0" } }, "sha512-a4tiq7E0/5fTjxPAaH4jpjkSv/uCaU2p5KC6HVGrvl0cDjA8iBZv4vv1gyzlmK0ZUKqwpOyQMKzZQe3lTit77A=="],
"@isaacs/cliui/string-width/emoji-regex": ["[email protected]", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
@@ -2277,6 +2351,22 @@
"@puppeteer/browsers/yargs/yargs-parser": ["[email protected]", "", {}, "sha512-rwu/ClNdSMpkSrUb+d6BRsSkLUq1fmfsY6TOpYzTwvwkg1/NRG85KBy3kq++A8LKQwX6lsu+aWad+2khvuXrqw=="],
+ "@types/babel__core/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@types/babel__core/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@types/babel__generator/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@types/babel__generator/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@types/babel__template/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@types/babel__template/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
+ "@types/babel__traverse/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA=="],
+
+ "@types/babel__traverse/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q=="],
+
"gaxios/https-proxy-agent/agent-base": ["[email protected]", "", {}, "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ=="],
"gcp-metadata/gaxios/https-proxy-agent": ["[email protected]", "", { "dependencies": { "agent-base": "^7.1.2", "debug": "4" } }, "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw=="],
@@ -2295,10 +2385,6 @@
"google-gax/retry-request/teeny-request": ["[email protected]", "", { "dependencies": { "http-proxy-agent": "^7.0.0", "https-proxy-agent": "^7.0.1", "node-fetch": "^3.3.2", "stream-events": "^1.0.5" } }, "sha512-5yDliI1uWkYPo7W+Zvrxg6YmoWuj5iC5EydewqrRTvc68nyMTZhlPPlLg6cptUGfbQAb+N9XDPDPzF6N081lug=="],
- "magicast/@babel/types/@babel/helper-string-parser": ["@babel/[email protected]", "", {}, "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw=="],
-
- "magicast/@babel/types/@babel/helper-validator-identifier": ["@babel/[email protected]", "", {}, "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg=="],
-
"node-fetch/whatwg-url/tr46": ["[email protected]", "", {}, "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="],
"node-fetch/whatwg-url/webidl-conversions": ["[email protected]", "", {}, "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ=="],
diff --git a/packages/studio/package.json b/packages/studio/package.json
index bedd5c69d3..963f230516 100644
--- a/packages/studio/package.json
+++ b/packages/studio/package.json
@@ -58,6 +58,7 @@
"test:timeline-default": "bun run test:timeline-virtualization"
},
"dependencies": {
+ "@base-ui/react": "1.7.0",
"@codemirror/autocomplete": "^6.20.1",
"@codemirror/commands": "^6.10.3",
"@codemirror/lang-css": "^6.3.1",
@@ -78,6 +79,7 @@
"@phosphor-icons/react": "^2.1.10",
"@tanstack/react-virtual": "^3.14.6",
"bpm-detective": "^2.0.5",
+ "cn": "0.2.4",
"dockview-react": "8.3.1",
"gsap": "^3.13.0",
"mediabunny": "^1.45.3"
diff --git a/packages/studio/src/components/ui/Button.test.tsx b/packages/studio/src/components/ui/Button.test.tsx
index 4c1a8a7ef8..32ff1e5133 100644
--- a/packages/studio/src/components/ui/Button.test.tsx
+++ b/packages/studio/src/components/ui/Button.test.tsx
@@ -1,57 +1,249 @@
// @vitest-environment happy-dom
-// happy-dom has no CSS engine, so this pins the structure that makes the gap
-// work (children are direct flex items of the gap-bearing button), not the
-// computed pixels. The measured gap is verified in a real browser.
+/**
+ * Button/IconButton: renders every variant and size, then compiles Studio's
+ * real stylesheet against the emitted classes so an unstyled class fails.
+ */
+import { createRequire } from "node:module";
+import { readFileSync } from "node:fs";
+import path from "node:path";
+import React, { act } from "react";
+import { compile } from "tailwindcss";
+import { afterEach, beforeAll, describe, expect, it } from "vitest";
+import { Button, type ButtonSize, type ButtonVariant } from "./Button";
+import { IconButton } from "./IconButton";
+import { Tab, Tabs, TabsList } from "./Tabs";
+import { cleanupMounted, mountHost } from "./mountHost.testHelpers";
+import { isTypingTarget } from "../../utils/typingTarget";
+import { shouldIgnorePlaybackShortcutTarget } from "../../player/lib/playbackShortcuts";
-import { act } from "react";
-import { createRoot, type Root } from "react-dom/client";
-import { afterEach, describe, expect, it } from "vitest";
-import { Button } from "./Button";
+const VARIANTS: ButtonVariant[] = ["primary", "secondary", "danger", "ghost"];
+const SIZES: ButtonSize[] = ["sm", "md", "lg"];
-Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
+afterEach(cleanupMounted);
-let root: Root | null = null;
+function classesOf(host: HTMLElement, selector = "button"): string[] {
+ const el = host.querySelector(selector);
+ if (!el) throw new Error(`nothing matched ${selector}`);
+ return [...el.classList];
+}
+
+// -- the compiled stylesheet, built once for the whole file --
-afterEach(() => {
- if (root) act(() => root?.unmount());
- root = null;
- document.body.innerHTML = "";
+const STYLES_DIR = path.resolve(__dirname, "../../styles");
+const require = createRequire(import.meta.url);
+const TAILWIND_DIR = path.dirname(require.resolve("tailwindcss/package.json"));
+
+async function loadStylesheet(id: string, base: string) {
+ const file = id === "tailwindcss" ? path.join(TAILWIND_DIR, "index.css") : path.resolve(base, id);
+ return { path: file, base: path.dirname(file), content: readFileSync(file, "utf8") };
+}
+
+let compileStudioCss: (candidates: string[]) => string;
+
+beforeAll(async () => {
+ const compiled = await compile(readFileSync(path.join(STYLES_DIR, "studio.css"), "utf8"), {
+ base: STYLES_DIR,
+ loadStylesheet,
+ });
+ compileStudioCss = (candidates) => compiled.build(candidates);
});
-function mount(element: React.ReactNode): HTMLButtonElement {
- const host = document.createElement("div");
- document.body.append(host);
- root = createRoot(host);
- act(() => root?.render(element));
- const button = host.querySelector("button");
- if (!button) throw new Error("button did not render");
- return button;
+function unresolved(candidates: string[]): string[] {
+ const css = compileStudioCss(candidates);
+ return candidates.filter((candidate) => !css.includes(CSS.escape(candidate)));
}
-describe("Button children layout", () => {
- it("lays label and kbd out as sibling flex items of the gap-bearing button", () => {
- const button = mount(
+describe("Button classes", () => {
+ it("emits only classes Studio's stylesheet defines", () => {
+ const emitted = new Set<string>();
+ for (const variant of VARIANTS) {
+ for (const size of SIZES) {
+ const host = mountHost(
+ <>
+ <Button variant={variant} size={size}>
+ Export
+ </Button>
+ <IconButton variant={variant} size={size} icon={null} aria-label="Zoom out" />
+ </>,
+ );
+ for (const el of host.querySelectorAll("button")) {
+ for (const cls of el.classList) emitted.add(cls);
+ }
+ cleanupMounted();
+ }
+ }
+
+ expect(emitted.size).toBeGreaterThan(20);
+ expect(unresolved([...emitted])).toEqual([]);
+ });
+
+ it("fails an undefined class, so the check above is not vacuous", () => {
+ // Names in a real namespace with no token behind them; the theme file now defines the
+ // `rounded-button` pair this used to name.
+ expect(unresolved(["bg-not-a-token", "text-step-999"])).toEqual([
+ "bg-not-a-token",
+ "text-step-999",
+ ]);
+ });
+
+ it("lets a caller's type size beat the size's own", () => {
+ // The Renders Export case: `size="md"` brings `text-step-12`, the caller
+ // wants 11px, and with plain concatenation both survived into the class
+ // list and the stylesheet's order decided the winner.
+ const classes = classesOf(mountHost(<Button size="md" className="text-step-11" />));
+
+ expect(classes).toContain("text-step-11");
+ expect(classes).not.toContain("text-step-12");
+ });
+
+ it("keeps every interactive look reachable without a pointer", () => {
+ // `data-preview-state` exists so a gallery can show the hover, active and
+ // focus looks. It is worth nothing if it drifts from the real state, so
+ // each pair is matched here in both directions.
+ const realPrefix = {
+ hover: ["enabled:hover:", "hover:"],
+ active: ["enabled:active:", "active:"],
+ focus: ["focus-visible:"],
+ };
+
+ for (const variant of VARIANTS) {
+ const classes = classesOf(mountHost(<Button variant={variant}>Export</Button>));
+ cleanupMounted();
+
+ for (const [state, prefixes] of Object.entries(realPrefix)) {
+ const previewPrefix = `data-[preview-state=${state}]:`;
+ const preview = classes
+ .filter((cls) => cls.startsWith(previewPrefix))
+ .map((cls) => cls.slice(previewPrefix.length));
+ const real = classes
+ .filter((cls) => prefixes.some((prefix) => cls.startsWith(prefix)))
+ .map((cls) => cls.slice(cls.lastIndexOf(":") + 1));
+
+ expect([...preview].sort(), `${variant} ${state}`).toEqual([...real].sort());
+ expect(preview.length, `${variant} ${state}`).toBeGreaterThan(0);
+ }
+ }
+ });
+
+ it("uses a motion token that zeroes itself under reduced motion", () => {
+ // AE4. The zero-duration case lives in the `duration-press` utility itself
+ // (theme.css), not in a `motion-reduce:` class beside it, so a caller
+ // cannot use the token and forget the reduced-motion half. The button's
+ // job is to name the token; the stylesheet's job is the media query.
+ expect(classesOf(mountHost(<Button>Export</Button>))).toContain("duration-press");
+
+ expect(compileStudioCss(["duration-press"])).toMatch(
+ /\.duration-press \{[\s\S]*?prefers-reduced-motion: reduce[\s\S]*?transition-duration: 0ms/,
+ );
+ });
+});
+
+describe("Button behaviour", () => {
+ it("does not fire a disabled click, and says it is disabled", () => {
+ let clicks = 0;
+ const host = mountHost(
+ <Button disabled onClick={() => (clicks += 1)}>
+ Export
+ </Button>,
+ );
+ const button = host.querySelector("button")!;
+
+ act(() => button.click());
+
+ expect(clicks).toBe(0);
+ expect(button.getAttribute("aria-disabled")).toBe("true");
+ });
+
+ it("still fires a click while a preview state is forced", () => {
+ let clicks = 0;
+ const host = mountHost(
+ <Button data-preview-state="hover" onClick={() => (clicks += 1)}>
+ Export
+ </Button>,
+ );
+ const button = host.querySelector("button")!;
+
+ act(() => button.click());
+
+ expect(clicks).toBe(1);
+ expect(button.getAttribute("data-preview-state")).toBe("hover");
+ });
+
+ it("is classified by the hotkey selectors the way a plain button is", () => {
+ // KTD13. Both selector lists gate on roles and element names. A primitive
+ // that landed on a different role would leak or swallow global hotkeys with
+ // nothing to notice it.
+ const host = mountHost(
+ <>
+ <button type="button" data-testid="plain">
+ Export
+ </button>
+ <Button data-testid="primitive">Export</Button>
+ <Tabs defaultValue="code">
+ <TabsList aria-label="Sidebar panels">
+ <Tab value="code">Code</Tab>
+ </TabsList>
+ </Tabs>
+ </>,
+ );
+ const plain = host.querySelector('[data-testid="plain"]')!;
+ const button = host.querySelector('[data-testid="primitive"]')!;
+ const tab = host.querySelector('[role="tab"]')!;
+
+ for (const el of [plain, button, tab]) {
+ expect(isTypingTarget(el)).toBe(false);
+ expect(shouldIgnorePlaybackShortcutTarget(el)).toBe(true);
+ }
+ });
+});
+
+describe("disabled states", () => {
+ it("disables a loading Button", () => {
+ const host = mountHost(<Button loading>Save</Button>);
+ const button = host.querySelector("button");
+
+ expect(button?.disabled).toBe(true);
+ expect(button?.getAttribute("aria-disabled")).toBe("true");
+ });
+
+ it("marks a disabled IconButton for assistive tech", () => {
+ const host = mountHost(<IconButton aria-label="Undo" icon={<svg />} disabled />);
+ const button = host.querySelector("button");
+
+ expect(button?.disabled).toBe(true);
+ expect(button?.getAttribute("aria-disabled")).toBe("true");
+ });
+});
+
+describe("children layout", () => {
+ it("keeps label and shortcut direct flex items of the gap-bearing button without an icon", () => {
+ const host = mountHost(
<Button size="md">
<span>Export</span>
<kbd>⌘E</kbd>
</Button>,
);
+ const button = host.querySelector("button");
- expect(button.classList.contains("inline-flex")).toBe(true);
- expect(button.classList.contains("gap-1.5")).toBe(true);
- expect(Array.from(button.children).map((child) => child.tagName)).toEqual(["SPAN", "KBD"]);
+ expect(button?.classList.contains("inline-flex")).toBe(true);
+ expect(button?.classList.contains("gap-1.5")).toBe(true);
+ expect(Array.from(button?.children ?? []).map((child) => child.tagName)).toEqual([
+ "SPAN",
+ "KBD",
+ ]);
});
- it("puts children next to the icon as direct flex items too", () => {
- const button = mount(
+ it("makes label and shortcut direct flex items so the button gap applies between them", () => {
+ const host = mountHost(
<Button icon={<svg />}>
<span>Export</span>
<kbd>⌘E</kbd>
</Button>,
);
+ const button = host.querySelector("button");
- expect(Array.from(button.children).map((child) => child.tagName)).toEqual([
+ expect(Array.from(button?.children ?? []).map((child) => child.tagName)).toEqual([
"SPAN",
"SPAN",
"KBD",
diff --git a/packages/studio/src/components/ui/Button.tsx b/packages/studio/src/components/ui/Button.tsx
index 79ea62093c..979c7d77fe 100644
--- a/packages/studio/src/components/ui/Button.tsx
+++ b/packages/studio/src/components/ui/Button.tsx
@@ -1,159 +1,119 @@
/**
- * Button & IconButton — The most important primitive.
+ * Button — a native `<button>` wearing Studio's tokens.
*
- * Absorbs: active state (scale 0.98), hit target (min 32px),
- * shadow anatomy (primary), focus ring, disabled state,
- * loading state, reduced motion, proper timing tokens.
+ * Everything visual comes from `theme.css`: the three control heights, the
+ * radius scale, the semantic colours, the motion durations. No value is decided
+ * here, so a button cannot drift from the rest of the system.
*
- * Rules applied:
- * - physics-active-state: scale(0.98) on :active
- * - ux-fitts-target-size: min 32px hit target
- * - visual-button-shadow-anatomy: 6-layer shadow on primary
- * - duration-press-hover: 120ms press, 150ms hover
+ * Two conventions: classes merge through `cn`, so a caller's `className`
+ * always wins within its group; and every interactive look is written twice,
+ * once as the real state and once as `data-[preview-state=…]` (CSS-only, for
+ * screenshots). `Button.test.tsx` asserts the two stay in sync.
*/
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from "react";
+import { cn } from "./cn";
-// -- Button --
+export type ButtonVariant = "primary" | "secondary" | "danger" | "ghost";
+export type ButtonSize = "sm" | "md" | "lg";
-type ButtonVariant = "primary" | "secondary" | "danger" | "ghost";
-type ButtonSize = "sm" | "md" | "lg";
+/** Forces one interactive look for a gallery shot. CSS-only; see the header. */
+export type PreviewState = "hover" | "active" | "focus";
-interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
+export interface ButtonBaseProps extends ButtonHTMLAttributes<HTMLButtonElement> {
variant?: ButtonVariant;
size?: ButtonSize;
+ "data-preview-state"?: PreviewState;
+}
+
+interface ButtonProps extends ButtonBaseProps {
loading?: boolean;
icon?: ReactNode;
}
-const variantStyles: Record<ButtonVariant, string> = {
- primary: [
- "bg-white text-neutral-950 font-medium",
- "shadow-btn-primary",
- "enabled:hover:bg-neutral-200",
- "enabled:active:scale-[0.97]",
- ].join(" "),
- secondary: [
- "bg-transparent text-neutral-300 font-medium",
- "border border-border",
- "enabled:hover:bg-surface-hover enabled:hover:text-white enabled:hover:border-border-strong",
- "enabled:active:scale-[0.98]",
- ].join(" "),
- danger: [
- "bg-accent-red text-white font-medium",
- "enabled:hover:bg-red-600",
- "enabled:active:scale-[0.97]",
- ].join(" "),
- ghost: [
- "bg-transparent text-neutral-400",
- "enabled:hover:bg-surface-hover enabled:hover:text-white",
- "enabled:active:scale-[0.98]",
- ].join(" "),
+/**
+ * Shared by Button and IconButton. `disabled:` keeps pointer events alive so a
+ * wrapping Tooltip can still explain why the control is disabled.
+ */
+export const buttonBase = cn(
+ "inline-flex items-center justify-center select-none cursor-pointer whitespace-nowrap",
+ "transition-[background-color,border-color,color,filter,transform] ease-out-quint duration-press",
+ "disabled:opacity-40 disabled:cursor-not-allowed",
+ "outline-hidden",
+ "focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent",
+ "data-[preview-state=focus]:outline-solid data-[preview-state=focus]:outline-2 data-[preview-state=focus]:outline-offset-1 data-[preview-state=focus]:outline-accent",
+);
+
+/**
+ * One entry per variant. The `data-[preview-state=…]` half of each string
+ * repeats the `hover:` and `active:` half exactly; the test pairs them.
+ */
+export const buttonVariants: Record<ButtonVariant, string> = {
+ primary: cn(
+ "bg-accent text-bg-0 font-semibold",
+ "enabled:hover:brightness-110 data-[preview-state=hover]:brightness-110",
+ "enabled:active:scale-[0.98] data-[preview-state=active]:scale-[0.98]",
+ ),
+ secondary: cn(
+ "bg-transparent text-text-1 font-medium border border-border-strong",
+ "enabled:hover:bg-hover enabled:hover:text-text-0 data-[preview-state=hover]:bg-hover data-[preview-state=hover]:text-text-0",
+ "enabled:active:scale-[0.98] data-[preview-state=active]:scale-[0.98]",
+ ),
+ danger: cn(
+ "bg-danger text-text-0 font-medium",
+ "enabled:hover:brightness-110 data-[preview-state=hover]:brightness-110",
+ "enabled:active:scale-[0.98] data-[preview-state=active]:scale-[0.98]",
+ ),
+ ghost: cn(
+ "bg-transparent text-text-2 font-medium",
+ "enabled:hover:bg-hover enabled:hover:text-text-0 data-[preview-state=hover]:bg-hover data-[preview-state=hover]:text-text-0",
+ "enabled:active:scale-[0.98] data-[preview-state=active]:scale-[0.98]",
+ ),
};
+/** The three control heights, 24 / 28 / 32 px, from `--spacing-ctl-*`. */
const sizeStyles: Record<ButtonSize, string> = {
- sm: "h-7 px-2.5 text-xs gap-1.5 rounded-button",
- md: "h-8 px-3 text-sm gap-1.5 rounded-button",
- lg: "h-9 px-4 text-base gap-2 rounded-button",
+ sm: "h-ctl-sm px-2 gap-1 rounded-sm text-step-11",
+ md: "h-ctl px-3 gap-1.5 rounded-md text-step-12",
+ lg: "h-ctl-lg px-4 gap-2 rounded-md text-step-13",
};
-// Imported by the shell/renders PRs later in this stack.
-// fallow-ignore-next-line unused-export
+function Spinner() {
+ return (
+ <svg className="animate-spin size-3.5" viewBox="0 0 24 24" fill="none" aria-hidden="true">
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
+ <path
+ className="opacity-75"
+ fill="currentColor"
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
+ />
+ </svg>
+ );
+}
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
- {
- variant = "secondary",
- size = "md",
- loading,
- icon,
- children,
- className = "",
- disabled,
- ...props
- },
+ { variant = "secondary", size = "md", loading, icon, children, className, disabled, ...props },
ref,
) => {
+ const isDisabled = disabled || loading;
+ let leading: ReactNode = null;
+ if (loading) leading = <Spinner />;
+ else if (icon) leading = <span className="shrink-0">{icon}</span>;
return (
<button
ref={ref}
- disabled={disabled || loading}
- className={[
- "inline-flex items-center justify-center",
- "transition-all duration-press ease-standard",
- // No pointer-events-none: disabled buttons must still receive hover
- // so a wrapping Tooltip can explain WHY they're disabled (A5).
- "disabled:opacity-40 disabled:cursor-not-allowed",
- "select-none cursor-pointer",
- "outline-hidden focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-studio-accent",
- variantStyles[variant],
- sizeStyles[size],
- className,
- ].join(" ")}
+ disabled={isDisabled}
+ // `aria-disabled` as well as `disabled`: assistive tech announces the
+ // state even where the native attribute is filtered out of the tree.
+ aria-disabled={isDisabled || undefined}
+ className={cn(buttonBase, buttonVariants[variant], sizeStyles[size], className)}
{...props}
>
- {loading ? (
- <svg className="animate-spin h-3.5 w-3.5" viewBox="0 0 24 24" fill="none">
- <circle
- className="opacity-25"
- cx="12"
- cy="12"
- r="10"
- stroke="currentColor"
- strokeWidth="4"
- />
- <path
- className="opacity-75"
- fill="currentColor"
- d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
- />
- </svg>
- ) : icon ? (
- <span className="shrink-0">{icon}</span>
- ) : null}
+ {leading}
{children}
</button>
);
},
);
Button.displayName = "Button";
-
-// -- IconButton --
-// For icon-only buttons. Enforces min 32px hit target.
-
-interface IconButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
- icon: ReactNode;
- size?: ButtonSize;
- variant?: ButtonVariant;
- "aria-label": string; // REQUIRED for accessibility
-}
-
-const iconSizeStyles: Record<ButtonSize, string> = {
- sm: "min-w-7 min-h-7 rounded-button", // 28px
- md: "min-w-8 min-h-8 rounded-button", // 32px — minimum recommended
- lg: "min-w-9 min-h-9 rounded-button", // 36px
-};
-
-// fallow-ignore-next-line unused-export
-export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
- ({ icon, size = "md", variant = "ghost", className = "", ...props }, ref) => {
- return (
- <button
- ref={ref}
- className={[
- "inline-flex items-center justify-center",
- "transition-all duration-press ease-standard",
- "disabled:opacity-40 disabled:cursor-not-allowed",
- "select-none cursor-pointer",
- "outline-hidden focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-studio-accent",
- variantStyles[variant],
- iconSizeStyles[size],
- className,
- ].join(" ")}
- {...props}
- >
- {icon}
- </button>
- );
- },
-);
-IconButton.displayName = "IconButton";
diff --git a/packages/studio/src/components/ui/IconButton.tsx b/packages/studio/src/components/ui/IconButton.tsx
new file mode 100644
index 0000000000..1808ae92e1
--- /dev/null
+++ b/packages/studio/src/components/ui/IconButton.tsx
@@ -0,0 +1,38 @@
+/**
+ * IconButton — Button's square sibling; shares its base/variant classes so
+ * the two never drift. `aria-label` is required for screen readers.
+ */
+
+import { forwardRef } from "react";
+import type { ReactNode } from "react";
+import { buttonBase, buttonVariants, type ButtonBaseProps, type ButtonSize } from "./Button";
+import { cn } from "./cn";
+
+interface IconButtonProps extends ButtonBaseProps {
+ icon: ReactNode;
+ "aria-label": string;
+}
+
+/** Square boxes on the same 24 / 28 / 32 px control heights as Button. */
+const iconSizeStyles: Record<ButtonSize, string> = {
+ sm: "size-ctl-sm rounded-sm",
+ md: "size-ctl rounded-md",
+ lg: "size-ctl-lg rounded-md",
+};
+
+export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
+ ({ icon, size = "md", variant = "ghost", className, disabled, ...props }, ref) => {
+ return (
+ <button
+ ref={ref}
+ disabled={disabled}
+ aria-disabled={disabled || undefined}
+ className={cn(buttonBase, buttonVariants[variant], iconSizeStyles[size], className)}
+ {...props}
+ >
+ {icon}
+ </button>
+ );
+ },
+);
+IconButton.displayName = "IconButton";
diff --git a/packages/studio/src/components/ui/Tabs.test.tsx b/packages/studio/src/components/ui/Tabs.test.tsx
new file mode 100644
index 0000000000..53a35cf4bb
--- /dev/null
+++ b/packages/studio/src/components/ui/Tabs.test.tsx
@@ -0,0 +1,98 @@
+// @vitest-environment happy-dom
+
+/**
+ * Tabs: proves the shared strip reaches every tab by arrow key, something
+ * three of Studio's six hand-rolled strips don't.
+ */
+import React, { act } from "react";
+import { afterEach, expect, it } from "vitest";
+import { cleanupMounted, mountHost } from "./mountHost.testHelpers";
+import { Tab, TabPanel, Tabs, TabsList } from "./Tabs";
+
+const TABS = ["code", "comps", "assets", "catalog"];
+
+afterEach(cleanupMounted);
+
+function mount(): HTMLElement {
+ return mountHost(
+ <Tabs defaultValue="code">
+ <TabsList aria-label="Sidebar panels">
+ {TABS.map((id) => (
+ <Tab key={id} value={id}>
+ {id}
+ </Tab>
+ ))}
+ </TabsList>
+ {TABS.map((id) => (
+ <TabPanel key={id} value={id}>
+ {id} panel
+ </TabPanel>
+ ))}
+ </Tabs>,
+ );
+}
+
+function tab(host: HTMLElement, id: string): HTMLElement {
+ const el = host.querySelector<HTMLElement>(`[data-tab-id="${id}"]`);
+ if (!el) throw new Error(`no tab for ${id}`);
+ return el;
+}
+
+function selected(host: HTMLElement): string | null {
+ return (
+ host.querySelector('[role="tab"][aria-selected="true"]')?.getAttribute("data-tab-id") ?? null
+ );
+}
+
+/** Base UI moves the roving tabindex synchronously and the focus one task later. */
+async function arrow(key: string): Promise<void> {
+ const target = document.activeElement ?? document.body;
+ act(() => {
+ target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true, composed: true }));
+ });
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ });
+}
+
+it("moves selection and focus with the arrow keys", async () => {
+ const host = mount();
+ act(() => tab(host, "code").focus());
+
+ await arrow("ArrowRight");
+
+ expect(selected(host)).toBe("comps");
+ expect(document.activeElement).toBe(tab(host, "comps"));
+});
+
+it("jumps to the first and last tab with Home and End", async () => {
+ const host = mount();
+ act(() => tab(host, "code").focus());
+
+ await arrow("End");
+ expect(selected(host)).toBe("catalog");
+ expect(document.activeElement).toBe(tab(host, "catalog"));
+
+ await arrow("Home");
+ expect(selected(host)).toBe("code");
+ expect(document.activeElement).toBe(tab(host, "code"));
+});
+
+it("labels the visible panel with its tab", () => {
+ const host = mount();
+ const panel = host.querySelector('[role="tabpanel"]:not([hidden])');
+
+ expect(panel?.textContent).toBe("code panel");
+ expect(panel?.getAttribute("aria-labelledby")).toBe(tab(host, "code").id);
+});
+
+it("carries data-tab-id, which the sidebar's focus restore looks up", () => {
+ // LeftSidebar finds a tab with `[data-tab-id="…"]` to restore focus after a
+ // programmatic switch. An attribute the primitive owns survives a reskin;
+ // the class it used to match on does not.
+ const host = mount();
+
+ expect(
+ [...host.querySelectorAll("[data-tab-id]")].map((el) => el.getAttribute("data-tab-id")),
+ ).toEqual(TABS);
+});
diff --git a/packages/studio/src/components/ui/Tabs.tsx b/packages/studio/src/components/ui/Tabs.tsx
new file mode 100644
index 0000000000..5a7cc1105c
--- /dev/null
+++ b/packages/studio/src/components/ui/Tabs.tsx
@@ -0,0 +1,71 @@
+/**
+ * Tabs — Base UI's tabs wearing Studio's tokens; replaces six hand-rolled
+ * strips with one implementation (roving tabindex, arrow/Home/End, `aria-controls`).
+ */
+
+import { Tabs as BaseTabs } from "@base-ui/react/tabs";
+import type { ComponentPropsWithoutRef, ElementType } from "react";
+import { cn } from "./cn";
+import type { PreviewState } from "./Button";
+
+/**
+ * Base UI lets `className` be a function of the part's state. Studio's parts
+ * merge a string with `cn`, so the string form is the one they accept.
+ */
+type StyledProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, "className"> & {
+ className?: string;
+};
+
+/**
+ * Groups a tab list with its panels. Uncontrolled by default; pass `value` and
+ * `onValueChange` for a strip whose selection lives in a store.
+ */
+export function Tabs(props: ComponentPropsWithoutRef<typeof BaseTabs.Root>) {
+ return <BaseTabs.Root {...props} />;
+}
+
+/** The strip. Give it an `aria-label`: a tablist with no name is unlabelled. */
+export function TabsList({ className, ...props }: StyledProps<typeof BaseTabs.List>) {
+ return (
+ <BaseTabs.List
+ // Arrow keys move selection, matching today's sidebar strip.
+ activateOnFocus
+ className={cn("inline-flex items-center gap-0.5 rounded-lg bg-surface-alt p-1", className)}
+ {...props}
+ />
+ );
+}
+
+interface TabProps extends StyledProps<typeof BaseTabs.Tab> {
+ value: string;
+ "data-preview-state"?: PreviewState;
+}
+
+/**
+ * aria-selected drives the selected look (Base UI sets it) so assistive tech
+ * and sighted users match. data-preview-state is for gallery shots only.
+ */
+export function Tab({ value, className, ...props }: TabProps) {
+ return (
+ <BaseTabs.Tab
+ value={value}
+ data-tab-id={value}
+ className={cn(
+ "inline-flex h-ctl-sm cursor-pointer select-none items-center justify-center rounded-sm px-2.5",
+ "text-step-11 font-semibold whitespace-nowrap text-text-3",
+ "transition-[background-color,color] ease-out-quint duration-hover",
+ "hover:text-text-1 data-[preview-state=hover]:text-text-1",
+ "aria-selected:bg-hover aria-selected:text-text-0",
+ "outline-hidden focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent",
+ "data-[preview-state=focus]:outline-solid data-[preview-state=focus]:outline-2 data-[preview-state=focus]:outline-offset-1 data-[preview-state=focus]:outline-accent",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+/** The panel for one tab. Base UI wires `aria-labelledby` back to its tab. */
+export function TabPanel({ className, ...props }: StyledProps<typeof BaseTabs.Panel>) {
+ return <BaseTabs.Panel className={cn("outline-hidden", className)} {...props} />;
+}
diff --git a/packages/studio/src/components/ui/Tooltip.test.tsx b/packages/studio/src/components/ui/Tooltip.test.tsx
new file mode 100644
index 0000000000..fa8cc5ad7c
--- /dev/null
+++ b/packages/studio/src/components/ui/Tooltip.test.tsx
@@ -0,0 +1,110 @@
+// @vitest-environment happy-dom
+
+/**
+ * Tooltip a11y contract Base UI must not lose: focus opens it, Escape
+ * dismisses it (WCAG 1.4.13), aria-describedby ties trigger to bubble (4.1.2).
+ */
+import React, { act } from "react";
+import { afterEach, expect, it } from "vitest";
+import { cleanupMounted, mountHost } from "./mountHost.testHelpers";
+import { Tooltip } from "./Tooltip";
+
+afterEach(cleanupMounted);
+
+function mount(): HTMLElement {
+ const host = mountHost(
+ <Tooltip label="Selection tool (V)" delay={0}>
+ <button type="button" data-testid="trigger">
+ V
+ </button>
+ </Tooltip>,
+ );
+ const trigger = host.querySelector<HTMLElement>('[data-testid="trigger"]');
+ if (!trigger) throw new Error("trigger not rendered");
+ return trigger;
+}
+
+/** Base UI opens and closes across a task, not synchronously. */
+async function settle(): Promise<void> {
+ await act(async () => {
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ });
+}
+
+/** Browsers send hover to the wrapper, never to a disabled control inside it. */
+function hover(trigger: HTMLElement): void {
+ const box = trigger.parentElement ?? trigger;
+ act(() => {
+ box.dispatchEvent(new PointerEvent("pointerenter", { bubbles: false, composed: true }));
+ box.dispatchEvent(new MouseEvent("mouseenter", { bubbles: false, composed: true }));
+ box.dispatchEvent(new MouseEvent("mousemove", { bubbles: true, composed: true }));
+ });
+}
+
+function bubble(): HTMLElement | null {
+ return document.querySelector<HTMLElement>('[role="tooltip"]');
+}
+
+it("opens on focus and describes its trigger", async () => {
+ const trigger = mount();
+
+ expect(bubble()).toBeNull();
+ act(() => trigger.focus());
+ await settle();
+
+ const tip = bubble();
+ expect(tip?.textContent).toBe("Selection tool (V)");
+ expect(trigger.getAttribute("aria-describedby")).toBe(tip?.id);
+});
+
+it("opens on pointer hover", async () => {
+ const trigger = mount();
+
+ hover(trigger);
+ await settle();
+
+ expect(bubble()?.textContent).toBe("Selection tool (V)");
+});
+
+it("closes on Escape and drops the description", async () => {
+ const trigger = mount();
+ act(() => trigger.focus());
+ await settle();
+ expect(bubble()).not.toBeNull();
+
+ act(() => {
+ document.dispatchEvent(
+ new KeyboardEvent("keydown", { key: "Escape", bubbles: true, composed: true }),
+ );
+ });
+ await settle();
+
+ expect(bubble()).toBeNull();
+ expect(trigger.getAttribute("aria-describedby")).toBeNull();
+});
+
+it("opens on hover over a disabled child", async () => {
+ const host = mountHost(
+ <Tooltip label="Rendering" delay={0}>
+ <button type="button" disabled data-testid="off">
+ Export
+ </button>
+ </Tooltip>,
+ );
+ const off = host.querySelector<HTMLElement>('[data-testid="off"]');
+ if (!off) throw new Error("trigger not rendered");
+
+ hover(off);
+ await settle();
+
+ expect(bubble()?.textContent).toBe("Rendering");
+});
+
+it("wraps its child in a box-less span so a disabled child still gets hover", () => {
+ const trigger = mount();
+
+ expect(trigger.tagName).toBe("BUTTON");
+ expect(trigger.parentElement?.tagName).toBe("SPAN");
+ expect(trigger.parentElement?.className).toBe("contents");
+ expect(trigger.parentElement?.parentElement?.parentElement).toBe(document.body);
+});
diff --git a/packages/studio/src/components/ui/Tooltip.tsx b/packages/studio/src/components/ui/Tooltip.tsx
index 3bc9a2fe0f..0bc6644c7a 100644
--- a/packages/studio/src/components/ui/Tooltip.tsx
+++ b/packages/studio/src/components/ui/Tooltip.tsx
@@ -1,127 +1,53 @@
-import {
- useState,
- useRef,
- useCallback,
- useEffect,
- useLayoutEffect,
- useId,
- type ReactNode,
-} from "react";
-import { createPortal } from "react-dom";
-import { clampCentredLeft } from "../editor/floatingPanel";
+/**
+ * Tooltip: Base UI's tooltip in Studio tokens. The trigger is a box-less
+ * `display: contents` wrapper so a disabled control still gets hover.
+ */
+
+import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
+import { cloneElement, useId, useRef, useState, type ReactElement } from "react";
interface TooltipProps {
label: string;
- children: ReactNode;
+ /** A single element, wrapped in a box-less span so a disabled one still gets hover. */
+ children: ReactElement<{ "aria-describedby"?: string }>;
+ /** Hover delay in ms. */
delay?: number;
- side?: "top" | "bottom";
+ side?: "top" | "bottom" | "left" | "right";
}
-// Rough bubble height (padding + one text line) used to decide flipping
-// before the bubble has rendered; exact height isn't needed for the guard.
-const APPROX_BUBBLE_H = 28;
+/** Matches the old bubble's gap from its trigger, and its viewport margin. */
+const SIDE_OFFSET = 6;
const VIEWPORT_MARGIN = 8;
export function Tooltip({ label, children, delay = 400, side = "top" }: TooltipProps) {
- const [visible, setVisible] = useState(false);
- const [pos, setPos] = useState({ x: 0, y: 0 });
- const [resolvedSide, setResolvedSide] = useState<"top" | "bottom">(side);
- const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
- const triggerRef = useRef<HTMLSpanElement>(null);
- const bubbleRef = useRef<HTMLDivElement>(null);
- const [bubbleWidth, setBubbleWidth] = useState(0);
- // WCAG 4.1.2: programmatically associate the bubble with its trigger.
+ const [open, setOpen] = useState(false);
+ const boxRef = useRef<HTMLSpanElement>(null);
const tooltipId = useId();
- const show = useCallback(() => {
- if (timerRef.current) clearTimeout(timerRef.current);
- timerRef.current = setTimeout(() => {
- const el = triggerRef.current;
- if (!el) return;
- const child = el.firstElementChild as HTMLElement | null;
- const rect = (child ?? el).getBoundingClientRect();
- if (rect.width === 0 && rect.height === 0) return;
- // Flip when the preferred side would clip the viewport edge.
- let nextSide = side;
- if (side === "top" && rect.top - APPROX_BUBBLE_H - 6 < VIEWPORT_MARGIN) {
- nextSide = "bottom";
- } else if (
- side === "bottom" &&
- rect.bottom + APPROX_BUBBLE_H + 6 > window.innerHeight - VIEWPORT_MARGIN
- ) {
- nextSide = "top";
- }
- setResolvedSide(nextSide);
- setPos({
- // Raw trigger centre; clamped to the viewport at render, once the
- // bubble's own width is known (see clampedX).
- x: rect.left + rect.width / 2,
- y: nextSide === "top" ? rect.top - 6 : rect.bottom + 6,
- });
- setVisible(true);
- }, delay);
- }, [delay, side]);
-
- const hide = useCallback(() => {
- if (timerRef.current) {
- clearTimeout(timerRef.current);
- timerRef.current = null;
- }
- setVisible(false);
- }, []);
-
- // Measure before paint so a wide bubble near a viewport edge is clamped in
- // the same commit it appears in (no visible jump).
- useLayoutEffect(() => {
- setBubbleWidth(visible ? (bubbleRef.current?.offsetWidth ?? 0) : 0);
- }, [visible, label]);
-
- // WCAG 1.4.13: tooltip content must be dismissible with Escape.
- useEffect(() => {
- if (!visible) return;
- const onKeyDown = (e: KeyboardEvent) => {
- if (e.key === "Escape") hide();
- };
- document.addEventListener("keydown", onKeyDown);
- return () => document.removeEventListener("keydown", onKeyDown);
- }, [visible, hide]);
-
- const clampedX = clampCentredLeft(pos.x, bubbleWidth, window.innerWidth, VIEWPORT_MARGIN);
-
return (
- <>
- <span
- ref={triggerRef}
- onPointerEnter={show}
- onPointerLeave={hide}
- onFocus={show}
- onBlur={hide}
- aria-describedby={visible ? tooltipId : undefined}
- className="contents"
- >
- {children}
- </span>
- {visible &&
- createPortal(
- <div
- className="fixed z-200 pointer-events-none"
- style={{
- left: clampedX,
- top: pos.y,
- transform: resolvedSide === "top" ? "translate(-50%, -100%)" : "translate(-50%, 0)",
- }}
+ <BaseTooltip.Root open={open} onOpenChange={setOpen}>
+ <BaseTooltip.Trigger delay={delay} render={<span ref={boxRef} className="contents" />}>
+ {cloneElement(children, {
+ "aria-describedby": open ? tooltipId : children.props["aria-describedby"],
+ })}
+ </BaseTooltip.Trigger>
+ <BaseTooltip.Portal>
+ <BaseTooltip.Positioner
+ anchor={() => boxRef.current?.firstElementChild ?? null}
+ side={side}
+ sideOffset={SIDE_OFFSET}
+ collisionPadding={VIEWPORT_MARGIN}
+ className="z-200"
+ >
+ <BaseTooltip.Popup
+ id={tooltipId}
+ role="tooltip"
+ className="pointer-events-none rounded-md border border-border-input bg-surface px-2 py-1 text-step-10 font-medium text-text-1 whitespace-nowrap shadow-menu"
>
- <div
- ref={bubbleRef}
- role="tooltip"
- id={tooltipId}
- className="px-2 py-1 rounded-md bg-neutral-800 border border-neutral-700/50 text-[10px] font-medium text-neutral-200 whitespace-nowrap shadow-lg"
- >
- {label}
- </div>
- </div>,
- document.body,
- )}
- </>
+ {label}
+ </BaseTooltip.Popup>
+ </BaseTooltip.Positioner>
+ </BaseTooltip.Portal>
+ </BaseTooltip.Root>
);
}
diff --git a/packages/studio/src/components/ui/cn.test.ts b/packages/studio/src/components/ui/cn.test.ts
new file mode 100644
index 0000000000..b3b2e2bd57
--- /dev/null
+++ b/packages/studio/src/components/ui/cn.test.ts
@@ -0,0 +1,30 @@
+/**
+ * The two things `cn` must do that a bare `clsx` cannot: drop a losing class
+ * from the same group, and know the two class families `theme.css` invents.
+ */
+import { describe, expect, it } from "vitest";
+import { cn } from "./cn";
+
+describe("cn", () => {
+ it("keeps only the last class from a group", () => {
+ expect(cn("text-sm", "text-step-11")).toBe("text-step-11");
+ expect(cn("text-step-11", "text-sm")).toBe("text-sm");
+ });
+
+ it("takes clsx-style conditionals", () => {
+ const cond = true;
+ expect(cn("px-3", cond && "px-4")).toBe("px-4");
+ expect(cn("px-3", !cond && "px-4")).toBe("px-3");
+ });
+
+ it("merges the control heights against each other", () => {
+ expect(cn("h-ctl", "h-ctl-lg")).toBe("h-ctl-lg");
+ expect(cn("h-ctl-lg", "h-8")).toBe("h-8");
+ expect(cn("size-ctl", "size-ctl-sm")).toBe("size-ctl-sm");
+ });
+
+ it("keeps a type step and a text colour apart", () => {
+ // Both are `text-*`; only one is a font size.
+ expect(cn("text-step-11", "text-text-2")).toBe("text-step-11 text-text-2");
+ });
+});
diff --git a/packages/studio/src/components/ui/cn.ts b/packages/studio/src/components/ui/cn.ts
new file mode 100644
index 0000000000..7cb71e3f1e
--- /dev/null
+++ b/packages/studio/src/components/ui/cn.ts
@@ -0,0 +1,25 @@
+/**
+ * Studio's tailwind-merge config: teaches it the two scales `theme.css`
+ * invents (`text-step-*`, `ctl`/`ctl-sm`/`ctl-lg`) so overrides replace, not stack.
+ */
+
+import { createCn } from "cn/config";
+
+/** `text-step-11`, `text-step-9`, … — the type scale from `theme.css`. */
+const isTypeStep = (value: string) => /^step-\d+$/.test(value);
+
+/** `ctl`, `ctl-sm`, `ctl-lg` — the control heights from `theme.css`. */
+const isControlSize = (value: string) => /^ctl(-sm|-lg)?$/.test(value);
+
+export const cn = createCn({
+ extend: {
+ classGroups: {
+ "font-size": [{ text: [isTypeStep] }],
+ h: [{ h: [isControlSize] }],
+ w: [{ w: [isControlSize] }],
+ size: [{ size: [isControlSize] }],
+ "min-h": [{ "min-h": [isControlSize] }],
+ "min-w": [{ "min-w": [isControlSize] }],
+ },
+ },
+});
diff --git a/packages/studio/src/components/ui/index.ts b/packages/studio/src/components/ui/index.ts
index 0a6987e69e..1055707d7e 100644
--- a/packages/studio/src/components/ui/index.ts
+++ b/packages/studio/src/components/ui/index.ts
@@ -1,5 +1,10 @@
-// Minimal UI primitives for studio canvas components
-export { Button, IconButton } from "./Button";
+// Studio's shared UI primitives. Every control in the app is meant to come
+// from here, so a look or a keyboard behaviour is decided once.
+export { cn } from "./cn";
+export { Button, buttonBase, buttonVariants } from "./Button";
+export type { ButtonSize, ButtonVariant, PreviewState } from "./Button";
+export { IconButton } from "./IconButton";
+export { Tab, TabPanel, Tabs, TabsList } from "./Tabs";
export { HyperframesLoader, StatusFrame } from "./HyperframesLoader";
export type { HyperframesLoaderProps } from "./HyperframesLoader";
export { Tooltip } from "./Tooltip";
diff --git a/packages/studio/src/components/ui/mountHost.testHelpers.ts b/packages/studio/src/components/ui/mountHost.testHelpers.ts
new file mode 100644
index 0000000000..2c10d4adc3
--- /dev/null
+++ b/packages/studio/src/components/ui/mountHost.testHelpers.ts
@@ -0,0 +1,24 @@
+import { act, type ReactElement } from "react";
+import { createRoot, type Root } from "react-dom/client";
+
+(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
+
+let mounted: { root: Root; host: HTMLElement } | null = null;
+
+/** Renders into a fresh host attached to the body; `cleanupMounted` tears it down. */
+export function mountHost(element: ReactElement): HTMLElement {
+ const host = document.createElement("div");
+ document.body.append(host);
+ const root = createRoot(host);
+ mounted = { root, host };
+ act(() => root.render(element));
+ return host;
+}
+
+export function cleanupMounted(): void {
+ if (!mounted) return;
+ const { root, host } = mounted;
+ mounted = null;
+ act(() => root.unmount());
+ host.remove();
+}
diff --git a/packages/studio/src/index.ts b/packages/studio/src/index.ts
index 9b904c3f1e..ac46b86920 100644
--- a/packages/studio/src/index.ts
+++ b/packages/studio/src/index.ts
@@ -1,3 +1,10 @@
+// UI primitives
+export { Button, buttonBase, buttonVariants } from "./components/ui/Button";
+export type { ButtonSize, ButtonVariant, PreviewState } from "./components/ui/Button";
+export { IconButton } from "./components/ui/IconButton";
+export { Tab, TabPanel, Tabs, TabsList } from "./components/ui/Tabs";
+export { Tooltip } from "./components/ui/Tooltip";
+
// NLE Layout
export { EditorShell } from "./components/EditorShell";
export { NLEPreview } from "./components/nle/NLEPreview";