Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: introduce stylex (#20743)

ecmadao1549b09dc9ba
diff --git a/frontend/env.d.ts b/frontend/env.d.ts
index 11f02fe2a0..1ddac2f7ac 100644
--- a/frontend/env.d.ts
+++ b/frontend/env.d.ts
@@ -1 +1,3 @@
/// <reference types="vite/client" />
+
+declare module "virtual:stylex:css-only";
diff --git a/frontend/package.json b/frontend/package.json
index bbac954555..377ed506c3 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -40,6 +40,7 @@
"@dnd-kit/sortable": "^10.0.0",
"@dnd-kit/utilities": "^3.2.2",
"@markdoc/markdoc": "0.5.7",
+ "@stylexjs/stylex": "^0.19.0",
"@tanstack/react-virtual": "^3.13.24",
"bootstrap": "5.3.8",
"class-variance-authority": "^0.7.1",
@@ -101,6 +102,7 @@
"@biomejs/biome": "2.4.14",
"@playwright/test": "^1.59.1",
"@rollup/plugin-yaml": "4.1.2",
+ "@stylexjs/unplugin": "^0.19.0",
"@tailwindcss/forms": "0.5.11",
"@tailwindcss/typography": "0.5.19",
"@tailwindcss/vite": "^4.3.0",
diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml
index c3132f76b5..3e2c5d8da5 100644
--- a/frontend/pnpm-lock.yaml
+++ b/frontend/pnpm-lock.yaml
@@ -58,6 +58,9 @@ importers:
'@markdoc/markdoc':
specifier: 0.5.7
version: 0.5.7(@types/[email protected])([email protected])
+ '@stylexjs/stylex':
+ specifier: ^0.19.0
+ version: 0.19.0
'@tanstack/react-virtual':
specifier: ^3.13.24
@@ -236,6 +239,9 @@ importers:
'@rollup/plugin-yaml':
specifier: 4.1.2
version: 4.1.2([email protected])
+ '@stylexjs/unplugin':
+ specifier: ^0.19.0
+ version: 0.19.0([email protected])
'@tailwindcss/forms':
specifier: 0.5.11
version: 0.5.11([email protected])
@@ -462,6 +468,10 @@ packages:
resolution: {integrity: sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==}
engines: {node: '>=6.9.0'}
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==}
+ engines: {node: '>=6.9.0'}
+
resolution: {integrity: sha512-7fiA521aVw8lSPeI4ZOD3vRFkoqkJcS+z4hFo82bFSH/2tNd6eJ5qCVMS5OzDmZh/kaHQeBaeyxK6wljcPtveA==}
engines: {node: '>=6.9.0'}
@@ -539,6 +549,12 @@ packages:
peerDependencies:
'@babel/core': ^7.0.0-0
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-ajMX6QPcyomotqwpzhkYGxcK2i/us0rs1Qo9QvUpa+Fca0FTmqrzKrctoIYLMxcOhGZldGT/BAVkRGTWBiR8gQ==}
+ engines: {node: '>=6.9.0'}
+ peerDependencies:
+ '@babel/core': ^7.0.0-0
+
resolution: {integrity: sha512-UT/Jrhw57xg4ILHLFnzFpPDlMbcdEicaAtjPQpbj9wa8T4r5KVWCimHcL/460g8Ht0DMxDyjsLgiWSkVjnwPFg==}
engines: {node: '>=6.9.0'}
@@ -551,6 +567,18 @@ packages:
peerDependencies:
'@babel/core': ^7.0.0-0
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==}
+ engines: {node: '>=6.9.0'}
+ peerDependencies:
+ '@babel/core': ^7.0.0-0
+
+ '@babel/[email protected]':
+ resolution: {integrity: sha512-ngr+82Sh0xMz25TPCZi+nC2iTzjfCdWS2ONXTp/PtSCHCgaCNBpdMqgvJ2ccdLlClVZ7sisIgB914j/JFe+RZA==}
+ engines: {node: '>=6.9.0'}
+ peerDependencies:
+ '@babel/core': ^7.0.0-0
+
resolution: {integrity: sha512-727YkEAPwSIQTv5im8QHz3upqp92JTWhidIC81Tdx4VJYIte/VndKf1qKrfnnhPLiPghStWfvC/iFaMCQu7Nqg==}
engines: {node: '>=6.9.0'}
@@ -975,7 +1003,7 @@ packages:
os: [win32]
'@buf/googleapis_googleapis.bufbuild_es@2.10.2-20260414192239-c17df5b2beca.1':
- resolution: {tarball: https://buf.build/gen/npm/v1/@buf/googleapis_googleapis.bufbuild_es/-/googleapis_googleapis.bufbuild_es-2.10.2-20260414192239-c17df5b2beca.1.tgz}
+ resolution: {tarball: https://buf.build/gen/npm/v1/@buf/googleapis_googleapis.bufbuild_es/-/googleapis_googleapis.bufbuild_es-2.10.2-20260414192239-c17df5b2beca.1.tgz, integrity: sha512-+cPFrXmQ8X80yjoP/SvW5CcvX34TS04grzX1bqsXHrz61kZIPy4mtT4REo2uJ/Kk7UJ4n/gdv/x9uwyvRjQIow==}
peerDependencies:
'@bufbuild/protobuf': ^2.10.2
@@ -1246,6 +1274,9 @@ packages:
peerDependencies:
react: '>=16.8.0'
+ '@dual-bundle/[email protected]':
+ resolution: {integrity: sha512-id+7YRUgoUX6CgV0DtuhirQWodeeA7Lf4i2x71JS/vtA5pRb/hIGWlw+G6MeXvsM+MXrz0VAydTGElX1rAfgPg==}
+
'@emnapi/[email protected]':
resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==}
@@ -1770,6 +1801,20 @@ packages:
'@standard-schema/[email protected]':
resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==}
+ '@stylexjs/[email protected]':
+ resolution: {integrity: sha512-2SnVZIl047TtqKW0nRTn7Irz0kmoot1bxdGDE/HwfwfF7dJYHqwkIFg92s87v3hj7zxJobrHWwDx1p3qvQXW4g==}
+
+ '@stylexjs/[email protected]':
+ resolution: {integrity: sha512-7Yym70cQH5sPzJHgzJX3FkL9ZCptbC3IbiRijN9YLYU/5OywB/3c519Xv1DOzvxqjv8urSxh98/9HxLaPG7sDg==}
+
+ '@stylexjs/[email protected]':
+ resolution: {integrity: sha512-CnUFp7YMaDLDeemsWOfJgoC/gKM5P/yBNMcpJaE6ChJmXr7s0DJwSeGTTlHJcqqwN9OW1qGtmARWLFhGZN1pTA==}
+
+ '@stylexjs/[email protected]':
+ resolution: {integrity: sha512-2QwNYovSwarC/M8DLD78857F6MEi4eQ3UYzgdmyg/K7562M/rV1KWptiATxcKgujlUT6ToNy778SOXf4bGK+Bw==}
+ peerDependencies:
+ unplugin: ^2.3.11
+
'@tailwindcss/[email protected]':
resolution: {integrity: sha512-h9wegbZDPurxG22xZSoWtdzc41/OlNEUQERNqI/0fOwa2aVlWGu7C35E/x6LDyD3lgtztFSSjKZyuVM0hxhbgA==}
peerDependencies:
@@ -2399,6 +2444,9 @@ packages:
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
+ resolution: {integrity: sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==}
+
resolution: {integrity: sha512-0eW44TGN5SQXU1mWSkKwFstI/22X2bG1nYzZTYMAWjylYURhse752YgbE4Cx46AC+bAvI+/dYTPRk1LqSUnu6w==}
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0}
@@ -2909,6 +2957,9 @@ packages:
resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==}
engines: {node: '>=12'}
+ resolution: {integrity: sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==}
+
resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==}
@@ -3158,6 +3209,10 @@ packages:
resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==}
+ resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
+ hasBin: true
+
resolution: {integrity: sha512-ToxOC+SsduRmdSuoLZLYAr5zy1Qu7l5XhmPWM3zefCZ5IcrzW/h108qbJUKfOlDlhvhjUK84+8PSVX0kxnit0g==}
@@ -3915,6 +3970,9 @@ packages:
resolution: {integrity: sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw==}
+ resolution: {integrity: sha512-L0TR0NQb+X4/ktDEKmjWyp27gla+LUYi/by5k5SjKXf6/pvZP7wbwEB5J+tqxdFVPgzbsuz+d4RTScO/QZquBw==}
+
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
@@ -4070,6 +4128,10 @@ packages:
resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==}
engines: {node: '>= 4.0.0'}
+ resolution: {integrity: sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==}
+ engines: {node: '>=18.12.0'}
+
resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==}
hasBin: true
@@ -4256,6 +4318,9 @@ packages:
resolution: {integrity: sha512-n4W4YFyz5JzOfQeA8oN7dUYpR+MBP3PIUsn2jLjWXwK5ASUzt0Jc/A5sAUZoCYFJRGF0FBKJ+1JjN43rNdsQzA==}
engines: {node: '>=20'}
+ resolution: {integrity: sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==}
+
resolution: {integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==}
engines: {node: '>=18'}
@@ -4476,6 +4541,8 @@ snapshots:
'@babel/[email protected]': {}
+ '@babel/[email protected]': {}
+
dependencies:
'@babel/core': 7.29.0
@@ -4563,6 +4630,11 @@ snapshots:
dependencies:
'@babel/core': 7.29.0
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/helper-plugin-utils': 7.29.7
+
dependencies:
'@babel/core': 7.29.0
@@ -4573,6 +4645,16 @@ snapshots:
'@babel/core': 7.29.0
'@babel/helper-plugin-utils': 7.28.6
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/helper-plugin-utils': 7.29.7
+
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/helper-plugin-utils': 7.29.7
+
dependencies:
'@babel/core': 7.29.0
@@ -5466,6 +5548,8 @@ snapshots:
react: 19.2.6
tslib: 2.8.1
+ '@dual-bundle/[email protected]': {}
+
'@emnapi/[email protected]':
dependencies:
'@emnapi/wasi-threads': 1.2.1
@@ -5795,6 +5879,40 @@ snapshots:
'@standard-schema/[email protected]': {}
+ '@stylexjs/[email protected]':
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/helper-module-imports': 7.28.6
+ '@babel/traverse': 7.29.0
+ '@babel/types': 7.29.0
+ '@dual-bundle/import-meta-resolve': 4.2.1
+ '@stylexjs/shared': 0.19.0
+ '@stylexjs/stylex': 0.19.0
+ postcss-value-parser: 4.2.0
+ transitivePeerDependencies:
+ - supports-color
+
+ '@stylexjs/[email protected]': {}
+
+ '@stylexjs/[email protected]':
+ dependencies:
+ css-mediaquery: 0.1.2
+ invariant: 2.2.4
+ styleq: 0.2.1
+
+ dependencies:
+ '@babel/core': 7.29.0
+ '@babel/plugin-syntax-flow': 7.29.7(@babel/[email protected])
+ '@babel/plugin-syntax-jsx': 7.29.7(@babel/[email protected])
+ '@babel/plugin-syntax-typescript': 7.29.7(@babel/[email protected])
+ '@stylexjs/babel-plugin': 0.19.0
+ browserslist: 4.28.2
+ lightningcss: 1.32.0
+ unplugin: 2.3.11
+ transitivePeerDependencies:
+ - supports-color
+
dependencies:
mini-svg-data-uri: 1.4.4
@@ -6484,6 +6602,8 @@ snapshots:
+
dependencies:
mdn-data: 2.12.2
@@ -6998,6 +7118,10 @@ snapshots:
+ dependencies:
+ loose-envify: 1.4.0
+
@@ -7222,6 +7346,10 @@ snapshots:
+ dependencies:
+ js-tokens: 4.0.0
+
@@ -8320,6 +8448,8 @@ snapshots:
dependencies:
inline-style-parser: 0.2.7
+
dependencies:
has-flag: 4.0.0
@@ -8468,6 +8598,13 @@ snapshots:
+ dependencies:
+ '@jridgewell/remapping': 2.3.5
+ acorn: 8.17.0
+ picomatch: 4.0.4
+ webpack-virtual-modules: 0.6.2
+
dependencies:
browserslist: 4.28.2
@@ -8610,6 +8747,8 @@ snapshots:
+
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 700db63101..3f8add21d3 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -3,6 +3,7 @@ import "./init";
import "regenerator-runtime/runtime";
import "./assets/css/github-markdown-style.css";
import "./assets/css/tailwind.css";
+import "./stylex-dev-css";
// Side-effect: configures the shared dayjs singleton (localizedFormat) and
// registers the SQL highlight.js language + theme used across the app.
import "./plugins/dayjs";
diff --git a/frontend/src/react/components/DashboardSidebar.tsx b/frontend/src/react/components/DashboardSidebar.tsx
index f46fe908f8..e06e59a53b 100644
--- a/frontend/src/react/components/DashboardSidebar.tsx
+++ b/frontend/src/react/components/DashboardSidebar.tsx
@@ -291,9 +291,9 @@ function filterSidebarList(items: SidebarItem[]): SidebarItem[] {
// ---------------------------------------------------------------------------
const parentRouteClass =
- "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-xs text-gray-700 outline-item text-sm!";
+ "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-xs text-gray-700 outline-item whitespace-nowrap text-sm!";
const childRouteClass =
- "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-xs";
+ "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-xs whitespace-nowrap";
export function DashboardSidebar() {
const rawItems = useSidebarItems();
diff --git a/frontend/src/react/components/ExprEditor.test.tsx b/frontend/src/react/components/ExprEditor.test.tsx
index 7e8936c6a2..b6085e47a8 100644
--- a/frontend/src/react/components/ExprEditor.test.tsx
+++ b/frontend/src/react/components/ExprEditor.test.tsx
@@ -1,3 +1,4 @@
+import * as stylex from "@stylexjs/stylex";
import { act, type ReactElement, useState } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test, vi } from "vitest";
@@ -10,6 +11,7 @@ import {
CEL_ATTRIBUTE_STATEMENT_SQL_TYPE,
} from "@/utils/cel-attributes";
import { ExprEditor, type OptionConfig } from "./ExprEditor";
+import { controlSizeStyle } from "./ui/styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -24,6 +26,12 @@ class ResizeObserverStub implements ResizeObserver {
globalThis.ResizeObserver = ResizeObserverStub;
+const expectClasses = (className: string | undefined, expected: string) => {
+ for (const expectedClass of expected.split(" ")) {
+ expect(className ?? "").toContain(expectedClass);
+ }
+};
+
const { MockExprType } = vi.hoisted(() => ({
MockExprType: {
RawString: "RawString",
@@ -322,8 +330,13 @@ describe("ExprEditor", () => {
);
expect(input).toBeInstanceOf(HTMLInputElement);
- expect(input?.className).toContain("h-9");
- expect(input?.className).not.toContain("h-7");
+ expectClasses(
+ input?.className,
+ stylex.props(controlSizeStyle("md")).className ?? ""
+ );
+ expect(input?.className).not.toContain(
+ stylex.props(controlSizeStyle("sm")).className ?? ""
+ );
unmount();
});
diff --git a/frontend/src/react/components/ProjectSidebar.test.tsx b/frontend/src/react/components/ProjectSidebar.test.tsx
new file mode 100644
index 0000000000..a50884b4fa
--- /dev/null
+++ b/frontend/src/react/components/ProjectSidebar.test.tsx
@@ -0,0 +1,158 @@
+import type { ReactElement } from "react";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { beforeEach, describe, expect, test, vi } from "vitest";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const mocks = vi.hoisted(() => ({
+ currentRoute: {
+ name: "workspace.project.masking-exemption",
+ fullPath: "/projects/sample/masking-exemption",
+ params: {
+ projectId: "sample",
+ },
+ query: {},
+ },
+ defaultProject: "",
+ getOrFetchProjectByName: vi.fn(),
+ record: vi.fn(),
+ push: vi.fn(),
+ resolve: vi.fn(
+ (target: string | { name?: string; params?: Record<string, string> }) => {
+ const name = typeof target === "string" ? target : target.name;
+ return {
+ href: `/${name ?? ""}`,
+ fullPath: `/${name ?? ""}`,
+ };
+ }
+ ),
+ workspace: {
+ logo: "",
+ },
+}));
+
+const t = vi.hoisted(
+ () => (key: string, options?: { count?: number }) =>
+ ({
+ "common.database": "Database",
+ "common.databases": "Databases",
+ "common.groups": "Groups",
+ "common.issues": "Issues",
+ "common.manage": "Manage",
+ "common.members": options?.count === 2 ? "Members" : "Member",
+ "common.setting": "Setting",
+ "common.webhooks": "Webhooks",
+ "database.sync-schema.title": "Sync Schema",
+ "gitops.self": "GitOps",
+ "plan.plans": "Plans",
+ "project.masking-exemption.self": "Masking Exemptions",
+ "release.releases": "Releases",
+ "settings.members.service-accounts": "Service Accounts",
+ "settings.members.workload-identities": "Workload Identities",
+ "settings.sidebar.audit-log": "Audit Logs",
+ "settings.sidebar.data-access": "Data Access",
+ "sql-editor.access-grants": "Access Grants",
+ })[key] ?? key
+);
+
+vi.mock("react-i18next", () => ({
+ initReactI18next: {
+ type: "3rdParty",
+ init: vi.fn(),
+ },
+ useTranslation: () => ({
+ t,
+ }),
+}));
+
+vi.mock("@/react/hooks/useAppState", () => ({
+ useWorkspace: () => mocks.workspace,
+}));
+
+vi.mock("@/react/hooks/useRecentVisit", () => ({
+ useRecentVisit: () => ({
+ record: mocks.record,
+ }),
+}));
+
+vi.mock("@/react/router", () => ({
+ router: {
+ push: mocks.push,
+ resolve: mocks.resolve,
+ },
+ useCurrentRoute: () => mocks.currentRoute,
+}));
+
+vi.mock("@/react/stores/app", () => {
+ const useAppStore = (
+ selector: (state: {
+ getOrFetchProjectByName: typeof mocks.getOrFetchProjectByName;
+ serverInfo: { defaultProject: string };
+ }) => unknown
+ ) =>
+ selector({
+ getOrFetchProjectByName: mocks.getOrFetchProjectByName,
+ serverInfo: {
+ defaultProject: mocks.defaultProject,
+ },
+ });
+ useAppStore.getState = () => ({
+ getOrFetchProjectByName: mocks.getOrFetchProjectByName,
+ });
+ return { useAppStore };
+});
+
+vi.mock("@/assets/logo-full.svg", () => ({
+ default: "/assets/logo-full.svg",
+}));
+
+let ProjectSidebar: typeof import("./ProjectSidebar").ProjectSidebar;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ return {
+ container,
+ render: () => {
+ act(() => {
+ root.render(element);
+ });
+ },
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+beforeEach(async () => {
+ vi.clearAllMocks();
+ mocks.currentRoute.name = "workspace.project.masking-exemption";
+ mocks.currentRoute.params = {
+ projectId: "sample",
+ };
+ mocks.defaultProject = "";
+ ({ ProjectSidebar } = await import("./ProjectSidebar"));
+});
+
+describe("ProjectSidebar", () => {
+ test("keeps child route labels on one line", () => {
+ const { container, render, unmount } = renderIntoContainer(
+ <ProjectSidebar />
+ );
+ render();
+
+ const maskingExemptionsLink = Array.from(
+ container.querySelectorAll("a")
+ ).find((link) => link.textContent?.includes("Masking Exemptions"));
+
+ expect(maskingExemptionsLink?.className).toContain("whitespace-nowrap");
+
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/ProjectSidebar.tsx b/frontend/src/react/components/ProjectSidebar.tsx
index bf660fb7ca..7d38ff180e 100644
--- a/frontend/src/react/components/ProjectSidebar.tsx
+++ b/frontend/src/react/components/ProjectSidebar.tsx
@@ -224,9 +224,9 @@ function filterSidebarList(items: SidebarItem[]): SidebarItem[] {
// ---------------------------------------------------------------------------
const parentRouteClass =
- "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-xs text-gray-700 outline-item text-sm!";
+ "group flex items-center px-2 py-1.5 leading-normal font-medium rounded-xs text-gray-700 outline-item whitespace-nowrap text-sm!";
const childRouteClass =
- "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-xs";
+ "group w-full flex items-center pl-9 pr-2 py-1 outline-item mb-0.5 rounded-xs whitespace-nowrap";
export function ProjectSidebar() {
const rawItems = useSidebarItems();
diff --git a/frontend/src/react/components/ui/button.test.tsx b/frontend/src/react/components/ui/button.test.tsx
new file mode 100644
index 0000000000..71215fc2b6
--- /dev/null
+++ b/frontend/src/react/components/ui/button.test.tsx
@@ -0,0 +1,13 @@
+import { describe, expect, test } from "vitest";
+import { buttonVariants } from "./button";
+
+describe("buttonVariants", () => {
+ test("keeps sizing overridable for class-helper consumers", () => {
+ const className = buttonVariants({ className: "size-8 p-0" });
+
+ expect(className).toContain("size-8");
+ expect(className).toContain("p-0");
+ expect(className).not.toContain("h-9");
+ expect(className).not.toContain("px-3");
+ });
+});
diff --git a/frontend/src/react/components/ui/button.tsx b/frontend/src/react/components/ui/button.tsx
index 74164b7b97..62fa6c0275 100644
--- a/frontend/src/react/components/ui/button.tsx
+++ b/frontend/src/react/components/ui/button.tsx
@@ -1,10 +1,11 @@
import { Button as BaseButton } from "@base-ui/react/button";
import { cva, type VariantProps } from "class-variance-authority";
+import type { ClassValue } from "clsx";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
-const buttonVariants = cva(
- "inline-flex items-center justify-center gap-2 rounded-xs text-sm font-medium whitespace-nowrap cursor-pointer transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
+const buttonVariantClasses = cva(
+ "inline-flex items-center justify-center rounded-xs font-medium whitespace-nowrap cursor-pointer transition-colors focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
{
variants: {
variant: {
@@ -19,11 +20,11 @@ const buttonVariants = cva(
},
size: {
// `default` is an alias for `md` — both render identically.
- default: "h-9 px-3 text-sm leading-5",
- xs: "h-6 px-1.5 text-xs leading-4 gap-1.5",
- sm: "h-7 px-2 text-xs leading-4",
- md: "h-9 px-3 text-sm leading-5",
- lg: "h-10 px-4 text-sm leading-5",
+ default: "h-9 px-3 text-sm leading-5 gap-1.5",
+ xs: "h-6 px-1.5 text-xs leading-4 gap-1",
+ sm: "h-7 px-2 text-xs leading-4 gap-1",
+ md: "h-9 px-3 text-sm leading-5 gap-1.5",
+ lg: "h-10 px-4 text-sm leading-5 gap-1.5",
},
},
defaultVariants: {
@@ -33,15 +34,42 @@ const buttonVariants = cva(
}
);
-type ButtonProps = ComponentProps<"button"> &
- VariantProps<typeof buttonVariants>;
+type ButtonVariantProps = VariantProps<typeof buttonVariantClasses> & {
+ class?: ClassValue;
+ className?: ClassValue;
+};
-function Button({ className, variant, size, ref, ...props }: ButtonProps) {
+function buttonVariants({
+ class: classValue,
+ className,
+ size = "default",
+ variant,
+}: ButtonVariantProps = {}) {
+ return cn(buttonVariantClasses({ size, variant }), classValue, className);
+}
+
+type ButtonProps = ComponentProps<"button"> & ButtonVariantProps;
+
+function Button({
+ class: classValue,
+ className,
+ variant,
+ size = "default",
+ ref,
+ style,
+ ...props
+}: ButtonProps) {
return (
<BaseButton
- ref={ref}
- className={cn(buttonVariants({ variant, size, className }))}
{...props}
+ ref={ref}
+ className={buttonVariants({
+ class: classValue,
+ className,
+ size,
+ variant,
+ })}
+ style={style}
/>
);
}
diff --git a/frontend/src/react/components/ui/combobox.test.tsx b/frontend/src/react/components/ui/combobox.test.tsx
index 6fad8ef5f6..487374d309 100644
--- a/frontend/src/react/components/ui/combobox.test.tsx
+++ b/frontend/src/react/components/ui/combobox.test.tsx
@@ -60,6 +60,13 @@ describe("Combobox", () => {
expect(dropdown?.textContent).toContain("Alpha");
expect(dropdown?.className).toContain(LAYER_SURFACE_CLASS);
expect(overlayRoot?.lastElementChild).toBe(dropdown);
+ expect(dropdown?.querySelector("input")?.style.paddingInlineStart).toBe(
+ "2rem"
+ );
+ const option = Array.from(dropdown?.querySelectorAll("button") ?? []).find(
+ (button) => button.textContent?.includes("Alpha")
+ );
+ expect(option?.parentElement?.parentElement?.className).toContain("px-2");
act(() => {
root.unmount();
diff --git a/frontend/src/react/components/ui/combobox.tsx b/frontend/src/react/components/ui/combobox.tsx
index 9f4a7ed3fa..70a26a52a0 100644
--- a/frontend/src/react/components/ui/combobox.tsx
+++ b/frontend/src/react/components/ui/combobox.tsx
@@ -1,3 +1,4 @@
+import * as stylex from "@stylexjs/stylex";
import { Check, ChevronDown, X } from "lucide-react";
import {
useCallback,
@@ -17,6 +18,12 @@ import {
} from "./combobox-position";
import { getLayerRoot, LAYER_SURFACE_CLASS } from "./layer";
import { SearchInput } from "./search-input";
+import {
+ type ControlSize,
+ controlMinHeightStyle,
+ menuRowStateClassName,
+ menuRowStyle,
+} from "./styles.stylex";
export interface ComboboxOption {
value: string;
@@ -65,8 +72,8 @@ type ComboboxBaseProps = {
className?: string;
disabled?: boolean;
clearable?: boolean;
- /** Trigger size — matches the Input component's tier names. Defaults to `md`. */
- size?: "sm" | "md";
+ /** Trigger size — matches the shared control size tier names. Defaults to `md`. */
+ size?: ControlSize;
/** Render dropdown via portal (use when inside overflow:hidden containers like modals) */
portal?: boolean;
};
@@ -319,17 +326,19 @@ export function Combobox(props: ComboboxProps) {
// ---- Render option row ----
const renderOptionRow = (option: ComboboxOption) => {
const isSelected = selectedValues.includes(option.value);
+ const stylexProps = stylex.props(menuRowStyle("sm"));
return (
<button
key={option.value}
type="button"
disabled={option.disabled}
+ data-selected={isSelected || undefined}
className={cn(
- "w-full text-left px-3 py-1.5 text-sm flex items-center gap-x-2 transition-colors",
- "hover:bg-control-bg",
- isSelected && "bg-accent/5",
- option.disabled && "opacity-50 cursor-not-allowed"
+ stylexProps.className,
+ menuRowStateClassName,
+ option.disabled && "cursor-not-allowed"
)}
+ style={stylexProps.style}
onClick={() => !option.disabled && handleSelect(option.value)}
>
{multiple && (
@@ -374,6 +383,8 @@ export function Combobox(props: ComboboxProps) {
);
};
+ const triggerStylexProps = stylex.props(controlMinHeightStyle(size));
+
// ---- Render dropdown content ----
const dropdownContent = (
<div
@@ -392,7 +403,7 @@ export function Combobox(props: ComboboxProps) {
wrapperClassName="m-2"
className="h-7"
/>
- <div className="max-h-60 overflow-y-auto">
+ <div className="max-h-60 overflow-y-auto px-2 pb-2">
{filteredGroups.every((g) => g.options.length === 0) ? (
noResultsContent !== undefined ? (
<div className="p-3">{noResultsContent}</div>
@@ -428,13 +439,12 @@ export function Combobox(props: ComboboxProps) {
// looks broken. Keep the trigger on a single line in that case
// and let the label truncate inside `renderTrigger`.
"flex items-center gap-1 w-full rounded-xs border border-control-border bg-background py-1 cursor-pointer",
- size === "sm"
- ? "min-h-7 px-2 text-xs leading-4"
- : "min-h-9 px-3 text-sm leading-5",
+ triggerStylexProps.className,
multiple && "flex-wrap",
disabled && "opacity-50 cursor-not-allowed",
open && "border-accent"
)}
+ style={triggerStylexProps.style}
onClick={() => {
if (!disabled) {
setOpen(!open);
diff --git a/frontend/src/react/components/ui/context-menu.test.tsx b/frontend/src/react/components/ui/context-menu.test.tsx
index 542914c076..e2beb42610 100644
--- a/frontend/src/react/components/ui/context-menu.test.tsx
+++ b/frontend/src/react/components/ui/context-menu.test.tsx
@@ -1,3 +1,4 @@
+import * as stylex from "@stylexjs/stylex";
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test, vi } from "vitest";
@@ -9,6 +10,7 @@ import {
ContextMenuSeparator,
ContextMenuTrigger,
} from "./context-menu";
+import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -264,4 +266,52 @@ describe("ContextMenu", () => {
root.unmount();
});
});
+
+ test("uses shared menu row state classes for items", async () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <ContextMenu>
+ <ContextMenuTrigger>
+ <div data-testid="trigger">Right-click me</div>
+ </ContextMenuTrigger>
+ <ContextMenuContent>
+ <ContextMenuItem>Action</ContextMenuItem>
+ </ContextMenuContent>
+ </ContextMenu>
+ );
+ });
+
+ const trigger = container.querySelector("[data-testid='trigger']");
+
+ await act(async () => {
+ trigger?.dispatchEvent(
+ new MouseEvent("contextmenu", {
+ bubbles: true,
+ cancelable: true,
+ clientX: 50,
+ clientY: 50,
+ })
+ );
+ });
+
+ await vi.waitFor(() => {
+ expect(document.body.textContent).toContain("Action");
+ });
+
+ const item = Array.from(
+ document.querySelectorAll("[role='menuitem']")
+ ).find((el) => el.textContent === "Action");
+ expect(item?.className).toContain(
+ stylex.props(menuRowStyle("sm")).className ?? ""
+ );
+ expect(item?.className).toContain(menuRowStateClassName);
+
+ await act(async () => {
+ root.unmount();
+ });
+ });
});
diff --git a/frontend/src/react/components/ui/context-menu.tsx b/frontend/src/react/components/ui/context-menu.tsx
index 72ffa218a2..a5ff64b26b 100644
--- a/frontend/src/react/components/ui/context-menu.tsx
+++ b/frontend/src/react/components/ui/context-menu.tsx
@@ -1,4 +1,5 @@
import { ContextMenu as BaseContextMenu } from "@base-ui/react/context-menu";
+import * as stylex from "@stylexjs/stylex";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
import {
@@ -6,6 +7,7 @@ import {
LAYER_SURFACE_CLASS,
usePreserveHigherLayerAccess,
} from "./layer";
+import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
// ---- Root ----
// Wraps BaseContextMenu.Root. ContextMenu has no `modal` prop (it is omitted
@@ -51,17 +53,13 @@ function ContextMenuItem({
ref,
...props
}: ComponentProps<typeof BaseContextMenu.Item>) {
+ const stylexProps = stylex.props(menuRowStyle("sm"));
return (
<BaseContextMenu.Item
- ref={ref}
- className={cn(
- "relative flex items-center gap-x-2 px-2 py-1.5 text-sm cursor-pointer select-none",
- "hover:bg-control-bg focus:bg-control-bg outline-hidden",
- "data-highlighted:bg-control-bg",
- "data-disabled:pointer-events-none data-disabled:opacity-50",
- className
- )}
{...props}
+ ref={ref}
+ className={cn(stylexProps.className, menuRowStateClassName, className)}
+ style={{ ...stylexProps.style, ...props.style }}
>
{children}
</BaseContextMenu.Item>
diff --git a/frontend/src/react/components/ui/dropdown-menu.test.tsx b/frontend/src/react/components/ui/dropdown-menu.test.tsx
new file mode 100644
index 0000000000..ed2c2f2a0e
--- /dev/null
+++ b/frontend/src/react/components/ui/dropdown-menu.test.tsx
@@ -0,0 +1,105 @@
+import * as stylex from "@stylexjs/stylex";
+import { act } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, describe, expect, test, vi } from "vitest";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuTrigger,
+} from "./dropdown-menu";
+import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+globalThis.ResizeObserver ??= class ResizeObserver {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+};
+
+describe("DropdownMenu", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("uses shared menu row state classes for items", async () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <DropdownMenu>
+ <DropdownMenuTrigger>Open</DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem>Action</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+ });
+
+ await act(async () => {
+ container
+ .querySelector("button")
+ ?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ await vi.waitFor(() => {
+ expect(document.body.textContent).toContain("Action");
+ });
+
+ const item = Array.from(
+ document.querySelectorAll("[role='menuitem']")
+ ).find((el) => el.textContent === "Action");
+ expect(item?.className).toContain(
+ stylex.props(menuRowStyle("sm")).className ?? ""
+ );
+ expect(item?.className).toContain(menuRowStateClassName);
+
+ await act(async () => {
+ root.unmount();
+ });
+ });
+
+ test("renders section labels for grouped menus", async () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <DropdownMenu>
+ <DropdownMenuTrigger>Open</DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuLabel>Section</DropdownMenuLabel>
+ <DropdownMenuItem>Action</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+ });
+
+ await act(async () => {
+ container
+ .querySelector("button")
+ ?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ await vi.waitFor(() => {
+ expect(document.body.textContent).toContain("Section");
+ });
+
+ const label = Array.from(document.querySelectorAll("div")).find(
+ (el) => el.textContent === "Section"
+ );
+ expect(label?.className).toContain("text-xs");
+ expect(label?.className).toContain("text-control-light");
+
+ await act(async () => {
+ root.unmount();
+ });
+ });
+});
diff --git a/frontend/src/react/components/ui/dropdown-menu.tsx b/frontend/src/react/components/ui/dropdown-menu.tsx
index 9a0a07e092..d3bad4ea6d 100644
--- a/frontend/src/react/components/ui/dropdown-menu.tsx
+++ b/frontend/src/react/components/ui/dropdown-menu.tsx
@@ -1,7 +1,9 @@
import { Menu as BaseMenu } from "@base-ui/react/menu";
+import * as stylex from "@stylexjs/stylex";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
import { getLayerRoot, LAYER_SURFACE_CLASS } from "./layer";
+import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
// ---- Root ----
// Default to non-modal: row action menus should let users click through to
@@ -103,17 +105,13 @@ function DropdownMenuItem({
ref,
...props
}: ComponentProps<typeof BaseMenu.Item>) {
+ const stylexProps = stylex.props(menuRowStyle("sm"));
return (
<BaseMenu.Item
- ref={ref}
- className={cn(
- "relative flex items-center gap-x-2 px-3 py-2 text-sm cursor-pointer select-none",
- "hover:bg-control-bg focus:bg-control-bg outline-hidden",
- "data-highlighted:bg-control-bg",
- "data-disabled:pointer-events-none data-disabled:opacity-50",
- className
- )}
{...props}
+ ref={ref}
+ className={cn(stylexProps.className, menuRowStateClassName, className)}
+ style={{ ...stylexProps.style, ...props.style }}
>
{children}
</BaseMenu.Item>
@@ -126,17 +124,13 @@ function DropdownMenuSubmenuTrigger({
ref,
...props
}: ComponentProps<typeof BaseMenu.SubmenuTrigger>) {
+ const stylexProps = stylex.props(menuRowStyle("sm"));
return (
<BaseMenu.SubmenuTrigger
- ref={ref}
- className={cn(
- "relative flex items-center gap-x-2 px-3 py-2 text-sm cursor-pointer select-none",
- "hover:bg-control-bg focus:bg-control-bg outline-hidden",
- "data-highlighted:bg-control-bg",
- "data-disabled:pointer-events-none data-disabled:opacity-50",
- className
- )}
{...props}
+ ref={ref}
+ className={cn(stylexProps.className, menuRowStateClassName, className)}
+ style={{ ...stylexProps.style, ...props.style }}
>
{children}
</BaseMenu.SubmenuTrigger>
@@ -158,10 +152,29 @@ function DropdownMenuSeparator({
);
}
+// ---- Label ----
+// Non-interactive section header. Rendered as a plain <div> so grouped
+// dropdown menus share the same typography without becoming focusable items.
+function DropdownMenuLabel({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) {
+ return (
+ <div
+ className={cn(
+ "px-2 py-1.5 text-xs font-semibold text-control-light",
+ className
+ )}
+ {...props}
+ />
+ );
+}
+
export {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
+ DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuSubmenu,
DropdownMenuSubmenuContent,
diff --git a/frontend/src/react/components/ui/form.test.tsx b/frontend/src/react/components/ui/form.test.tsx
new file mode 100644
index 0000000000..9c3708db20
--- /dev/null
+++ b/frontend/src/react/components/ui/form.test.tsx
@@ -0,0 +1,155 @@
+import * as stylex from "@stylexjs/stylex";
+import { act, createElement, type ReactElement } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, describe, expect, test } from "vitest";
+import {
+ FormControlAffix,
+ FormControlGroup,
+ FormControlRow,
+ FormFieldGroup,
+ FormFieldRow,
+ FormInlineAffix,
+ FormMessage,
+} from "./form";
+import {
+ formControlAffixStyle,
+ formControlGroupStyle,
+ formControlRowStyle,
+ formFieldGroupStyle,
+ formFieldRowStyle,
+ formInlineAffixStyle,
+ formMessageStyle,
+} from "./styles.stylex";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ act(() => {
+ root.render(element);
+ });
+ return {
+ container,
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+describe("FormMessage", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("renders field validation messages as alert text", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(FormMessage, null, "Title is required")
+ );
+
+ const message = container.querySelector('[data-slot="form-message"]');
+ expect(message?.getAttribute("role")).toBe("alert");
+ expect(message?.textContent).toBe("Title is required");
+ expect(message?.className).toContain(
+ stylex.props(formMessageStyle()).className ?? ""
+ );
+
+ unmount();
+ });
+
+ test("renders field groups and horizontal field rows with shared spacing", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ FormFieldGroup,
+ null,
+ createElement(
+ FormFieldRow,
+ null,
+ createElement("label", null, "Environment"),
+ createElement("input", { "aria-label": "Environment" })
+ )
+ )
+ );
+
+ const group = container.querySelector('[data-slot="form-field-group"]');
+ const row = container.querySelector('[data-slot="form-field-row"]');
+
+ expect(group?.className).toContain(
+ stylex.props(formFieldGroupStyle()).className ?? ""
+ );
+ expect(row?.className).toContain(
+ stylex.props(formFieldRowStyle()).className ?? ""
+ );
+ expect(row?.children).toHaveLength(2);
+
+ unmount();
+ });
+
+ test("renders inline affix controls with non-shrinking affix text", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ FormInlineAffix,
+ null,
+ createElement("input", { "aria-label": "Email local part" }),
+ createElement(FormControlAffix, null, "@"),
+ createElement(FormControlAffix, null, "example.com")
+ )
+ );
+
+ const affix = container.querySelector('[data-slot="form-inline-affix"]');
+ const affixText = container.querySelector(
+ '[data-slot="form-control-affix"]'
+ );
+
+ expect(affix?.className).toContain(
+ stylex.props(formInlineAffixStyle()).className ?? ""
+ );
+ expect(affixText?.className).toContain(
+ stylex.props(formControlAffixStyle()).className ?? ""
+ );
+ expect(affix?.textContent).toBe("@example.com");
+
+ unmount();
+ });
+});
+
+describe("Form control layouts", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("renders inline control rows with shared alignment and gap styles", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ FormControlGroup,
+ null,
+ createElement(
+ FormControlRow,
+ null,
+ createElement("input", { "aria-label": "Parameter name" }),
+ createElement("input", { "aria-label": "Parameter value" }),
+ createElement("button", { type: "button" }, "Add")
+ )
+ )
+ );
+
+ const group = container.querySelector('[data-slot="form-control-group"]');
+ const row = container.querySelector('[data-slot="form-control-row"]');
+
+ expect(group?.className).toContain(
+ stylex.props(formControlGroupStyle()).className ?? ""
+ );
+ expect(row?.className).toContain(
+ stylex.props(formControlRowStyle()).className ?? ""
+ );
+ expect(row?.children).toHaveLength(3);
+ expect(row?.textContent).toBe("Add");
+
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/ui/form.tsx b/frontend/src/react/components/ui/form.tsx
new file mode 100644
index 0000000000..bbe828d293
--- /dev/null
+++ b/frontend/src/react/components/ui/form.tsx
@@ -0,0 +1,229 @@
+import * as stylex from "@stylexjs/stylex";
+import type { ComponentProps } from "react";
+import { cn } from "@/react/lib/utils";
+import {
+ formControlAffixStyle,
+ formControlGroupStyle,
+ formControlRowStyle,
+ formDescriptionStyle,
+ formErrorStyle,
+ formFieldGroupStyle,
+ formFieldRowStyle,
+ formFieldStyle,
+ formInlineAffixStyle,
+ formLabelStyle,
+ formMessageStyle,
+} from "./styles.stylex";
+
+function FormField({ className, ref, style, ...props }: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formFieldStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-field"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormFieldGroup({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formFieldGroupStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-field-group"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormFieldRow({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formFieldRowStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-field-row"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormControlGroup({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formControlGroupStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-control-group"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormControlRow({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formControlRowStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-control-row"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormInlineAffix({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"div">) {
+ const stylexProps = stylex.props(formInlineAffixStyle());
+ return (
+ <div
+ ref={ref}
+ data-slot="form-inline-affix"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormControlAffix({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"span">) {
+ const stylexProps = stylex.props(formControlAffixStyle());
+ return (
+ <span
+ ref={ref}
+ data-slot="form-control-affix"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormLabel({
+ className,
+ htmlFor,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"label">) {
+ const stylexProps = stylex.props(formLabelStyle());
+ return (
+ <label
+ ref={ref}
+ data-slot="form-label"
+ htmlFor={htmlFor}
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormDescription({
+ className,
+ ref,
+ style,
+ ...props
+}: ComponentProps<"p">) {
+ const stylexProps = stylex.props(formDescriptionStyle());
+ return (
+ <p
+ ref={ref}
+ data-slot="form-description"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormError({
+ className,
+ ref,
+ role = "alert",
+ style,
+ ...props
+}: ComponentProps<"p">) {
+ const stylexProps = stylex.props(formErrorStyle());
+ return (
+ <p
+ ref={ref}
+ role={role}
+ data-slot="form-error"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+function FormMessage({
+ className,
+ ref,
+ role = "alert",
+ style,
+ ...props
+}: ComponentProps<"p">) {
+ const stylexProps = stylex.props(formMessageStyle());
+ return (
+ <p
+ ref={ref}
+ role={role}
+ data-slot="form-message"
+ className={cn(stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
+ {...props}
+ />
+ );
+}
+
+export {
+ FormControlAffix,
+ FormControlGroup,
+ FormControlRow,
+ FormDescription,
+ FormError,
+ FormField,
+ FormFieldGroup,
+ FormFieldRow,
+ FormInlineAffix,
+ FormLabel,
+ FormMessage,
+};
diff --git a/frontend/src/react/components/ui/input.tsx b/frontend/src/react/components/ui/input.tsx
index dfbe0df3d2..e5f3500c0a 100644
--- a/frontend/src/react/components/ui/input.tsx
+++ b/frontend/src/react/components/ui/input.tsx
@@ -1,7 +1,9 @@
import { Input as BaseInput } from "@base-ui/react/input";
-import { cva, type VariantProps } from "class-variance-authority";
+import * as stylex from "@stylexjs/stylex";
+import { cva } from "class-variance-authority";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
+import { type ControlSize, controlSizeStyle } from "./styles.stylex";
const inputVariants = cva(
cn(
@@ -10,31 +12,21 @@ const inputVariants = cva(
"focus:outline-hidden",
"disabled:cursor-not-allowed disabled:bg-control-bg disabled:opacity-50",
"read-only:cursor-default read-only:bg-control-bg read-only:focus:ring-0 read-only:focus:border-control-border"
- ),
- {
- variants: {
- size: {
- xs: "h-6 px-2 text-xs leading-4",
- sm: "h-7 px-2 text-xs leading-4",
- md: "h-9 px-3 text-sm leading-5",
- lg: "h-10 px-4 text-sm leading-5",
- },
- },
- defaultVariants: {
- size: "md",
- },
- }
+ )
);
-type InputProps = Omit<ComponentProps<"input">, "size"> &
- VariantProps<typeof inputVariants>;
+type InputProps = Omit<ComponentProps<"input">, "size"> & {
+ size?: ControlSize;
+};
-function Input({ className, size, ref, ...props }: InputProps) {
+function Input({ className, size = "md", ref, style, ...props }: InputProps) {
+ const stylexProps = stylex.props(controlSizeStyle(size));
return (
<BaseInput
- ref={ref}
- className={cn(inputVariants({ size }), className)}
{...props}
+ ref={ref}
+ className={cn(inputVariants(), stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
/>
);
}
diff --git a/frontend/src/react/components/ui/number-input.test.tsx b/frontend/src/react/components/ui/number-input.test.tsx
index 17438c830b..a8cea662c7 100644
--- a/frontend/src/react/components/ui/number-input.test.tsx
+++ b/frontend/src/react/components/ui/number-input.test.tsx
@@ -1,7 +1,9 @@
+import * as stylex from "@stylexjs/stylex";
import { act } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test } from "vitest";
import { NumberInput } from "./number-input";
+import { controlSizeStyle } from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -17,6 +19,12 @@ function mount(node: React.ReactNode) {
return { container, root };
}
+const expectClasses = (className: string | undefined, expected: string) => {
+ for (const expectedClass of expected.split(" ")) {
+ expect(className ?? "").toContain(expectedClass);
+ }
+};
+
describe("NumberInput", () => {
afterEach(() => {
document.body.innerHTML = "";
@@ -47,6 +55,21 @@ describe("NumberInput", () => {
expect(container.querySelector("input")).toBeInstanceOf(HTMLInputElement);
});
+ test("keeps affix padding overridable by inputClassName", () => {
+ const { container } = mount(
+ <NumberInput
+ value={10}
+ onValueChange={() => {}}
+ suffix="MB"
+ inputClassName="pr-16"
+ />
+ );
+ const input = container.querySelector("input");
+
+ expect(input?.className).toContain("pr-16");
+ expect(input?.className).not.toContain("pr-12");
+ });
+
test("applies className to the outer wrapper and size variant to the input", () => {
const { container } = mount(
<NumberInput
@@ -59,7 +82,12 @@ describe("NumberInput", () => {
const wrapper = container.firstElementChild as HTMLElement | null;
const input = container.querySelector("input");
expect(wrapper?.className).toContain("w-60");
- expect(input?.className).toContain("h-7");
+ expectClasses(
+ input?.className,
+ stylex.props(controlSizeStyle("sm", { paddingInline: false }))
+ .className ?? ""
+ );
+ expect(input?.className).toContain("px-2");
});
test("forwards the disabled prop to the underlying input", () => {
diff --git a/frontend/src/react/components/ui/number-input.tsx b/frontend/src/react/components/ui/number-input.tsx
index e6b285a057..23ecafd4ce 100644
--- a/frontend/src/react/components/ui/number-input.tsx
+++ b/frontend/src/react/components/ui/number-input.tsx
@@ -1,7 +1,9 @@
import { NumberField } from "@base-ui/react/number-field";
-import { cva, type VariantProps } from "class-variance-authority";
+import * as stylex from "@stylexjs/stylex";
+import { cva } from "class-variance-authority";
import type { ComponentPropsWithoutRef, ReactNode } from "react";
import { cn } from "@/react/lib/utils";
+import { type ControlSize, controlSizeStyle } from "./styles.stylex";
// Mirrors the sizing/appearance of ./input.tsx so NumberInput visually matches
// the regular Input at every size.
@@ -12,35 +14,33 @@ const numberInputClasses = cva(
"focus:outline-hidden",
"disabled:cursor-not-allowed disabled:bg-control-bg disabled:opacity-50",
"read-only:cursor-default read-only:bg-control-bg read-only:focus:ring-0 read-only:focus:border-control-border"
- ),
- {
- variants: {
- size: {
- xs: "h-6 px-2 text-xs leading-4",
- sm: "h-7 px-2 text-xs leading-4",
- md: "h-9 px-3 text-sm leading-5",
- lg: "h-10 px-4 text-sm leading-5",
- },
- },
- defaultVariants: {
- size: "md",
- },
- }
+ )
);
+const numberInputPaddingClasses = cva("", {
+ variants: {
+ size: {
+ xs: "px-1.5",
+ sm: "px-2",
+ md: "px-3",
+ lg: "px-4",
+ },
+ },
+});
+
type NumberFieldRootProps = ComponentPropsWithoutRef<typeof NumberField.Root>;
interface NumberInputProps
extends Omit<
- NumberFieldRootProps,
- "className" | "render" | "size" | "prefix"
- >,
- VariantProps<typeof numberInputClasses> {
+ NumberFieldRootProps,
+ "className" | "render" | "size" | "prefix"
+ > {
/** Applied to the outer wrapper; use for layout/width classes (e.g. "w-60"). */
className?: string;
/** Applied to the underlying input element for extra input-specific styling. */
inputClassName?: string;
placeholder?: string;
+ size?: ControlSize;
/** Content rendered inside the field to the right of the input (e.g. unit). */
suffix?: ReactNode;
/** Content rendered inside the field to the left of the input. */
@@ -50,15 +50,20 @@ interface NumberInputProps
function NumberInput({
className,
inputClassName,
- size,
+ size = "md",
suffix,
prefix,
placeholder,
...rootProps
}: NumberInputProps) {
const hasAffix = Boolean(prefix || suffix);
+ const stylexProps = stylex.props(
+ controlSizeStyle(size, { paddingInline: false })
+ );
const inputClasses = cn(
- numberInputClasses({ size }),
+ numberInputClasses(),
+ stylexProps.className,
+ numberInputPaddingClasses({ size }),
prefix && "pl-10",
suffix && "pr-12",
inputClassName
@@ -67,7 +72,11 @@ function NumberInput({
if (!hasAffix) {
return (
<NumberField.Root {...rootProps} className={className}>
- <NumberField.Input placeholder={placeholder} className={inputClasses} />
+ <NumberField.Input
+ placeholder={placeholder}
+ className={inputClasses}
+ style={stylexProps.style}
+ />
</NumberField.Root>
);
}
@@ -80,7 +89,11 @@ function NumberInput({
{prefix}
</span>
)}
- <NumberField.Input placeholder={placeholder} className={inputClasses} />
+ <NumberField.Input
+ placeholder={placeholder}
+ className={inputClasses}
+ style={stylexProps.style}
+ />
{suffix && (
<span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-sm text-control-light">
{suffix}
diff --git a/frontend/src/react/components/ui/radio-group.test.tsx b/frontend/src/react/components/ui/radio-group.test.tsx
index bdfc9f8d54..8e7c2b3340 100644
--- a/frontend/src/react/components/ui/radio-group.test.tsx
+++ b/frontend/src/react/components/ui/radio-group.test.tsx
@@ -57,4 +57,41 @@ describe("RadioGroupItem", () => {
unmount();
});
+
+ test("uses the semantic accent token for checked and focus states", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ RadioGroup,
+ { value: "workspace", onValueChange: () => undefined },
+ createElement(RadioGroupItem, { value: "workspace" }, "Workspace")
+ )
+ );
+
+ expect(getRadio(container).className).toContain(
+ "data-[checked]:border-[rgb(var(--color-accent))]"
+ );
+ expect(getRadio(container).className).toContain(
+ "focus-visible:ring-[rgb(var(--color-accent))]"
+ );
+
+ unmount();
+ });
+
+ test("allows the radio control to be offset for rich labels", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(
+ RadioGroup,
+ { value: "workspace", onValueChange: () => undefined },
+ createElement(
+ RadioGroupItem,
+ { value: "workspace", radioClassName: "mt-1" },
+ createElement("div", null, "Workspace")
+ )
+ )
+ );
+
+ expect(getRadio(container).className).toContain("mt-1");
+
+ unmount();
+ });
});
diff --git a/frontend/src/react/components/ui/radio-group.tsx b/frontend/src/react/components/ui/radio-group.tsx
index c6a9224360..adc635c6aa 100644
--- a/frontend/src/react/components/ui/radio-group.tsx
+++ b/frontend/src/react/components/ui/radio-group.tsx
@@ -17,9 +17,15 @@ function RadioGroup({
function RadioGroupItem({
children,
className,
+ contentClassName,
+ radioClassName,
value,
...props
-}: React.ComponentProps<typeof Radio.Root> & { children?: React.ReactNode }) {
+}: React.ComponentProps<typeof Radio.Root> & {
+ children?: React.ReactNode;
+ contentClassName?: string;
+ radioClassName?: string;
+}) {
return (
<label
className={cn("flex items-center gap-x-2 cursor-pointer", className)}
@@ -28,13 +34,16 @@ function RadioGroupItem({
value={value}
className={cn(
"flex size-4 shrink-0 items-center justify-center rounded-full border border-control-border",
- "data-[checked]:border-accent data-[checked]:border-[5px]",
- "focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2",
- "disabled:cursor-not-allowed disabled:opacity-50"
+ "data-[checked]:border-[rgb(var(--color-accent))] data-[checked]:border-[5px]",
+ "focus:outline-hidden focus-visible:ring-2 focus-visible:ring-[rgb(var(--color-accent))] focus-visible:ring-offset-2",
+ "disabled:cursor-not-allowed disabled:opacity-50",
+ radioClassName
)}
{...props}
/>
- {children && <span className="text-sm">{children}</span>}
+ {children && (
+ <div className={cn("text-sm", contentClassName)}>{children}</div>
+ )}
</label>
);
}
diff --git a/frontend/src/react/components/ui/search-input.tsx b/frontend/src/react/components/ui/search-input.tsx
index 4633023942..e2ac69c425 100644
--- a/frontend/src/react/components/ui/search-input.tsx
+++ b/frontend/src/react/components/ui/search-input.tsx
@@ -12,7 +12,7 @@ type SearchInputProps = Omit<ComponentProps<typeof Input>, "className"> & {
export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
function SearchInput(
- { className, wrapperClassName, placeholder, ...props },
+ { className, wrapperClassName, placeholder, style, ...props },
ref
) {
const { t } = useTranslation();
@@ -24,6 +24,7 @@ export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
autoComplete="off"
className={cn("pl-8", className)}
placeholder={placeholder ?? t("common.type-to-search")}
+ style={{ ...style, paddingInlineStart: "2rem" }}
{...props}
/>
</div>
diff --git a/frontend/src/react/components/ui/segmented-control.tsx b/frontend/src/react/components/ui/segmented-control.tsx
index fd005a8eda..905155c366 100644
--- a/frontend/src/react/components/ui/segmented-control.tsx
+++ b/frontend/src/react/components/ui/segmented-control.tsx
@@ -1,8 +1,10 @@
import { Radio } from "@base-ui/react/radio";
import { RadioGroup as BaseRadioGroup } from "@base-ui/react/radio-group";
+import * as stylex from "@stylexjs/stylex";
import type { ReactNode } from "react";
import { Tooltip } from "@/react/components/ui/tooltip";
import { cn } from "@/react/lib/utils";
+import { type ControlSize, controlMinHeightStyle } from "./styles.stylex";
export interface SegmentedControlOption<T extends string> {
value: T;
@@ -18,8 +20,8 @@ interface SegmentedControlProps<T extends string> {
ariaLabel: string;
disabled?: boolean;
className?: string;
- /** Segment size — matches the Input/Combobox size tier names. Defaults to `md`. */
- size?: "sm" | "md";
+ /** Segment size — matches the shared control size tier names. Defaults to `md`. */
+ size?: ControlSize;
}
export function SegmentedControl<T extends string>({
@@ -31,8 +33,6 @@ export function SegmentedControl<T extends string>({
className,
size = "md",
}: SegmentedControlProps<T>) {
- const segmentSizeClasses =
- size === "sm" ? "min-h-7 px-2 text-xs" : "min-h-8 px-3 text-sm";
return (
<BaseRadioGroup
value={value}
@@ -51,12 +51,13 @@ export function SegmentedControl<T extends string>({
const previousSelected =
index > 0 && options[index - 1]?.value === value;
const optionDisabled = disabled || option.disabled;
+ const stylexProps = stylex.props(controlMinHeightStyle(size));
const segment = (
<label
key={option.value}
className={cn(
"relative inline-flex items-center justify-center transition-colors focus-within:outline-hidden focus-within:ring-2 focus-within:ring-accent focus-within:ring-inset",
- segmentSizeClasses,
+ stylexProps.className,
index > 0 &&
!previousSelected &&
"border-l border-control-border",
@@ -67,6 +68,7 @@ export function SegmentedControl<T extends string>({
? "cursor-not-allowed opacity-50 hover:bg-background"
: "cursor-pointer"
)}
+ style={stylexProps.style}
>
<Radio.Root
value={option.value}
diff --git a/frontend/src/react/components/ui/select.test.tsx b/frontend/src/react/components/ui/select.test.tsx
index 61999404ba..9db6c2f221 100644
--- a/frontend/src/react/components/ui/select.test.tsx
+++ b/frontend/src/react/components/ui/select.test.tsx
@@ -1,7 +1,9 @@
-import { act, type ReactNode } from "react";
+import * as stylex from "@stylexjs/stylex";
+import { act, type CSSProperties, type ReactNode } from "react";
import { createRoot } from "react-dom/client";
import { afterEach, describe, expect, test, vi } from "vitest";
-import { Select, SelectContent, SelectTrigger } from "./select";
+import { Select, SelectContent, SelectItem, SelectTrigger } from "./select";
+import { menuRowStateClassName, menuRowStyle } from "./styles.stylex";
(
globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
@@ -33,7 +35,19 @@ vi.mock("@base-ui/react/select", () => ({
return <div>{children}</div>;
},
Popup: ({ children }: { children: ReactNode }) => <div>{children}</div>,
- Item: ({ children }: { children: ReactNode }) => <div>{children}</div>,
+ Item: ({
+ children,
+ ...props
+ }: {
+ children: ReactNode;
+ className?: string;
+ role?: string;
+ style?: CSSProperties;
+ }) => (
+ <div role="option" {...props}>
+ {children}
+ </div>
+ ),
ItemIndicator: ({ children }: { children: ReactNode }) => <>{children}</>,
ItemText: ({ children }: { children: ReactNode }) => <>{children}</>,
},
@@ -133,3 +147,35 @@ describe("SelectTrigger", () => {
});
});
});
+
+describe("SelectItem", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("uses shared menu row classes for options", async () => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+
+ await act(async () => {
+ root.render(
+ <Select>
+ <SelectContent>
+ <SelectItem value="alpha">Alpha</SelectItem>
+ </SelectContent>
+ </Select>
+ );
+ });
+
+ const option = container.querySelector("[role='option']");
+ expect(option?.className).toContain(
+ stylex.props(menuRowStyle("sm")).className ?? ""
+ );
+ expect(option?.className).toContain(menuRowStateClassName);
+
+ await act(async () => {
+ root.unmount();
+ });
+ });
+});
diff --git a/frontend/src/react/components/ui/select.tsx b/frontend/src/react/components/ui/select.tsx
index dac9d59af5..fd637fa496 100644
--- a/frontend/src/react/components/ui/select.tsx
+++ b/frontend/src/react/components/ui/select.tsx
@@ -1,9 +1,16 @@
import { Select as BaseSelect } from "@base-ui/react/select";
-import { cva, type VariantProps } from "class-variance-authority";
+import * as stylex from "@stylexjs/stylex";
+import { cva } from "class-variance-authority";
import { Check, ChevronDown } from "lucide-react";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
import { getLayerRoot, LAYER_SURFACE_CLASS } from "./layer";
+import {
+ type ControlSize,
+ controlSizeStyle,
+ menuRowStateClassName,
+ menuRowStyle,
+} from "./styles.stylex";
// ---- Root ----
const Select = BaseSelect.Root;
@@ -15,37 +22,28 @@ const selectTriggerVariants = cva(
"cursor-pointer",
"hover:bg-control-bg focus:outline-hidden focus-visible:ring-2 focus-visible:ring-accent",
"disabled:pointer-events-none disabled:opacity-50"
- ),
- {
- variants: {
- size: {
- xs: "h-6 px-2 text-xs leading-4",
- sm: "h-7 px-2 text-xs leading-4",
- md: "h-9 px-3 text-sm leading-5",
- lg: "h-10 px-4 text-sm leading-5",
- },
- },
- defaultVariants: {
- size: "md",
- },
- }
+ )
);
-type SelectTriggerProps = ComponentProps<typeof BaseSelect.Trigger> &
- VariantProps<typeof selectTriggerVariants>;
+type SelectTriggerProps = ComponentProps<typeof BaseSelect.Trigger> & {
+ size?: ControlSize;
+};
function SelectTrigger({
className,
children,
ref,
- size,
+ size = "md",
+ style,
...props
}: SelectTriggerProps) {
+ const stylexProps = stylex.props(controlSizeStyle(size));
return (
<BaseSelect.Trigger
- ref={ref}
- className={cn(selectTriggerVariants({ size }), className)}
{...props}
+ ref={ref}
+ className={cn(selectTriggerVariants(), stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
>
{children}
<BaseSelect.Icon>
@@ -112,20 +110,19 @@ function SelectItem({
ref,
...props
}: ComponentProps<typeof BaseSelect.Item>) {
+ const stylexProps = stylex.props(menuRowStyle("sm"));
return (
<BaseSelect.Item
- ref={ref}
- className={cn(
- "relative flex items-center gap-2 px-2 py-1.5 pl-7 text-sm cursor-pointer select-none",
- "hover:bg-control-bg focus:bg-control-bg outline-hidden",
- "data-highlighted:bg-control-bg",
- className
- )}
{...props}
+ ref={ref}
+ className={cn(stylexProps.className, menuRowStateClassName, className)}
+ style={{ ...stylexProps.style, ...props.style }}
>
- <BaseSelect.ItemIndicator className="absolute left-1.5">
- <Check className="size-3.5" />
- </BaseSelect.ItemIndicator>
+ <span className="flex size-4 shrink-0 items-center justify-center">
+ <BaseSelect.ItemIndicator>
+ <Check className="size-3.5" />
+ </BaseSelect.ItemIndicator>
+ </span>
<BaseSelect.ItemText>{children}</BaseSelect.ItemText>
</BaseSelect.Item>
);
diff --git a/frontend/src/react/components/ui/sticky-action-footer.test.tsx b/frontend/src/react/components/ui/sticky-action-footer.test.tsx
new file mode 100644
index 0000000000..9b09167603
--- /dev/null
+++ b/frontend/src/react/components/ui/sticky-action-footer.test.tsx
@@ -0,0 +1,81 @@
+import * as stylex from "@stylexjs/stylex";
+import { act, createElement, type ReactElement } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, describe, expect, test } from "vitest";
+import { StickyActionFooter } from "./sticky-action-footer";
+import {
+ stickyActionFooterRightStyle,
+ stickyActionFooterSideStyle,
+ stickyActionFooterStyle,
+} from "./styles.stylex";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ act(() => {
+ root.render(element);
+ });
+ return {
+ container,
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+describe("StickyActionFooter", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("keeps negative actions on the left and positive actions on the right", () => {
+ const { container, unmount } = renderIntoContainer(
+ createElement(StickyActionFooter, {
+ left: createElement("button", { type: "button" }, "Cancel"),
+ right: [
+ createElement("button", { key: "test", type: "button" }, "Test"),
+ createElement("button", { key: "save", type: "button" }, "Save"),
+ ],
+ })
+ );
+
+ const footer = container.querySelector(
+ '[data-slot="sticky-action-footer"]'
+ );
+ const left = container.querySelector(
+ '[data-slot="sticky-action-footer-left"]'
+ );
+ const right = container.querySelector(
+ '[data-slot="sticky-action-footer-right"]'
+ );
+
+ expect(footer?.className).toContain("sticky");
+ expect(footer?.className).toContain("bottom-0");
+ expect(footer?.className).toContain(
+ stylex.props(stickyActionFooterStyle()).className ?? ""
+ );
+ expect(footer?.firstElementChild).toBe(left);
+ expect(footer?.lastElementChild).toBe(right);
+ expect(left?.textContent).toBe("Cancel");
+ expect(left?.className).toContain(
+ stylex.props(stickyActionFooterSideStyle()).className ?? ""
+ );
+ expect(right?.textContent).toBe("TestSave");
+ expect(right?.className).toContain("gap-x-2");
+ expect(right?.className).toContain(
+ stylex.props(
+ stickyActionFooterSideStyle(),
+ stickyActionFooterRightStyle()
+ ).className ?? ""
+ );
+
+ unmount();
+ });
+});
diff --git a/frontend/src/react/components/ui/sticky-action-footer.tsx b/frontend/src/react/components/ui/sticky-action-footer.tsx
new file mode 100644
index 0000000000..480de91339
--- /dev/null
+++ b/frontend/src/react/components/ui/sticky-action-footer.tsx
@@ -0,0 +1,66 @@
+import * as stylex from "@stylexjs/stylex";
+import type { ComponentProps, ReactNode } from "react";
+import { cn } from "@/react/lib/utils";
+import {
+ stickyActionFooterRightStyle,
+ stickyActionFooterSideStyle,
+ stickyActionFooterStyle,
+} from "./styles.stylex";
+
+type StickyActionFooterProps = Readonly<
+ ComponentProps<"div"> & {
+ left?: ReactNode;
+ right?: ReactNode;
+ leftClassName?: string;
+ rightClassName?: string;
+ }
+>;
+
+function StickyActionFooter({
+ className,
+ left,
+ leftClassName,
+ right,
+ rightClassName,
+ ref,
+ style,
+ ...props
+}: StickyActionFooterProps) {
+ const rootStylexProps = stylex.props(stickyActionFooterStyle());
+ const leftStylexProps = stylex.props(stickyActionFooterSideStyle());
+ const rightStylexProps = stylex.props(
+ stickyActionFooterSideStyle(),
+ stickyActionFooterRightStyle()
+ );
+
+ return (
+ <div
+ ref={ref}
+ data-slot="sticky-action-footer"
+ className={cn(
+ "sticky bottom-0 z-10 border-t border-block-border bg-background py-4",
+ rootStylexProps.className,
+ className
+ )}
+ style={{ ...rootStylexProps.style, ...style }}
+ {...props}
+ >
+ <div
+ data-slot="sticky-action-footer-left"
+ className={cn(leftStylexProps.className, leftClassName)}
+ style={leftStylexProps.style}
+ >
+ {left}
+ </div>
+ <div
+ data-slot="sticky-action-footer-right"
+ className={cn("gap-x-2", rightStylexProps.className, rightClassName)}
+ style={rightStylexProps.style}
+ >
+ {right}
+ </div>
+ </div>
+ );
+}
+
+export { StickyActionFooter };
diff --git a/frontend/src/react/components/ui/styles.stylex.test.tsx b/frontend/src/react/components/ui/styles.stylex.test.tsx
new file mode 100644
index 0000000000..4ab976d1ee
--- /dev/null
+++ b/frontend/src/react/components/ui/styles.stylex.test.tsx
@@ -0,0 +1,328 @@
+import * as stylex from "@stylexjs/stylex";
+import { act, createElement, type ReactElement } from "react";
+import { createRoot } from "react-dom/client";
+import { afterEach, describe, expect, test } from "vitest";
+import { Button } from "./button";
+import { Combobox } from "./combobox";
+import {
+ FormControlAffix,
+ FormControlGroup,
+ FormControlRow,
+ FormDescription,
+ FormError,
+ FormField,
+ FormFieldGroup,
+ FormFieldRow,
+ FormInlineAffix,
+ FormLabel,
+ FormMessage,
+} from "./form";
+import { Input } from "./input";
+import { NumberInput } from "./number-input";
+import { SegmentedControl } from "./segmented-control";
+import { Select, SelectTrigger } from "./select";
+import {
+ controlMinHeightStyle,
+ controlMultilineSizeStyle,
+ controlSizeStyle,
+ formControlAffixStyle,
+ formControlGroupStyle,
+ formControlRowStyle,
+ formDescriptionStyle,
+ formErrorStyle,
+ formFieldGroupStyle,
+ formFieldRowStyle,
+ formFieldStyle,
+ formInlineAffixStyle,
+ formLabelStyle,
+ formMessageStyle,
+ interactiveRowStyle,
+ listRowStyle,
+ menuRowStateClassName,
+ menuRowStyle,
+ stickyActionFooterRightStyle,
+ stickyActionFooterSideStyle,
+ stickyActionFooterStyle,
+} from "./styles.stylex";
+import { Textarea } from "./textarea";
+
+(
+ globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }
+).IS_REACT_ACT_ENVIRONMENT = true;
+
+const renderIntoContainer = (element: ReactElement) => {
+ const container = document.createElement("div");
+ document.body.appendChild(container);
+ const root = createRoot(container);
+ act(() => {
+ root.render(element);
+ });
+ return {
+ container,
+ unmount: () =>
+ act(() => {
+ root.unmount();
+ container.remove();
+ }),
+ };
+};
+
+const expectStyleXClass = (className: string | undefined) => {
+ expect(className).toEqual(expect.any(String));
+ expect(className ?? "").toContain("x");
+};
+
+const expectClasses = (className: string | undefined, expected: string) => {
+ for (const expectedClass of expected.split(" ")) {
+ expect(className ?? "").toContain(expectedClass);
+ }
+};
+
+describe("StyleX common UI style contracts", () => {
+ afterEach(() => {
+ document.body.innerHTML = "";
+ });
+
+ test("returns StyleX props for shared control and row styles", () => {
+ expectStyleXClass(stylex.props(controlSizeStyle("sm")).className);
+ expectStyleXClass(stylex.props(controlMinHeightStyle("lg")).className);
+ expectStyleXClass(stylex.props(controlMultilineSizeStyle("md")).className);
+ expectStyleXClass(stylex.props(interactiveRowStyle("md")).className);
+ });
+
+ test("returns StyleX props for shared form, menu, and list row styles", () => {
+ expectStyleXClass(stylex.props(formFieldStyle()).className);
+ expectStyleXClass(stylex.props(formFieldGroupStyle()).className);
+ expectStyleXClass(stylex.props(formFieldRowStyle()).className);
+ expectStyleXClass(stylex.props(formControlGroupStyle()).className);
+ expectStyleXClass(stylex.props(formControlRowStyle()).className);
+ expectStyleXClass(stylex.props(formInlineAffixStyle()).className);
+ expectStyleXClass(stylex.props(formControlAffixStyle()).className);
+ expectStyleXClass(stylex.props(formLabelStyle()).className);
+ expectStyleXClass(stylex.props(formDescriptionStyle()).className);
+ expectStyleXClass(stylex.props(formErrorStyle()).className);
+ expectStyleXClass(stylex.props(formMessageStyle()).className);
+ expectStyleXClass(stylex.props(menuRowStyle("md")).className);
+ expectStyleXClass(stylex.props(listRowStyle("sm")).className);
+ expectClasses(
+ menuRowStateClassName,
+ "data-highlighted:bg-control-bg data-disabled:pointer-events-none data-disabled:opacity-50 data-selected:bg-accent/5 aria-selected:bg-accent/5 aria-disabled:pointer-events-none aria-disabled:opacity-50"
+ );
+ expectStyleXClass(stylex.props(stickyActionFooterStyle()).className);
+ expectStyleXClass(stylex.props(stickyActionFooterSideStyle()).className);
+ expectStyleXClass(stylex.props(stickyActionFooterRightStyle()).className);
+ });
+
+ test("applies StyleX classes to shared primitive consumers", () => {
+ const button = renderIntoContainer(
+ createElement(Button, { size: "sm" }, "Save")
+ );
+ const input = renderIntoContainer(createElement(Input, { size: "sm" }));
+ const segmentedControl = renderIntoContainer(
+ createElement(SegmentedControl, {
+ ariaLabel: "Mode",
+ value: "schema",
+ onValueChange: () => undefined,
+ size: "lg",
+ options: [
+ { value: "schema", label: "Schema" },
+ { value: "data", label: "Data" },
+ ],
+ })
+ );
+ const select = renderIntoContainer(
+ createElement(
+ Select,
+ null,
+ createElement(SelectTrigger, { size: "lg" }, "Role")
+ )
+ );
+ const numberInput = renderIntoContainer(
+ createElement(NumberInput, {
+ value: null,
+ onValueChange: () => undefined,
+ size: "lg",
+ })
+ );
+ const textarea = renderIntoContainer(
+ createElement(Textarea, { size: "lg" })
+ );
+ const formMessage = renderIntoContainer(
+ createElement(FormMessage, null, "Title is required.")
+ );
+ const controlGroup = renderIntoContainer(
+ createElement(
+ FormControlGroup,
+ null,
+ createElement(FormControlRow, null, createElement(Input))
+ )
+ );
+ const fieldGroup = renderIntoContainer(
+ createElement(
+ FormFieldGroup,
+ null,
+ createElement(
+ FormFieldRow,
+ null,
+ createElement(FormLabel, null, "Environment"),
+ createElement(Input)
+ )
+ )
+ );
+ const inlineAffix = renderIntoContainer(
+ createElement(
+ FormInlineAffix,
+ null,
+ createElement(Input),
+ createElement(FormControlAffix, null, "@"),
+ createElement(FormControlAffix, null, "example.com")
+ )
+ );
+
+ expectClasses(
+ button.container.querySelector("button")?.className,
+ "h-7 px-2 text-xs leading-4 gap-1"
+ );
+ expectClasses(
+ input.container.querySelector("input")?.className,
+ stylex.props(controlSizeStyle("sm")).className ?? ""
+ );
+ expectClasses(
+ segmentedControl.container.querySelector("label")?.className,
+ stylex.props(controlMinHeightStyle("lg")).className ?? ""
+ );
+ expectClasses(
+ select.container.querySelector("button")?.className,
+ stylex.props(controlSizeStyle("lg")).className ?? ""
+ );
+ expectClasses(
+ numberInput.container.querySelector("input")?.className,
+ stylex.props(controlSizeStyle("lg", { paddingInline: false }))
+ .className ?? ""
+ );
+ expectClasses(
+ numberInput.container.querySelector("input")?.className,
+ "px-4"
+ );
+ expectClasses(
+ textarea.container.querySelector("textarea")?.className,
+ stylex.props(controlMultilineSizeStyle("lg")).className ?? ""
+ );
+ expectClasses(
+ formMessage.container.querySelector('[data-slot="form-message"]')
+ ?.className,
+ stylex.props(formMessageStyle()).className ?? ""
+ );
+ expectClasses(
+ controlGroup.container.querySelector('[data-slot="form-control-group"]')
+ ?.className,
+ stylex.props(formControlGroupStyle()).className ?? ""
+ );
+ expectClasses(
+ controlGroup.container.querySelector('[data-slot="form-control-row"]')
+ ?.className,
+ stylex.props(formControlRowStyle()).className ?? ""
+ );
+ expectClasses(
+ fieldGroup.container.querySelector('[data-slot="form-field-group"]')
+ ?.className,
+ stylex.props(formFieldGroupStyle()).className ?? ""
+ );
+ expectClasses(
+ fieldGroup.container.querySelector('[data-slot="form-field-row"]')
+ ?.className,
+ stylex.props(formFieldRowStyle()).className ?? ""
+ );
+ expectClasses(
+ inlineAffix.container.querySelector('[data-slot="form-inline-affix"]')
+ ?.className,
+ stylex.props(formInlineAffixStyle()).className ?? ""
+ );
+ expectClasses(
+ inlineAffix.container.querySelector('[data-slot="form-control-affix"]')
+ ?.className,
+ stylex.props(formControlAffixStyle()).className ?? ""
+ );
+
+ button.unmount();
+ input.unmount();
+ segmentedControl.unmount();
+ select.unmount();
+ numberInput.unmount();
+ textarea.unmount();
+ formMessage.unmount();
+ controlGroup.unmount();
+ fieldGroup.unmount();
+ inlineAffix.unmount();
+ });
+
+ test("applies shared menu row contract to combobox option rows", () => {
+ const combobox = renderIntoContainer(
+ createElement(Combobox, {
+ value: "alpha",
+ onChange: () => undefined,
+ options: [
+ { value: "alpha", label: "Alpha" },
+ { value: "disabled", label: "Disabled", disabled: true },
+ ],
+ })
+ );
+
+ const trigger = combobox.container.firstElementChild?.firstElementChild;
+ expect(trigger).not.toBeNull();
+
+ act(() => {
+ trigger?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ });
+
+ const option = Array.from(
+ combobox.container.querySelectorAll("button")
+ ).find((button) => button.textContent?.includes("Alpha"));
+ expect(option).not.toBeUndefined();
+ expectClasses(
+ option?.className,
+ stylex.props(menuRowStyle("sm")).className ?? ""
+ );
+ expectClasses(option?.className, menuRowStateClassName);
+ expect(option?.getAttribute("data-selected")).toBe("true");
+
+ const disabledOption = Array.from(
+ combobox.container.querySelectorAll("button")
+ ).find((button) => button.textContent?.includes("Disabled"));
+ expect(disabledOption?.disabled).toBe(true);
+ expectClasses(disabledOption?.className, menuRowStateClassName);
+
+ combobox.unmount();
+ });
+
+ test("applies StyleX classes to shared form primitives", () => {
+ const form = renderIntoContainer(
+ createElement(
+ FormField,
+ null,
+ createElement(FormLabel, null, "Project"),
+ createElement(FormDescription, null, "Select a project."),
+ createElement(FormError, null, "Project is required.")
+ )
+ );
+
+ expectClasses(
+ form.container.firstElementChild?.className,
+ stylex.props(formFieldStyle()).className ?? ""
+ );
+ expectClasses(
+ form.container.querySelector("label")?.className,
+ stylex.props(formLabelStyle()).className ?? ""
+ );
+ expectClasses(
+ form.container.querySelector("[data-slot='form-description']")?.className,
+ stylex.props(formDescriptionStyle()).className ?? ""
+ );
+ expectClasses(
+ form.container.querySelector("[data-slot='form-error']")?.className,
+ stylex.props(formErrorStyle()).className ?? ""
+ );
+
+ form.unmount();
+ });
+});
diff --git a/frontend/src/react/components/ui/styles.stylex.ts b/frontend/src/react/components/ui/styles.stylex.ts
new file mode 100644
index 0000000000..7182826382
--- /dev/null
+++ b/frontend/src/react/components/ui/styles.stylex.ts
@@ -0,0 +1,410 @@
+import * as stylex from "@stylexjs/stylex";
+
+export const controlSize = {
+ xs: {
+ height: 24,
+ minHeight: 24,
+ paddingInline: 6,
+ paddingBlock: 4,
+ fontSize: 12,
+ lineHeight: "16px",
+ gap: 6,
+ iconSize: 14,
+ },
+ sm: {
+ height: 28,
+ minHeight: 28,
+ paddingInline: 8,
+ paddingBlock: 6,
+ fontSize: 12,
+ lineHeight: "16px",
+ gap: 6,
+ iconSize: 16,
+ },
+ md: {
+ height: 36,
+ minHeight: 36,
+ paddingInline: 12,
+ paddingBlock: 8,
+ fontSize: 14,
+ lineHeight: "20px",
+ gap: 8,
+ iconSize: 16,
+ },
+ lg: {
+ height: 40,
+ minHeight: 40,
+ paddingInline: 16,
+ paddingBlock: 8,
+ fontSize: 14,
+ lineHeight: "20px",
+ gap: 8,
+ iconSize: 20,
+ },
+} as const;
+
+export type ControlSize = keyof typeof controlSize;
+
+interface ControlSizeOptions {
+ gap?: boolean;
+ paddingInline?: boolean;
+}
+
+const controlHeightStyles = stylex.create({
+ xs: {
+ height: 24,
+ },
+ sm: {
+ height: 28,
+ },
+ md: {
+ height: 36,
+ },
+ lg: {
+ height: 40,
+ },
+});
+
+const controlMinHeightStyles = stylex.create({
+ xs: {
+ minHeight: 24,
+ },
+ sm: {
+ minHeight: 28,
+ },
+ md: {
+ minHeight: 36,
+ },
+ lg: {
+ minHeight: 40,
+ },
+});
+
+const controlPaddingInlineStyles = stylex.create({
+ xs: {
+ paddingInline: 6,
+ },
+ sm: {
+ paddingInline: 8,
+ },
+ md: {
+ paddingInline: 12,
+ },
+ lg: {
+ paddingInline: 16,
+ },
+});
+
+const controlTextStyles = stylex.create({
+ xs: {
+ fontSize: 12,
+ lineHeight: "16px",
+ },
+ sm: {
+ fontSize: 12,
+ lineHeight: "16px",
+ },
+ md: {
+ fontSize: 14,
+ lineHeight: "20px",
+ },
+ lg: {
+ fontSize: 14,
+ lineHeight: "20px",
+ },
+});
+
+const controlGapStyles = stylex.create({
+ xs: {
+ columnGap: 6,
+ },
+ sm: {
+ columnGap: 6,
+ },
+ md: {
+ columnGap: 8,
+ },
+ lg: {
+ columnGap: 8,
+ },
+});
+
+const buttonGapStyles = stylex.create({
+ xs: {
+ columnGap: 4,
+ },
+ sm: {
+ columnGap: 4,
+ },
+ md: {
+ columnGap: 6,
+ },
+ lg: {
+ columnGap: 6,
+ },
+});
+
+const controlMultilinePaddingStyles = stylex.create({
+ xs: {
+ paddingBlock: 4,
+ paddingInline: 6,
+ },
+ sm: {
+ paddingBlock: 6,
+ paddingInline: 8,
+ },
+ md: {
+ paddingBlock: 8,
+ paddingInline: 12,
+ },
+ lg: {
+ paddingBlock: 8,
+ paddingInline: 16,
+ },
+});
+
+export function controlSizeStyle(
+ size: ControlSize,
+ { gap, paddingInline = true }: ControlSizeOptions = {}
+) {
+ return [
+ controlHeightStyles[size],
+ paddingInline && controlPaddingInlineStyles[size],
+ controlTextStyles[size],
+ gap && controlGapStyles[size],
+ ];
+}
+
+export function buttonGapStyle(size: ControlSize) {
+ return buttonGapStyles[size];
+}
+
+export function controlMinHeightStyle(
+ size: ControlSize,
+ { gap, paddingInline = true }: ControlSizeOptions = {}
+) {
+ return [
+ controlMinHeightStyles[size],
+ paddingInline && controlPaddingInlineStyles[size],
+ controlTextStyles[size],
+ gap && controlGapStyles[size],
+ ];
+}
+
+export function controlMultilineSizeStyle(size: ControlSize) {
+ return [controlMultilinePaddingStyles[size], controlTextStyles[size]];
+}
+
+const formStyles = stylex.create({
+ affix: {
+ color: "rgb(var(--color-control-light))",
+ flexShrink: 0,
+ fontSize: 14,
+ lineHeight: "20px",
+ whiteSpace: "nowrap",
+ },
+ controlGroup: {
+ display: "flex",
+ flexDirection: "column",
+ rowGap: 8,
+ },
+ controlRow: {
+ alignItems: "center",
+ columnGap: 8,
+ display: "flex",
+ width: "100%",
+ },
+ field: {
+ display: "flex",
+ flexDirection: "column",
+ rowGap: 6,
+ },
+ fieldGroup: {
+ display: "flex",
+ flexDirection: "column",
+ rowGap: 24,
+ },
+ fieldRow: {
+ alignItems: "center",
+ columnGap: 16,
+ display: "grid",
+ gridTemplateColumns: "minmax(10rem, 14rem) minmax(0, 1fr)",
+ },
+ inlineAffix: {
+ alignItems: "center",
+ columnGap: 4,
+ display: "flex",
+ minWidth: 0,
+ width: "100%",
+ },
+ label: {
+ alignItems: "center",
+ color: "rgb(var(--color-control))",
+ columnGap: 4,
+ display: "inline-flex",
+ fontSize: 14,
+ fontWeight: 500,
+ lineHeight: "20px",
+ },
+ description: {
+ color: "rgb(var(--color-control-light))",
+ fontSize: 12,
+ lineHeight: "16px",
+ },
+ error: {
+ color: "rgb(var(--color-error))",
+ fontSize: 12,
+ lineHeight: "16px",
+ },
+});
+
+export function formFieldStyle() {
+ return formStyles.field;
+}
+
+export function formLabelStyle() {
+ return formStyles.label;
+}
+
+export function formDescriptionStyle() {
+ return formStyles.description;
+}
+
+export function formErrorStyle() {
+ return formStyles.error;
+}
+
+export function formMessageStyle() {
+ return formStyles.error;
+}
+
+export function formControlGroupStyle() {
+ return formStyles.controlGroup;
+}
+
+export function formControlRowStyle() {
+ return formStyles.controlRow;
+}
+
+export function formFieldGroupStyle() {
+ return formStyles.fieldGroup;
+}
+
+export function formFieldRowStyle() {
+ return formStyles.fieldRow;
+}
+
+export function formInlineAffixStyle() {
+ return formStyles.inlineAffix;
+}
+
+export function formControlAffixStyle() {
+ return formStyles.affix;
+}
+
+const stickyActionFooterStyles = stylex.create({
+ root: {
+ alignItems: "center",
+ display: "flex",
+ justifyContent: "space-between",
+ },
+ side: {
+ alignItems: "center",
+ display: "flex",
+ },
+ right: {
+ columnGap: 8,
+ },
+});
+
+export function stickyActionFooterStyle() {
+ return stickyActionFooterStyles.root;
+}
+
+export function stickyActionFooterSideStyle() {
+ return stickyActionFooterStyles.side;
+}
+
+export function stickyActionFooterRightStyle() {
+ return stickyActionFooterStyles.right;
+}
+
+const rowBaseStyles = stylex.create({
+ base: {
+ alignItems: "center",
+ color: "rgb(var(--color-control))",
+ cursor: "pointer",
+ display: "flex",
+ lineHeight: "20px",
+ minWidth: 0,
+ position: "relative",
+ textAlign: "start",
+ transitionDuration: "150ms",
+ transitionProperty:
+ "color, background-color, border-color, text-decoration-color, fill, stroke",
+ transitionTimingFunction: "cubic-bezier(0.4, 0, 0.2, 1)",
+ userSelect: "none",
+ width: "100%",
+ ":disabled": {
+ cursor: "not-allowed",
+ opacity: 0.5,
+ },
+ ":focus": {
+ backgroundColor: "rgb(var(--color-control-bg))",
+ outlineStyle: "none",
+ },
+ ":hover": {
+ backgroundColor: "rgb(var(--color-control-bg))",
+ },
+ },
+});
+
+export const menuRowStateClassName = [
+ "data-highlighted:bg-control-bg",
+ "data-selected:bg-accent/5",
+ "aria-selected:bg-accent/5",
+ "disabled:pointer-events-none",
+ "disabled:opacity-50",
+ "aria-disabled:pointer-events-none",
+ "aria-disabled:opacity-50",
+ "data-disabled:pointer-events-none",
+ "data-disabled:opacity-50",
+].join(" ");
+
+const rowSizeStyles = stylex.create({
+ sm: {
+ columnGap: 8,
+ fontSize: 14,
+ minHeight: 32,
+ paddingBlock: 6,
+ paddingInline: 8,
+ },
+ md: {
+ columnGap: 8,
+ fontSize: 14,
+ minHeight: 36,
+ paddingBlock: 8,
+ paddingInline: 12,
+ },
+});
+
+const listRowStyles = stylex.create({
+ base: {
+ textAlign: "start",
+ width: "100%",
+ },
+});
+
+export type RowSize = keyof typeof rowSizeStyles;
+
+export function menuRowStyle(size: RowSize = "sm") {
+ return [rowBaseStyles.base, rowSizeStyles[size]];
+}
+
+export function listRowStyle(size: RowSize = "sm") {
+ return [rowBaseStyles.base, rowSizeStyles[size], listRowStyles.base];
+}
+
+export function interactiveRowStyle(size: RowSize = "sm") {
+ return listRowStyle(size);
+}
diff --git a/frontend/src/react/components/ui/textarea.tsx b/frontend/src/react/components/ui/textarea.tsx
index bae302140c..a40ec35814 100644
--- a/frontend/src/react/components/ui/textarea.tsx
+++ b/frontend/src/react/components/ui/textarea.tsx
@@ -1,6 +1,8 @@
-import { cva, type VariantProps } from "class-variance-authority";
+import * as stylex from "@stylexjs/stylex";
+import { cva } from "class-variance-authority";
import type { ComponentProps } from "react";
import { cn } from "@/react/lib/utils";
+import { type ControlSize, controlMultilineSizeStyle } from "./styles.stylex";
const textareaVariants = cva(
cn(
@@ -8,31 +10,27 @@ const textareaVariants = cva(
"placeholder:text-control-placeholder",
"focus:outline-hidden focus:ring-1 focus:ring-accent focus:border-accent",
"disabled:cursor-not-allowed disabled:bg-control-bg disabled:opacity-50"
- ),
- {
- variants: {
- size: {
- xs: "px-2 py-1 text-xs leading-4",
- sm: "px-2 py-1.5 text-xs leading-4",
- md: "px-3 py-2 text-sm leading-5",
- lg: "px-4 py-2 text-sm leading-5",
- },
- },
- defaultVariants: {
- size: "md",
- },
- }
+ )
);
-type TextareaProps = Omit<ComponentProps<"textarea">, "size"> &
- VariantProps<typeof textareaVariants>;
+type TextareaProps = Omit<ComponentProps<"textarea">, "size"> & {
+ size?: ControlSize;
+};
-function Textarea({ className, size, ref, ...props }: TextareaProps) {
+function Textarea({
+ className,
+ size = "md",
+ ref,
+ style,
+ ...props
+}: TextareaProps) {
+ const stylexProps = stylex.props(controlMultilineSizeStyle(size));
return (
<textarea
- ref={ref}
- className={cn(textareaVariants({ size }), className)}
{...props}
+ ref={ref}
+ className={cn(textareaVariants(), stylexProps.className, className)}
+ style={{ ...stylexProps.style, ...style }}
/>
);
}
diff --git a/frontend/src/stylex-dev-css.ts b/frontend/src/stylex-dev-css.ts
new file mode 100644
index 0000000000..6491a83ad4
--- /dev/null
+++ b/frontend/src/stylex-dev-css.ts
@@ -0,0 +1,20 @@
+const STYLEX_DEV_CSS_ID = "__bytebase_stylex_dev_css__";
+const STYLEX_DEV_CSS_PATH = "/virtual:stylex.css";
+
+function installStyleXDevCSS() {
+ if (!import.meta.env.DEV) {
+ return;
+ }
+
+ if (!document.getElementById(STYLEX_DEV_CSS_ID)) {
+ const link = document.createElement("link");
+ link.id = STYLEX_DEV_CSS_ID;
+ link.rel = "stylesheet";
+ link.href = STYLEX_DEV_CSS_PATH;
+ document.head.appendChild(link);
+ }
+
+ void import("virtual:stylex:css-only");
+}
+
+installStyleXDevCSS();
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 2c7813a4f3..30e1b2e8a7 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -1,6 +1,7 @@
import { fileURLToPath, URL } from "node:url";
import { transform as esbuildTransform } from "esbuild";
import yaml from "@rollup/plugin-yaml";
+import stylex from "@stylexjs/unplugin";
import tailwindcss from "@tailwindcss/vite";
import legacy from "@vitejs/plugin-legacy";
import { CodeInspectorPlugin } from "code-inspector-plugin";
@@ -43,6 +44,13 @@ export default defineConfig({
return { code: result.code, map: result.map || null };
},
},
+ stylex.vite({
+ // Avoid the plugin's dev HTML injection: it inserts StyleX layers before
+ // Tailwind, letting Preflight override control typography and padding.
+ devMode: "css-only",
+ runtimeInjection: false,
+ useCSSLayers: true,
+ }),
tailwindcss(),
yaml(),
...(process.env.VITEST