Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📐 feat: Size Roles for the Shared Primitives (#16617)
Marco Beretta7baa8148682a
diff --git a/client/src/Providers/__tests__/DeploymentTheme.spec.tsx b/client/src/Providers/__tests__/DeploymentTheme.spec.tsxindex d18d9f3efa..ffb74ee833 100644--- a/client/src/Providers/__tests__/DeploymentTheme.spec.tsx+++ b/client/src/Providers/__tests__/DeploymentTheme.spec.tsx@@ -170,7 +170,7 @@ describe('DeploymentTheme', () => {...inlineTheme.modes,light: {...inlineTheme.modes.light,- appearance: { controlRadius: '2px', futureSpacing: '3rem' },+ appearance: { controlRadius: '2px', futureSpacing: '3.3125rem' },},},});@@ -179,7 +179,7 @@ describe('DeploymentTheme', () => {await waitFor(() => expect(root().dataset.theme).toBe('acme'));expect(root().style.getPropertyValue('--surface-primary')).toBe('10 20 30');expect(root().style.getPropertyValue('--theme-control-radius')).toBe('2px');- expect(root().getAttribute('style')).not.toContain('3rem');+ expect(root().getAttribute('style')).not.toContain('3.3125rem');expect(warn).toHaveBeenCalledWith('[ThemeProvider] Unknown light appearance token ignored: futureSpacing',);diff --git a/client/src/components/Bookmarks/BookmarkForm.tsx b/client/src/components/Bookmarks/BookmarkForm.tsxindex d94ba4de9b..319e1bc234 100644--- a/client/src/components/Bookmarks/BookmarkForm.tsx+++ b/client/src/components/Bookmarks/BookmarkForm.tsx@@ -162,7 +162,7 @@ const BookmarkForm = ({{...field}checked={field.value}onCheckedChange={field.onChange}- className="size-4 cursor-pointer"+ className="cursor-pointer"value={field.value?.toString()}aria-label={localize('com_ui_bookmarks_add_to_conversation')}/>diff --git a/client/src/components/Nav/SettingsTabs/Account/Passkeys/PasskeyItem.tsx b/client/src/components/Nav/SettingsTabs/Account/Passkeys/PasskeyItem.tsxindex d4c43e56fb..3c36dde9e8 100644--- a/client/src/components/Nav/SettingsTabs/Account/Passkeys/PasskeyItem.tsx+++ b/client/src/components/Nav/SettingsTabs/Account/Passkeys/PasskeyItem.tsx@@ -186,7 +186,7 @@ function PasskeyItem({onChange={(event) => setDraftName(event.target.value)}onKeyDown={onRenameKeyDown}aria-label={localize('com_ui_passkey_name')}- className="h-10"+ variant="inline"/><TooltipAnchordescription={localize('com_ui_save')}diff --git a/client/src/components/Nav/SettingsTabs/Account/Passkeys/__tests__/PasskeyItem.spec.tsx b/client/src/components/Nav/SettingsTabs/Account/Passkeys/__tests__/PasskeyItem.spec.tsxindex 54ad6081ee..9a3d62e862 100644--- a/client/src/components/Nav/SettingsTabs/Account/Passkeys/__tests__/PasskeyItem.spec.tsx+++ b/client/src/components/Nav/SettingsTabs/Account/Passkeys/__tests__/PasskeyItem.spec.tsx@@ -53,10 +53,13 @@ describe('PasskeyItem rename controls', () => {const saveButton = screen.getByRole('button', { name: 'Save' });const cancelButton = screen.getByRole('button', { name: 'Cancel' });- expect(input).toHaveClass('h-10');+ /** The field takes the buttons' height role, so a theme whose field and button heights+ * differ still draws one row height. */+ expect(input).toHaveClass('h-theme-button');+ expect(input).not.toHaveClass('h-theme-field');expect(input.parentElement?.parentElement).toHaveClass('py-2');- expect(saveButton).toHaveClass('size-10');- expect(cancelButton).toHaveClass('size-10');+ expect(saveButton).toHaveClass('size-theme-button');+ expect(cancelButton).toHaveClass('size-theme-button');expect(cancelButton).toHaveClass('bg-surface-secondary');});diff --git a/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx b/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsxindex e821105410..ec2a08358a 100644--- a/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx+++ b/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx@@ -39,14 +39,17 @@ export default function AdvancedPanel() {size="icon"onClick={() => setActivePanel(Panel.builder)}aria-label={localize('com_ui_back_to_builder')}- className="border-border-light text-text-secondary hover:bg-surface-secondary hover:text-text-primary focus-visible:ring-text-primary h-10 w-10 shrink-0 rounded-xl border focus-visible:ring-2"+ className="border-border-light text-text-secondary hover:bg-surface-secondary hover:text-text-primary focus-visible:ring-text-primary shrink-0 rounded-xl border focus-visible:ring-2"><ChevronLeft className="h-5 w-5" strokeWidth={1.75} aria-hidden="true" /></Button><h2 className="text-text-primary text-center text-base font-semibold">{localize('com_ui_advanced_settings')}</h2>- <span aria-hidden="true" className="h-10 w-10" />+ <span+ aria-hidden="true"+ className="size-theme-button min-h-theme-target min-w-theme-target"+ /></header><div className="flex flex-col gap-5 px-2 pb-2">diff --git a/client/src/components/SidePanel/Agents/ImageVision.tsx b/client/src/components/SidePanel/Agents/ImageVision.tsxindex 68f735bd6d..fb7710f74b 100644--- a/client/src/components/SidePanel/Agents/ImageVision.tsx+++ b/client/src/components/SidePanel/Agents/ImageVision.tsx@@ -19,7 +19,7 @@ export default function ImageVision() {{...field}checked={field.value}onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={field.value?.toString()}aria-labelledby="image-vision-label"/>diff --git a/client/src/components/SidePanel/Agents/ModelPanel.tsx b/client/src/components/SidePanel/Agents/ModelPanel.tsxindex 28627f1ea6..a86ed63f67 100644--- a/client/src/components/SidePanel/Agents/ModelPanel.tsx+++ b/client/src/components/SidePanel/Agents/ModelPanel.tsx@@ -122,14 +122,17 @@ export default function ModelPanel({size="icon"onClick={() => setActivePanel(Panel.builder)}aria-label={localize('com_ui_back_to_builder')}- className="text-text-secondary hover:bg-surface-secondary hover:text-text-primary h-10 w-10 shrink-0 rounded-xl"+ className="text-text-secondary hover:bg-surface-secondary hover:text-text-primary shrink-0 rounded-xl"><ChevronLeft className="h-5 w-5" strokeWidth={1.75} aria-hidden="true" /></Button><h2 className="text-text-primary text-center text-base font-semibold">{localize('com_ui_model_parameters')}</h2>- <span aria-hidden="true" className="h-10 w-10" />+ <span+ aria-hidden="true"+ className="size-theme-button min-h-theme-target min-w-theme-target"+ /></header><div>{/* Endpoint aka Provider for Agents */}diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsxindex 05a0c24554..5e0a4a7a99 100644--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx@@ -59,7 +59,7 @@ function ArtifactsConfig({ value, onChange }: ArtifactsConfigProps) {return (<div className="flex flex-col gap-3">- <span id="artifacts-mode-label" className="text-sm font-medium text-text-primary">+ <span id="artifacts-mode-label" className="text-text-primary text-sm font-medium">{localize('com_ui_artifacts_mode')}</span><Radio@@ -70,7 +70,7 @@ function ArtifactsConfig({ value, onChange }: ArtifactsConfigProps) {aria-labelledby="artifacts-mode-label"/>{active?.infoKey ? (- <p className="text-sm leading-relaxed text-text-secondary">{localize(active.infoKey)}</p>+ <p className="text-text-secondary text-sm leading-relaxed">{localize(active.infoKey)}</p>) : null}</div>);@@ -94,19 +94,19 @@ function MemoryConfig({ value, onChange }: MemoryConfigProps) {onCheckedChange={(checked) =>onChange(checked === true ? MemoryScope.agent : MemoryScope.user)}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={isolated.toString()}aria-labelledby="memory-scope-label"/><labelid="memory-scope-label"htmlFor="memory-scope-checkbox"- className="cursor-pointer text-sm font-medium text-text-primary"+ className="text-text-primary cursor-pointer text-sm font-medium">{localize('com_agents_memory_scope')}</label></div>- <p className="text-sm leading-relaxed text-text-secondary">+ <p className="text-text-secondary text-sm leading-relaxed">{localize('com_agents_memory_scope_info')}</p></div>@@ -177,7 +177,7 @@ export default function BuiltinSection({return (<div className="flex flex-col gap-5">{localizedDescription && (- <p className="text-sm leading-relaxed text-text-secondary">{localizedDescription}</p>+ <p className="text-text-secondary text-sm leading-relaxed">{localizedDescription}</p>)}{body}</div>diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/McpSection.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/McpSection.tsxindex 44796ed4c7..31006dd325 100644--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/McpSection.tsx+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/McpSection.tsx@@ -557,7 +557,7 @@ export default function McpSection({ item }: Props) {? localize('com_ui_tools_mcp_deselect_all'): localize('com_ui_tools_mcp_select_all')}- className="border-border-medium size-4 rounded border"+ className="border-border-medium rounded border"/><span>{(hasTools ? allSelected : isWildcardAttached)diff --git a/client/src/components/SidePanel/Agents/Version/VersionPanel.tsx b/client/src/components/SidePanel/Agents/Version/VersionPanel.tsxindex e4ffdceded..fc5db0ebea 100644--- a/client/src/components/SidePanel/Agents/Version/VersionPanel.tsx+++ b/client/src/components/SidePanel/Agents/Version/VersionPanel.tsx@@ -162,7 +162,10 @@ export default function VersionPanel() {</p>)}</div>- <span aria-hidden="true" className="h-10 w-10" />+ <span+ aria-hidden="true"+ className="size-theme-button min-h-theme-target min-w-theme-target"+ /></header><div className="flex flex-col px-2 pt-2"><VersionContentdiff --git a/client/src/components/SidePanel/Builder/AppendDateCheckbox.tsx b/client/src/components/SidePanel/Builder/AppendDateCheckbox.tsxindex 2bbc0c17d6..13fc4edb44 100644--- a/client/src/components/SidePanel/Builder/AppendDateCheckbox.tsx+++ b/client/src/components/SidePanel/Builder/AppendDateCheckbox.tsx@@ -39,7 +39,7 @@ export default function AppendDateCheckbox({ control, setValue }: AppendDateChecid="append_current_datetime"checked={field.value}onCheckedChange={handleChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={field.value.toString()}aria-labelledby="append-date-label"/>diff --git a/client/src/components/SidePanel/Builder/Code.tsx b/client/src/components/SidePanel/Builder/Code.tsxindex a7fa6d5021..7d4135e7e7 100644--- a/client/src/components/SidePanel/Builder/Code.tsx+++ b/client/src/components/SidePanel/Builder/Code.tsx@@ -29,7 +29,7 @@ export default function Code({ version }: { version: number | string }) {{...field}checked={field.value}onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={field.value.toString()}aria-labelledby={Capabilities.code_interpreter}/>diff --git a/client/src/components/SidePanel/Builder/ImageVision.tsx b/client/src/components/SidePanel/Builder/ImageVision.tsxindex fce9e92128..6e7f424494 100644--- a/client/src/components/SidePanel/Builder/ImageVision.tsx+++ b/client/src/components/SidePanel/Builder/ImageVision.tsx@@ -19,7 +19,7 @@ export default function ImageVision() {{...field}checked={field.value}onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={field.value.toString()}aria-labelledby={Capabilities.image_vision}/>diff --git a/client/src/components/SidePanel/Builder/Retrieval.tsx b/client/src/components/SidePanel/Builder/Retrieval.tsxindex 2be305272b..4b65bd1bda 100644--- a/client/src/components/SidePanel/Builder/Retrieval.tsx+++ b/client/src/components/SidePanel/Builder/Retrieval.tsx@@ -49,7 +49,7 @@ export default function Retrieval({checked={field.value}disabled={isDisabled}onCheckedChange={field.onChange}- className="relative float-left mr-2 inline-flex h-4 w-4 cursor-pointer"+ className="relative float-left mr-2 inline-flex cursor-pointer"value={field.value.toString()}aria-labelledby={Capabilities.retrieval}/>diff --git a/client/src/style.css b/client/src/style.cssindex 171ad486af..d193d4f3c4 100644--- a/client/src/style.css+++ b/client/src/style.css@@ -2109,7 +2109,7 @@ html[data-input-modality='keyboard']scroll-margin: 0.5rem;align-items: center;gap: 0.5rem;- border-radius: 0.5rem;+ border-radius: var(--theme-radius-lg, 0.5rem);padding: 0.5rem;outline: none !important;}diff --git a/e2e/specs/mock/scenarios/primitive-sizes.spec.ts b/e2e/specs/mock/scenarios/primitive-sizes.spec.tsnew file mode 100644index 0000000000..f7b8819412--- /dev/null+++ b/e2e/specs/mock/scenarios/primitive-sizes.spec.ts@@ -0,0 +1,164 @@+import { expect, test } from '@playwright/test';+import type { Page } from '@playwright/test';+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';+import { NEW_CHAT_PATH } from '../helpers';+import { probeStyle } from './style.helpers';++/**+ * The size roles the shared primitives draw with. The default theme keeps every size the+ * primitives drew as fixed utilities, in both modes; the ClickHouse theme takes Click UI's single+ * button size, its small icon button and its icon, checkbox and dialog close sizes.+ */++type Mode = 'light' | 'dark';++async function openChat(page: Page, mode: Mode, definition?: { name: string }) {+ await page.addInitScript(+ ([colorTheme, stored]) => {+ localStorage.setItem('color-theme', colorTheme as string);+ localStorage.removeItem('theme-colors');+ localStorage.removeItem('theme-name');+ if (stored) {+ localStorage.setItem('theme-definition', JSON.stringify(stored));+ localStorage.setItem('theme-source', 'definition');+ } else {+ localStorage.removeItem('theme-definition');+ localStorage.removeItem('theme-source');+ }+ },+ [mode, definition ?? null] as [string, unknown],+ );+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({+ timeout: 30000,+ });+ await expect(page.locator('html')).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);+ if (definition) {+ await expect(page.locator('html')).toHaveAttribute('data-theme', definition.name);+ }+}++async function sizes(page: Page): Promise<Record<string, string>> {+ const probes: Array<[string, string]> = [+ ['h-theme-button-xs', 'height'],+ ['h-theme-button-lg', 'height'],+ ['h-theme-button-compact', 'height'],+ ['size-theme-button', 'width'],+ ['size-theme-icon-button-sm', 'width'],+ ['size-theme-checkbox', 'width'],+ ['size-theme-icon', 'width'],+ ['size-theme-icon-lg', 'width'],+ ['h-theme-field-lg', 'height'],+ ['h-theme-field', 'height'],+ ['h-theme-target', 'height'],+ ['min-w-theme-target', 'min-width'],+ ['min-w-theme-tab', 'min-width'],+ ['select-item', 'border-top-left-radius'],+ ];+ const result: Record<string, string> = {};+ for (const [classes, property] of probes) {+ result[classes] = await probeStyle(page, classes, property);+ }+ return result;+}++/** Names an icon size apart from the default, so a size still drawn by a fixed utility shows, and+ * the retired `minTargetSize` role, which must not lower the fixed 24px target floor. */+const REFERENCE_SIZE_THEME = {+ version: 1,+ name: 'e2e-size-reference',+ modes: {+ light: { appearance: { iconSize: '1.25rem', minTargetSize: '1rem' } },+ dark: { appearance: { iconSize: '1.25rem', minTargetSize: '1rem' } },+ },+} as const;++const DEFAULT_SIZES = {+ 'h-theme-button-xs': '28px',+ 'h-theme-button-lg': '44px',+ 'h-theme-button-compact': '32px',+ 'size-theme-button': '40px',+ 'size-theme-icon-button-sm': '32px',+ 'size-theme-checkbox': '16px',+ 'size-theme-icon': '16px',+ 'size-theme-icon-lg': '24px',+ 'h-theme-field-lg': '48px',+ 'h-theme-field': '40px',+ 'h-theme-target': '24px',+ 'min-w-theme-target': '24px',+ 'min-w-theme-tab': '100px',+ 'select-item': '8px',+};++test.describe('primitive size roles', () => {+ test('the default theme keeps every primitive size in both modes @scenario:primitive-sizes-default-unchanged', async ({+ page,+ }) => {+ for (const mode of ['light', 'dark'] as const) {+ const modePage = mode === 'light' ? page : await page.context().newPage();+ await openChat(modePage, mode);++ const drawn = await sizes(modePage);+ expect(drawn).toEqual(DEFAULT_SIZES);+ /** A field and the icon buttons beside it (the passkey rename row) stay one height. */+ expect(drawn['h-theme-field']).toBe(drawn['size-theme-button']);+ }+ });++ test('the ClickHouse theme sizes buttons, icons and menu rows from Click UI @scenario:primitive-sizes-clickhouse', async ({+ page,+ }) => {+ for (const mode of ['light', 'dark'] as const) {+ const modePage = mode === 'light' ? page : await page.context().newPage();+ await openChat(modePage, mode, clickHouseTheme);++ const drawn = await sizes(modePage);+ expect(drawn['h-theme-field']).toBe(drawn['size-theme-button']);+ expect(drawn).toEqual({+ ...DEFAULT_SIZES,+ 'h-theme-button-lg': '32px',+ 'size-theme-button': '32px',+ 'size-theme-icon-button-sm': '24px',+ 'select-item': '4px',+ 'min-w-theme-tab': '0px',+ 'h-theme-field': '32px',+ });+ }+ });++ test('a theme resizes a menu glyph but cannot lower the 24px target floor @scenario:primitive-sizes-reference-theme', async ({+ page,+ }) => {+ await openChat(page, 'light', REFERENCE_SIZE_THEME);++ /** The menu row's icon slot, holding a glyph a caller sized itself, as the export menu does. */+ const glyph = await page.evaluate(() => {+ /** A menu row is a flex row, so the slot is sized like the one DropdownPopup renders. */+ const row = document.createElement('div');+ row.className = 'flex items-center';+ row.innerHTML = `<span class="size-theme-icon mr-2 [&>svg]:size-full"><svg class="size-4" viewBox="0 0 24 24"></svg></span>`;+ document.body.append(row);+ const width = getComputedStyle(row.querySelector('svg') as SVGElement).width;+ row.remove();+ return width;+ });+ expect(glyph).toBe('20px');++ /** A caller that sizes the slot itself, as the mobile panel switcher does, keeps its glyph. */+ const explicit = await page.evaluate(() => {+ /** A menu row is a flex row, so the slot is sized like the one DropdownPopup renders. */+ const row = document.createElement('div');+ row.className = 'flex items-center';+ row.innerHTML = `<span class="mr-2 size-5 [&>svg]:size-full"><svg class="size-5" viewBox="0 0 24 24"></svg></span>`;+ document.body.append(row);+ const width = getComputedStyle(row.querySelector('svg') as SVGElement).width;+ row.remove();+ return width;+ });+ expect(explicit).toBe('20px');+ /** WCAG 2.5.8's floor is fixed, so a theme naming a smaller target still draws 24px. */+ expect(await probeStyle(page, 'min-h-theme-target', 'min-height')).toBe('24px');+ expect(await probeStyle(page, 'min-w-theme-target', 'min-width')).toBe('24px');+ expect(await probeStyle(page, 'h-theme-target', 'height')).toBe('24px');+ });+});diff --git a/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts b/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.tsindex dc4aa9d8f4..7bfd3ec4a0 100644--- a/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts+++ b/e2e/specs/mock/scenarios/theme-unknown-appearance.spec.ts@@ -19,7 +19,10 @@ const withAppearance = (name: string, appearance: Record<string, unknown>) => ({},});-const NEWER_THEME = withAppearance('e2e-newer', { controlRadius: '2px', futureSpacing: '3rem' });+const NEWER_THEME = withAppearance('e2e-newer', {+ controlRadius: '2px',+ futureSpacing: '3.3125rem',+});async function storeTheme(page: Page, definition: Record<string, unknown>) {await page.addInitScript((theme) => {@@ -54,7 +57,7 @@ async function expectNewerThemeApplied(page: Page) {const dark = await page.evaluate(() => document.documentElement.classList.contains('dark'));expect(await themeValue(page, '--surface-primary')).toBe(dark ? '12 16 32' : '240 244 255');expect(await themeValue(page, '--theme-control-radius')).toBe('2px');- expect(await page.locator('html').getAttribute('style')).not.toContain('3rem');+ expect(await page.locator('html').getAttribute('style')).not.toContain('3.3125rem');}test.describe('appearance tokens this build does not know', () => {@@ -92,7 +95,7 @@ test.describe('appearance tokens this build does not know', () => {}) => {const theme = withAppearance('e2e-invalid-known', {controlRadius: 'huge',- futureSpacing: '3rem',+ futureSpacing: '3.3125rem',});await storeTheme(page, theme);diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsxindex 380bd6b914..7ac2abef9a 100644--- a/packages/client/src/components/Button.spec.tsx+++ b/packages/client/src/components/Button.spec.tsx@@ -31,7 +31,7 @@ describe('Button', () => {const button = screen.getByRole('button', { name: 'My agents' });expect(button).toHaveClass(- 'h-8',+ 'h-theme-button-compact','gap-1.5','px-2.5','text-xs',@@ -188,7 +188,12 @@ describe('Button', () => {const button = screen.getByRole('button', { name: 'Open' });- expect(button).toHaveClass('size-8', 'p-0', 'rounded-md', 'hover:bg-surface-hover-alt');+ expect(button).toHaveClass(+ 'size-theme-icon-button-sm',+ 'p-0',+ 'rounded-md',+ 'hover:bg-surface-hover-alt',+ );expect(button).not.toHaveClass('rounded-lg');});@@ -205,7 +210,7 @@ describe('Button', () => {);const button = screen.getByRole('button', { name: 'Filter' });- expect(button).toHaveClass('size-7', 'rounded-md', 'focus-visible:ring-inset');+ expect(button).toHaveClass('size-theme-button-xs', 'rounded-md', 'focus-visible:ring-inset');expect(button).not.toHaveClass('rounded-lg', 'focus-visible:ring-offset-2');});diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsxindex 53c8297f93..dbe0532718 100644--- a/packages/client/src/components/Button.tsx+++ b/packages/client/src/components/Button.tsx@@ -155,18 +155,18 @@ const buttonVariantRecipe = cva(/** Default-height actions with less horizontal padding, such as Copy link. */dense: 'h-theme-button px-3 py-2',/** Compact text controls that share a toolbar row with a compact dropdown. */- compact: 'h-8 gap-1.5 px-2.5 py-2 text-xs',+ compact: 'h-theme-button-compact gap-1.5 px-2.5 py-2 text-xs',/*** A chip, the text counterpart of `icon-xs`: the reset beside a list that* matched nothing, and anything else that offers a way out without asking* to be the thing the eye lands on.*/- xs: 'h-7 rounded-md px-2.5 text-xs',+ xs: 'h-theme-button-xs rounded-md px-2.5 text-xs',sm: 'h-theme-button-sm rounded-lg px-3',- lg: 'h-11 rounded-lg px-8',- icon: 'size-10',- 'icon-sm': 'size-8 p-0',- 'icon-xs': 'size-7',+ lg: 'h-theme-button-lg rounded-lg px-8',+ icon: 'size-theme-button',+ 'icon-sm': 'size-theme-icon-button-sm p-0',+ 'icon-xs': 'size-theme-button-xs',/*** A square icon control on the theme's control height — the size of* every button in the composer's action row, for a control that has to@@ -194,8 +194,8 @@ const buttonVariantRecipe = cva(},/* A section heading is sized by its own text, so it opts out of the* default size recipe that every other caller supplies explicitly.- * Without this the default `h-10 px-4` is emitted after the variant and- * wins the merge, giving a 40px control in a 32px header row. */+ * Without this the default size's height and padding are emitted after the variant and+ * win the merge, giving a 40px control in a 32px header row. */{variant: 'section-header',size: 'default',diff --git a/packages/client/src/components/Checkbox.tsx b/packages/client/src/components/Checkbox.tsxindex f26f44d7d3..53e080904a 100644--- a/packages/client/src/components/Checkbox.tsx+++ b/packages/client/src/components/Checkbox.tsx@@ -27,14 +27,14 @@ const Checkbox: React.ForwardRefExoticComponent<<CheckboxPrimitive.Rootref={ref}className={cn(- 'peer border-border-xheavy ring-offset-surface-primary focus-visible:ring-focus-control data-[state=checked]:bg-surface-inverted data-[state=checked]:text-text-inverted h-4 w-4 shrink-0 rounded-sm border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',+ 'peer border-border-xheavy ring-offset-surface-primary focus-visible:ring-focus-control data-[state=checked]:bg-surface-inverted data-[state=checked]:text-text-inverted size-theme-checkbox shrink-0 rounded-sm border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',disabledFillClasses,className,)}{...props}><CheckboxPrimitive.Indicator className={cn('flex items-center justify-center')}>- <Check className="h-4 w-4" />+ <Check className="size-theme-checkbox" /></CheckboxPrimitive.Indicator></CheckboxPrimitive.Root>),@@ -55,12 +55,12 @@ const CheckboxGlyph: React.FC<{ checked: boolean; className?: string }> = ({<spanaria-hidden="true"className={cn(- 'border-border-xheavy flex h-4 w-4 shrink-0 items-center justify-center rounded-sm border',+ 'border-border-xheavy size-theme-checkbox flex shrink-0 items-center justify-center rounded-sm border',checked && 'bg-surface-inverted text-text-inverted',className,)}>- {checked && <Check className="h-4 w-4" />}+ {checked && <Check className="size-theme-checkbox" />}</span>);CheckboxGlyph.displayName = 'CheckboxGlyph';diff --git a/packages/client/src/components/Combobox.tsx b/packages/client/src/components/Combobox.tsxindex aa1b1b9c35..7bd1ddac78 100644--- a/packages/client/src/components/Combobox.tsx+++ b/packages/client/src/components/Combobox.tsx@@ -80,9 +80,9 @@ export default function ComboboxComponent({<SelectTriggeraria-label={ariaLabel}className={cn(- 'flex items-center gap-2 [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0 [&>span]:line-clamp-1 [&>span]:flex [&>span]:w-full [&>span]:items-center [&>span]:gap-1 [&>span]:truncate',+ '[&_svg]:size-theme-icon flex items-center gap-2 [&_svg]:shrink-0 [&>span]:line-clamp-1 [&>span]:flex [&>span]:w-full [&>span]:items-center [&>span]:gap-1 [&>span]:truncate',isCollapsed- ? 'flex h-9 w-9 shrink-0 items-center justify-center p-0 [&>span]:w-auto [&>svg]:hidden'+ ? 'size-theme-control min-h-theme-target min-w-theme-target flex shrink-0 items-center justify-center p-0 [&>span]:w-auto [&>svg]:hidden': '','bg-surface-secondary text-text-primary hover:bg-surface-hover focus-visible:ring-focus-control focus-visible:ring-2',)}@@ -156,11 +156,11 @@ export default function ComboboxComponent({><span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center"><RadixSelect.ItemIndicator>- <CheckIcon className="h-4 w-4" />+ <CheckIcon className="size-theme-icon" /></RadixSelect.ItemIndicator></span><RadixSelect.ItemText>- <div className="[&_svg]:text-text-primary flex items-center justify-center gap-3 [&_svg]:h-4 [&_svg]:w-4 [&_svg]:shrink-0">+ <div className="[&_svg]:text-text-primary [&_svg]:size-theme-icon flex items-center justify-center gap-3 [&_svg]:shrink-0"><div className="assistant-item overflow-hidden rounded-full">{icon && icon}</div>diff --git a/packages/client/src/components/Dialog.tsx b/packages/client/src/components/Dialog.tsxindex 607445bfe0..d3c30df2ea 100644--- a/packages/client/src/components/Dialog.tsx+++ b/packages/client/src/components/Dialog.tsx@@ -74,7 +74,7 @@ const DialogContent: React.ForwardRefExoticComponent<{children}{showCloseButton && (<DialogPrimitive.Close className="focus:ring-focus-control data-[state=open]:bg-surface-hover absolute top-[1.6rem] right-6 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">- <X className="text-text-primary h-5 w-5" aria-hidden="true" />+ <X className="text-text-primary size-theme-icon-md" aria-hidden="true" /><span className="sr-only">Close</span></DialogPrimitive.Close>)}@@ -144,7 +144,7 @@ const DialogClose: React.ForwardRefExoticComponent<<DialogPrimitive.Closeref={ref}className={cn(- 'border-border-light text-text-primary hover:bg-surface-hover mt-2 inline-flex h-10 items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',+ 'border-border-light text-text-primary hover:bg-surface-hover h-theme-button mt-2 inline-flex items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',disabledFillClasses,className ?? '',/* Important: for accessibility */@@ -166,7 +166,7 @@ const DialogButton: React.ForwardRefExoticComponent<ref={ref}variant="outline"className={cn(- 'border-border-light text-text-primary hover:bg-surface-hover focus:ring-focus-control mt-2 inline-flex h-10 items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',+ 'border-border-light text-text-primary hover:bg-surface-hover focus:ring-focus-control h-theme-button mt-2 inline-flex items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',disabledFillClasses,className ?? '',/* Important: for accessibility */diff --git a/packages/client/src/components/Dropdown.css b/packages/client/src/components/Dropdown.cssindex e427137c6d..acbe67ea0e 100644--- a/packages/client/src/components/Dropdown.css+++ b/packages/client/src/components/Dropdown.css@@ -69,7 +69,7 @@ html.high-contrast .popover-ui {scroll-margin: 0.5rem;align-items: center;gap: 0.5rem;- border-radius: 0.5rem;+ border-radius: var(--theme-radius-lg, 0.5rem);padding: 0.5rem;outline: none !important;}diff --git a/packages/client/src/components/Dropdown.spec.tsx b/packages/client/src/components/Dropdown.spec.tsxindex 32dcee22a2..ad967cb45e 100644--- a/packages/client/src/components/Dropdown.spec.tsx+++ b/packages/client/src/components/Dropdown.spec.tsx@@ -104,7 +104,7 @@ describe('Dropdown compact recipe', () => {const trigger = screen.getByRole('combobox', { name: 'Sort 12-hour' });expect(trigger).toHaveClass(- 'h-8',+ 'h-theme-button-compact','px-2.5','py-0','text-xs',@@ -137,3 +137,15 @@ describe('Dropdown ink', () => {expect(plain).not.toHaveClass('text-field-text');});});++describe('Dropdown icon-only trigger', () => {+ it('holds the square to the target minimum, like the icon Button', () => {+ render(<Dropdown value="24h" options={OPTIONS} ariaLabel="Clock" iconOnly />);++ expect(screen.getByRole('combobox')).toHaveClass(+ 'size-theme-button',+ 'min-h-theme-target',+ 'min-w-theme-target',+ );+ });+});diff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsxindex 7da6b4887d..2d4736fc85 100644--- a/packages/client/src/components/Dropdown.tsx+++ b/packages/client/src/components/Dropdown.tsx@@ -175,9 +175,11 @@ const Dropdown: React.FC<DropdownProps> = ({'disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent',disabledFillClasses,/** Horizontal padding would squeeze the icon, which flex-shrinks to fit */- iconOnly ? 'size-10 justify-center px-0' : 'w-fit gap-2 px-3',+ iconOnly+ ? 'size-theme-button min-h-theme-target min-w-theme-target justify-center px-0'+ : 'w-fit gap-2 px-3',variant === 'field' && fieldControl,- variant === 'compact' && 'h-8 px-2.5 py-0 text-xs transition-none',+ variant === 'compact' && 'h-theme-button-compact px-2.5 py-0 text-xs transition-none',triggerClassName,)}data-testid={testId}@@ -214,7 +216,7 @@ const Dropdown: React.FC<DropdownProps> = ({store={selectProps}className={cn(// `className` sizes the TRIGGER only (applied above on Select.Select).- // Forwarding it here too meant a caller's trigger height (e.g. `h-10`)+ // Forwarding it here too meant a caller's trigger height (a fixed height utility)// became the popover's height as well, clipping every option below the// first out of view. `sizeClasses` is the popover's own sizing prop; the// shared `.popover-ui` class already caps height to the viewport via@@ -229,7 +231,7 @@ const Dropdown: React.FC<DropdownProps> = ({<div className="sticky -top-2 z-10 -mx-2 -mt-2 mb-1 bg-inherit px-2 pt-2 pb-1.5"><div className="relative"><Search- className="text-text-tertiary pointer-events-none absolute top-1/2 left-2 h-4 w-4 -translate-y-1/2"+ className="text-text-tertiary size-theme-icon pointer-events-none absolute top-1/2 left-2 -translate-y-1/2"aria-hidden="true"/><Combobox.Comboboxdiff --git a/packages/client/src/components/DropdownPopup.tsx b/packages/client/src/components/DropdownPopup.tsxindex ab6dfd4ad5..da687a3bde 100644--- a/packages/client/src/components/DropdownPopup.tsx+++ b/packages/client/src/components/DropdownPopup.tsx@@ -124,7 +124,10 @@ const Menu: React.FC<MenuProps> = ({><span className="flex items-center gap-2">{item.icon != null && (- <span className={cn('mr-2 size-4', iconClassName)} aria-hidden="true">+ <span+ className={cn('size-theme-icon mr-2 [&>svg]:size-full', iconClassName)}+ aria-hidden="true"+ >{item.icon}</span>)}@@ -174,7 +177,10 @@ const Menu: React.FC<MenuProps> = ({}}>{item.icon != null && (- <span className={cn('mr-2 size-4', iconClassName)} aria-hidden="true">+ <span+ className={cn('size-theme-icon mr-2 [&>svg]:size-full', iconClassName)}+ aria-hidden="true"+ >{item.icon}</span>)}diff --git a/packages/client/src/components/Input.tsx b/packages/client/src/components/Input.tsxindex d7d9abfa7c..e57d9be873 100644--- a/packages/client/src/components/Input.tsx+++ b/packages/client/src/components/Input.tsx@@ -3,10 +3,13 @@ import { fieldControl } from './Field';import { cn } from '~/utils';import './Field.css';-/** `title` edits a heading in place, so the field takes the heading's type scale. */+/** `title` edits a heading in place, so the field takes the heading's type scale. `inline` shares+ * a row with icon Buttons, so it takes their height role and the row stays one height when a+ * theme sizes fields and buttons apart. */const INPUT_VARIANTS = {default: '',- title: 'h-12 text-2xl font-semibold tracking-tight',+ inline: 'h-theme-button',+ title: 'h-theme-field-lg text-2xl font-semibold tracking-tight','title-sm': 'text-base font-semibold tracking-tight',} as const;diff --git a/packages/client/src/components/OGDialogTemplate.tsx b/packages/client/src/components/OGDialogTemplate.tsxindex 02d278ac88..5a14384145 100644--- a/packages/client/src/components/OGDialogTemplate.tsx+++ b/packages/client/src/components/OGDialogTemplate.tsx@@ -116,7 +116,11 @@ const OGDialogTemplate: ForwardRefExoticComponent<selectClasses ?? defaultSelect} h-theme-button flex items-center justify-center rounded-lg border-none px-4 py-2 text-sm disabled:opacity-80 max-sm:order-first max-sm:w-full sm:order-none`}>- {isLoading === true ? <Spinner className="size-4" /> : (selectText as React.JSX.Element)}+ {isLoading === true ? (+ <Spinner className="size-theme-icon" />+ ) : (+ (selectText as React.JSX.Element)+ )}</OGDialogClose>);} else if (selection) {diff --git a/packages/client/src/components/OriginalDialog.tsx b/packages/client/src/components/OriginalDialog.tsxindex 74844f2cae..9c86624814 100644--- a/packages/client/src/components/OriginalDialog.tsx+++ b/packages/client/src/components/OriginalDialog.tsx@@ -372,8 +372,8 @@ const DialogContent: React.ForwardRefExoticComponent<aria-hidden="true"/>{showCloseButton && (- <DialogPrimitive.Close className="ring-ring-primary ring-offset-surface-dialog focus:ring-focus-control data-[state=open]:bg-surface-hover data-[state=open]:text-text-secondary absolute top-4 right-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">- <X className="h-6 w-6" aria-hidden="true" />+ <DialogPrimitive.Close className="ring-ring-primary ring-offset-surface-dialog focus:ring-focus-control data-[state=open]:bg-surface-hover data-[state=open]:text-text-secondary min-h-theme-target min-w-theme-target absolute top-4 right-4 inline-flex items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">+ <X className="size-theme-icon-lg" aria-hidden="true" /><span className="sr-only">Close</span></DialogPrimitive.Close>)}diff --git a/packages/client/src/components/Select.tsx b/packages/client/src/components/Select.tsxindex 3d2a5edd5b..ea1e02c21e 100644--- a/packages/client/src/components/Select.tsx+++ b/packages/client/src/components/Select.tsx@@ -27,7 +27,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<<SelectPrimitive.Triggerref={ref}className={cn(- 'border-border-control ring-offset-surface-primary placeholder:text-text-secondary focus-visible:ring-focus-control flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:ring-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',+ 'border-border-control ring-offset-surface-primary placeholder:text-text-secondary focus-visible:ring-focus-control h-theme-control flex w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus-visible:ring-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',disabledFillClasses,'hover:bg-surface-hover rounded-lg',className,@@ -36,7 +36,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<>{children}<SelectPrimitive.Icon asChild>- <CaretSortIcon className="h-4 w-4 opacity-50" />+ <CaretSortIcon className="size-theme-icon opacity-50" /></SelectPrimitive.Icon></SelectPrimitive.Trigger>));@@ -151,7 +151,7 @@ const SelectItem: React.ForwardRefExoticComponent<><span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center"><SelectPrimitive.ItemIndicator>- <CheckIcon className="h-4 w-4" />+ <CheckIcon className="size-theme-icon" /></SelectPrimitive.ItemIndicator></span><SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>diff --git a/packages/client/src/components/Switch.tsx b/packages/client/src/components/Switch.tsxindex 9a2f7a0dd8..bbed41918f 100644--- a/packages/client/src/components/Switch.tsx+++ b/packages/client/src/components/Switch.tsx@@ -26,7 +26,7 @@ const Switch: React.ForwardRefExoticComponent</** A compact theme track can be smaller than a usable target, so an invisible layer* centered on it keeps the hit area at least 24px tall, and 44px each way on a coarse* pointer; a track larger than that still takes taps on its own box. */- 'touch:before:h-theme-control-touch touch:before:w-theme-control-touch relative before:absolute before:top-1/2 before:left-1/2 before:h-6 before:w-full before:-translate-x-1/2 before:-translate-y-1/2',+ 'touch:before:h-theme-control-touch touch:before:w-theme-control-touch before:h-theme-target before:min-w-theme-target relative before:absolute before:top-1/2 before:left-1/2 before:w-full before:-translate-x-1/2 before:-translate-y-1/2','peer focus-visible:ring-focus-control focus-visible:ring-offset-surface-primary data-[state=checked]:bg-surface-inverted data-[state=unchecked]:bg-switch-unchecked h-theme-switch w-theme-switch inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',disabledFillClasses,className,diff --git a/packages/client/src/components/Tabs.tsx b/packages/client/src/components/Tabs.tsxindex 651308702b..e7adc427e0 100644--- a/packages/client/src/components/Tabs.tsx+++ b/packages/client/src/components/Tabs.tsx@@ -33,7 +33,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<>(({ className = '', ...props }, ref) => (<TabsPrimitive.TriggerclassName={cn(- 'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary rounded-theme-tab inline-flex min-w-[100px] items-center justify-center px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',+ 'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary rounded-theme-tab min-w-theme-tab inline-flex items-center justify-center px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',disabledInkClasses,className,)}diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.mdindex 3c8bc10a63..9d62a0e2f9 100644--- a/packages/client/src/theme/README.md+++ b/packages/client/src/theme/README.md@@ -358,6 +358,22 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a- Keyboard focus outline - The global `:focus-visible` outline is drawn in`focus-outline`, `focusRingWidth` wide and `focusRingOffset` off the edge (2pxeach by default). The contrast modes keep their own 3px outline.+- Control and icon sizes - `h-theme-button-xs` / `h-theme-button-lg`+ (`buttonHeightXs`, `buttonHeightLg`) size the Button's `xs` and `lg` steps;+ its `icon`, `icon-sm` and `icon-xs` squares are `size-theme-button`,+ `size-theme-icon-button-sm` (`iconButtonSizeSm`) and `size-theme-button-xs`.+ `size-theme-checkbox` (`checkboxSize`) sizes the checkbox, `size-theme-icon` and+ `size-theme-icon-lg` (`iconSize`, `iconSizeLg`) the icons in menus and selects and+ the dialog's close icon, `h-theme-field-lg` (`fieldHeightLg`) the large `title`+ input, and `h-theme-target` the switch's hit area, and `min-w-theme-tab` (`tabMinWidth`, `0` to size a tab by its label) the tab+ trigger. Every default is the size the primitive drew before. The icon and checkbox roles+ are bounded to the room their layouts leave: `iconSize` 0.75 to 1.25rem, `iconSizeMd` (the+ exported Dialog's close glyph) 1.25 to 1.5rem, `iconSizeLg` 1 to 2rem, `checkboxSize` 1 to+ 1.5rem. The target floor (`h-theme-target`, `min-h-theme-target`, `min-w-theme-target`) is+ a fixed 24px, WCAG 2.5.8's minimum, not a role, so a theme cannot lower it. The Button's+ `xs`, `lg`, `compact` and `icon-sm` heights and `fieldHeightLg` reject a value under 24px;+ `controlHeight`, `buttonHeight`, `buttonHeightSm` and `fieldHeight` predate the floor and+ keep their earlier validation.- `bg-field-fill` / `text-field-text` - A form field's fill and typed value. Theink follows `text-primary` and the fill follows `surface-primary` when a themenames those and not these. Fields stay clear unless the theme'sdiff --git a/packages/client/src/theme/context/ThemeProvider.spec.tsx b/packages/client/src/theme/context/ThemeProvider.spec.tsxindex 2356e0e713..97106e3b82 100644--- a/packages/client/src/theme/context/ThemeProvider.spec.tsx+++ b/packages/client/src/theme/context/ThemeProvider.spec.tsx@@ -832,7 +832,7 @@ describe('ThemeProvider', () => {modes: {light: {colors: { 'rgb-accent-primary': '4 5 6' },- appearance: { controlRadius: '2px', futureSpacing: '3rem' },+ appearance: { controlRadius: '2px', futureSpacing: '3.3125rem' },},},};@@ -851,7 +851,7 @@ describe('ThemeProvider', () => {expect(root.dataset.theme).toBe('newer');expect(root.style.getPropertyValue('--accent-primary')).toBe('4 5 6');expect(root.style.getPropertyValue('--theme-control-radius')).toBe('2px');- expect(root.getAttribute('style')).not.toContain('3rem');+ expect(root.getAttribute('style')).not.toContain('3.3125rem');expect(warn).toHaveBeenCalledWith('[ThemeProvider] Unknown light appearance token ignored: futureSpacing',);@@ -890,7 +890,7 @@ describe('ThemeProvider', () => {it('still discards a stored definition whose known key has an invalid value', async () => {const invalid = {...newerDefinition,- modes: { light: { appearance: { controlRadius: 'huge', futureSpacing: '3rem' } } },+ modes: { light: { appearance: { controlRadius: 'huge', futureSpacing: '3.3125rem' } } },};localStorage.setItem('theme-definition', JSON.stringify(invalid));diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.cssindex d8b13fdd2c..82ce064711 100644--- a/packages/client/src/theme/defaults.css+++ b/packages/client/src/theme/defaults.css@@ -218,6 +218,7 @@ html {--theme-menu-radius: 0.7rem;--theme-tooltip-radius: 0.275rem;--theme-tab-radius: 0.185rem;+ --theme-tab-min-width: 100px;--theme-radius-sm: calc(0.5rem - 4px);--theme-radius-md: calc(0.5rem - 2px);--theme-radius-lg: 0.5rem;@@ -227,10 +228,18 @@ html {--theme-control-height: 2.25rem;--theme-control-padding-x: var(--theme-space-normal, 0.75rem);--theme-control-gap: var(--theme-space-compact, 0.375rem);+ --theme-icon-size: 1rem;+ --theme-icon-size-md: 1.25rem;+ --theme-icon-size-lg: 1.5rem;--theme-control-font-weight: 500;--theme-button-height: 2.5rem;--theme-button-height-sm: 2.25rem;+ --theme-button-height-xs: 1.75rem;+ --theme-button-height-lg: 2.75rem;+ --theme-button-height-compact: 2rem;+ --theme-icon-button-size-sm: 2rem;--theme-field-height: 2.5rem;+ --theme-field-height-lg: 3rem;--theme-field-padding-y: 0.5rem;--theme-field-focus-style: ring;--theme-field-fill-style: transparent;@@ -241,6 +250,7 @@ html {--theme-label-font-weight: inherit;--theme-switch-width: 2.75rem;--theme-switch-height: 1.5rem;+ --theme-checkbox-size: 1rem;--theme-table-cell-space-y: 1rem;--theme-table-row-stroke: 0px;--theme-space-compact: 0.375rem;diff --git a/packages/client/src/theme/primitives.spec.ts b/packages/client/src/theme/primitives.spec.tsnew file mode 100644index 0000000000..bebb126a0c--- /dev/null+++ b/packages/client/src/theme/primitives.spec.ts@@ -0,0 +1,190 @@+import { join } from 'path';+import { readFileSync } from 'fs';++/**+ * The ten named primitives, read the strict way: a primitive is theme-driven only when its files+ * paint color, radius, border, shadow and size from theme roles alone. Each file is checked for+ * raw palette utilities, hex/rgb/hsl literals, arbitrary corners and shadows, fixed size+ * utilities (`h-4`, `size-10`, `min-w-[8rem]`; a fraction such as `w-11/12`, a viewport unit or a+ * value read from the component library is relative, and a `0` is a reset, not a size), literal+ * corners and shadows in its stylesheet, and design-rule suppressions. Move a primitive into+ * `themeDriven` when a change clears it; the remaining values of the others are pinned so a new+ * literal fails by name.+ */++const components = join(__dirname, '../components');+const repoRoot = join(__dirname, '../../../..');++const primitives: Record<string, string[]> = {+ Button: ['Button.tsx'],+ Input: ['Input.tsx', 'Field.ts'],+ Select: ['Select.tsx', 'Dropdown.tsx', 'Dropdown.css'],+ Dialog: ['OriginalDialog.tsx', 'OGDialogTemplate.tsx', 'Dialog.tsx'],+ Menu: ['DropdownPopup.tsx', 'Dropdown.css'],+ Tabs: ['Tabs.tsx'],+ Switch: ['Switch.tsx'],+ Checkbox: ['Checkbox.tsx'],+ Table: ['Table.tsx'],+ Tooltip: ['Tooltip.tsx', 'Tooltip.css'],+};++const themeDriven = ['Button', 'Input', 'Dialog', 'Tabs', 'Switch', 'Checkbox', 'Table', 'Tooltip'];++/** What the two others still hard-code, and why it stays. */+const remaining: Record<string, string[]> = {+ /** The content's nested-popover layering is a runtime style; the item indicator box, the list's+ * scroll cap and its minimum width have no role. */+ Select: [+ 'Select.tsx: arbitrary size min-w-[8rem]',+ 'Select.tsx: fixed size h-3.5',+ 'Select.tsx: fixed size h-96',+ 'Select.tsx: fixed size w-3.5',+ 'Select.tsx: suppression shadcn/no-inline-styles',+ ],+ /** The menu's z-index comes from the popover stack at runtime. */+ Menu: ['DropdownPopup.tsx: suppression shadcn/no-inline-styles'],+};++const suppressions: Record<string, Record<string, { count: number }>> = JSON.parse(+ readFileSync(join(repoRoot, 'eslint-suppressions.json'), 'utf8'),+);++/** Every Tailwind palette hue, black and white, under any color utility. */+const rawPalette = new RegExp(+ `\\b(?:bg|text|border(?:-[xytblrse])?|ring(?:-offset)?|outline|fill|stroke|divide|accent|caret|decoration|placeholder|from|via|to|shadow)-(?:${[+ 'black',+ 'white',+ 'slate',+ 'gray',+ 'zinc',+ 'neutral',+ 'stone',+ 'red',+ 'orange',+ 'amber',+ 'yellow',+ 'lime',+ 'green',+ 'emerald',+ 'teal',+ 'cyan',+ 'sky',+ 'blue',+ 'indigo',+ 'violet',+ 'purple',+ 'fuchsia',+ 'pink',+ 'rose',+ ].join('|')})(?:-[0-9]+)?\\b`,+ 'g',+);++/** A 3, 4, 6 or 8 digit hex color, or an rgb/hsl function with literal channels. */+const hexOrRgb =+ /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})\b|rgba?\(\s*[0-9]|hsla?\(/g;++const isComment = (line: string) => /^\s*(\*|\/\/|\/\*)/.test(line);++/** A stylesheet with every theme role's `var(--theme-*, fallback)` reduced to `var(--theme-*)`;+ * any other custom property keeps its fallback, which is then scanned like any literal. */+function withoutVarFallbacks(css: string): string {+ let result = '';+ let index = 0;+ for (let start = css.indexOf('var(', index); start !== -1; start = css.indexOf('var(', index)) {+ let depth = 0;+ let end = start + 3;+ for (; end < css.length; end++) {+ if (css[end] === '(') {+ depth += 1;+ } else if (css[end] === ')') {+ depth -= 1;+ }+ if (depth === 0) {+ break;+ }+ }+ const call = css.slice(start, end + 1);+ const name = /^var\(\s*(--[\w-]+)/.exec(call)?.[1] ?? '';+ result += css.slice(index, start) + (name.startsWith('--theme-') ? `var(${name})` : call);+ index = end + 1;+ }+ return result + css.slice(index);+}++function hardCoded(file: string): string[] {+ const source = readFileSync(join(components, file), 'utf8');+ const code = source.split('\n').filter((line) => !isComment(line));+ const found = new Set<string>();+ if (file.endsWith('.css')) {+ /** A role's `var()` fallback restates the default for a host without the stock stylesheet;+ * it is not a value the rule paints while the role is set, so it is set aside first. */+ const rules = withoutVarFallbacks(source.replace(/\/\*[\s\S]*?\*\//g, ''));+ for (const match of rules.matchAll(/(border-radius|box-shadow):\s*[0-9][^;]*/g)) {+ found.add(`${file}: literal ${match[0]}`);+ }+ for (const match of rules.matchAll(hexOrRgb)) {+ found.add(`${file}: color literal ${match[0]}`);+ }+ } else {+ const text = code.join('\n');+ for (const match of text.matchAll(rawPalette)) {+ found.add(`${file}: raw palette ${match[0]}`);+ }+ for (const match of text.matchAll(hexOrRgb)) {+ found.add(`${file}: color literal ${match[0]}`);+ }+ for (const match of text.matchAll(/\b(?:rounded|shadow)(?:-[a-z]{1,2})?-\[[^\]]*\]/g)) {+ found.add(`${file}: arbitrary ${match[0]}`);+ }+ for (const match of text.matchAll(/\b(?:h|w|size|min-h)-(?:[1-9][0-9.]*|0\.[0-9]+)\b(?!\/)/g)) {+ found.add(`${file}: fixed size ${match[0]}`);+ }+ for (const match of text.matchAll(+ /\b(?:h|w|size|min-h|min-w|max-h|max-w)-\[[0-9.]+(?:px|rem|em)\]/g,+ )) {+ found.add(`${file}: arbitrary size ${match[0]}`);+ }+ }+ Object.keys(suppressions[`packages/client/src/components/${file}`] ?? {})+ .filter((rule) => rule.startsWith('shadcn/'))+ .forEach((rule) => found.add(`${file}: suppression ${rule}`));+ return [...found].sort();+}++const values = Object.fromEntries(+ Object.entries(primitives).map(([name, files]) => [name, files.flatMap(hardCoded).sort()]),+);++describe('the ten named primitives', () => {+ it('draws at least eight of them from theme roles alone', () => {+ const driven = Object.keys(primitives).filter((name) => values[name].length === 0);++ expect(driven).toEqual(themeDriven);+ expect(driven.length).toBeGreaterThanOrEqual(8);+ });++ it('reads any raw palette hue under any color utility', () => {+ const hits = (classes: string) => classes.match(rawPalette) ?? [];+ expect(+ hits('bg-orange-500 text-pink-600 border-emerald-500 fill-white ring-offset-red-500'),+ ).toHaveLength(5);+ expect('text-[#00000080] bg-[#fff]'.match(hexOrRgb)).toEqual(['#00000080', '#fff']);+ expect(hits('bg-surface-primary text-text-secondary border-border-light')).toEqual([]);+ });++ it('sets aside a role fallback in a stylesheet but keeps a painted literal', () => {+ expect(+ withoutVarFallbacks(+ '.a { box-shadow: var(--theme-menu-shadow, 0 1px rgb(0 0 0 / 0.1)); color: #fff; }',+ ),+ ).toBe('.a { box-shadow: var(--theme-menu-shadow); color: #fff; }');+ expect(withoutVarFallbacks('.a { box-shadow: var(--local-shadow, 0 1px #000); }')).toBe(+ '.a { box-shadow: var(--local-shadow, 0 1px #000); }',+ );+ });++ it.each(Object.keys(remaining))('pins what %s still hard-codes', (name) => {+ expect(values[name]).toEqual(remaining[name]);+ });+});diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.tsindex fa6029108c..ce188228be 100644--- a/packages/client/src/theme/registry.spec.ts+++ b/packages/client/src/theme/registry.spec.ts@@ -1109,6 +1109,54 @@ describe('theme registry', () => {expect(appearance).toMatchObject({ focusRingWidth: '0.25rem', focusRingOffset: '-1px' });});+ it('keeps every control and icon size on the size it drew before it had a role', () => {+ expect(defaultAppearance).toMatchObject({+ iconSize: '1rem',+ iconSizeLg: '1.5rem',+ buttonHeightXs: '1.75rem',+ buttonHeightLg: '2.75rem',+ iconButtonSizeSm: '2rem',+ fieldHeightLg: '3rem',+ checkboxSize: '1rem',+ });+ });++ it('rejects a pointer target under 24px and a size that is not a positive length', () => {+ const issues = (appearance: Record<string, string>) =>+ validateThemeDefinition({+ version: 1,+ name: 'size-values',+ modes: { light: { appearance } },+ });++ expect(+ issues({+ fieldHeightLg: '24px',+ checkboxSize: '1.5rem',+ iconSize: '20px',+ iconSizeLg: '2rem',+ }),+ ).toEqual([]);+ [+ { fieldHeightLg: '20px' },+ { fieldHeightLg: '1rem' },+ { fieldHeightLg: '1.5em' },+ { iconSize: '0' },+ { iconSize: '1.5rem' },+ { iconSize: '10px' },+ { iconSizeLg: '0.75rem' },+ { iconSizeLg: '40px' },+ { checkboxSize: '8px' },+ { checkboxSize: '2rem' },+ { checkboxSize: 'auto' },+ { buttonHeightLg: '-2rem' },+ { buttonHeightXs: '1px' },+ { iconSizeMd: '1rem' },+ { iconButtonSizeSm: '20px' },+ { iconButtonSizeSm: 'calc(2rem + 2px)' },+ ].forEach((appearance) => expect(issues(appearance)).toHaveLength(1));+ });+it('rejects a focus outline that would vanish or is not a fixed length', () => {const issues = (appearance: Record<string, string>) =>validateThemeDefinition({diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.tsindex a8a391f51e..390b032fcb 100644--- a/packages/client/src/theme/registry.ts+++ b/packages/client/src/theme/registry.ts@@ -166,6 +166,7 @@ export const themeAppearanceProperties: Readonly<menuRadius: '--theme-menu-radius',tooltipRadius: '--theme-tooltip-radius',tabRadius: '--theme-tab-radius',+ tabMinWidth: '--theme-tab-min-width',radiusSm: '--theme-radius-sm',radiusMd: '--theme-radius-md',radiusLg: '--theme-radius-lg',@@ -175,10 +176,18 @@ export const themeAppearanceProperties: Readonly<controlHeight: '--theme-control-height',controlPaddingX: '--theme-control-padding-x',controlGap: '--theme-control-gap',+ iconSize: '--theme-icon-size',+ iconSizeMd: '--theme-icon-size-md',+ iconSizeLg: '--theme-icon-size-lg',controlFontWeight: '--theme-control-font-weight',buttonHeight: '--theme-button-height',buttonHeightSm: '--theme-button-height-sm',+ buttonHeightXs: '--theme-button-height-xs',+ buttonHeightLg: '--theme-button-height-lg',+ buttonHeightCompact: '--theme-button-height-compact',+ iconButtonSizeSm: '--theme-icon-button-size-sm',fieldHeight: '--theme-field-height',+ fieldHeightLg: '--theme-field-height-lg',fieldPaddingY: '--theme-field-padding-y',fieldFocusStyle: '--theme-field-focus-style',fieldFillStyle: '--theme-field-fill-style',@@ -189,6 +198,7 @@ export const themeAppearanceProperties: Readonly<labelFontWeight: '--theme-label-font-weight',switchWidth: '--theme-switch-width',switchHeight: '--theme-switch-height',+ checkboxSize: '--theme-checkbox-size',tableCellSpaceY: '--theme-table-cell-space-y',tableRowStroke: '--theme-table-row-stroke',spaceCompact: '--theme-space-compact',@@ -242,6 +252,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({menuRadius: '0.7rem',tooltipRadius: '0.275rem',tabRadius: '0.185rem',+ tabMinWidth: '100px',radiusSm: 'calc(0.5rem - 4px)',radiusMd: 'calc(0.5rem - 2px)',radiusLg: '0.5rem',@@ -251,10 +262,18 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({controlHeight: '2.25rem',controlPaddingX: '0.75rem',controlGap: '0.375rem',+ iconSize: '1rem',+ iconSizeMd: '1.25rem',+ iconSizeLg: '1.5rem',controlFontWeight: '500',buttonHeight: '2.5rem',buttonHeightSm: '2.25rem',+ buttonHeightXs: '1.75rem',+ buttonHeightLg: '2.75rem',+ buttonHeightCompact: '2rem',+ iconButtonSizeSm: '2rem',fieldHeight: '2.5rem',+ fieldHeightLg: '3rem',fieldPaddingY: '0.5rem',fieldFocusStyle: 'ring',fieldFillStyle: 'transparent',@@ -264,6 +283,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({labelLeading: '1',labelFontWeight: 'inherit',...defaultSwitchSize,+ checkboxSize: '1rem',tableCellSpaceY: '1rem',tableRowStroke: '0px',spaceCompact: '0.375rem',diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.jsindex 1af2f218e0..696348e9a9 100644--- a/packages/client/src/theme/tailwind.spec.js+++ b/packages/client/src/theme/tailwind.spec.js@@ -158,6 +158,25 @@ describe('LibreChat Tailwind preset', () => {defaultAppearance.largeSurfaceRadius,],['rounded-theme-tab', '--theme-tab-radius', defaultAppearance.tabRadius],+ ['min-w-theme-tab', '--theme-tab-min-width', defaultAppearance.tabMinWidth],+ ['h-theme-button-xs', '--theme-button-height-xs', defaultAppearance.buttonHeightXs],+ ['h-theme-button-lg', '--theme-button-height-lg', defaultAppearance.buttonHeightLg],+ [+ 'h-theme-button-compact',+ '--theme-button-height-compact',+ defaultAppearance.buttonHeightCompact,+ ],+ ['h-theme-field-lg', '--theme-field-height-lg', defaultAppearance.fieldHeightLg],+ ['size-theme-button', '--theme-button-height', defaultAppearance.buttonHeight],+ [+ 'size-theme-icon-button-sm',+ '--theme-icon-button-size-sm',+ defaultAppearance.iconButtonSizeSm,+ ],+ ['size-theme-checkbox', '--theme-checkbox-size', defaultAppearance.checkboxSize],+ ['size-theme-icon', '--theme-icon-size', defaultAppearance.iconSize],+ ['size-theme-icon-md', '--theme-icon-size-md', defaultAppearance.iconSizeMd],+ ['size-theme-icon-lg', '--theme-icon-size-lg', defaultAppearance.iconSizeLg],['shadow-theme-surface', '--theme-elevation-surface', defaultAppearance.elevationSurface],['duration-theme-fast', '--theme-motion-fast', defaultAppearance.motionFast],['duration-theme-normal', '--theme-motion-normal', defaultAppearance.motionNormal],@@ -184,6 +203,13 @@ describe('LibreChat Tailwind preset', () => {`max(var(--theme-control-height, ${defaultAppearance.controlHeight}), 2.75rem)`,);+ /** The target floor is WCAG 2.5.8's 24px, not a role a theme could lower. */+ const target = await generate(['h-theme-target', 'min-h-theme-target', 'min-w-theme-target']);+ ['height', 'min-height', 'min-width'].forEach((property) =>+ expect(target).toContain(`${property}: 24px`),+ );+ expect(target).not.toContain('--theme-min-target-size');+/** A stylesheet that predates the control spacing roles pads controls with the shared* spacing they read before. */expect(rule(css, 'px-theme-control-x')).toContain(diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.tsindex 992877c78e..f3a80fcd1c 100644--- a/packages/client/src/theme/themes/clickhouse.ts+++ b/packages/client/src/theme/themes/clickhouse.ts@@ -382,6 +382,8 @@ const clickHouseShape = {menuRadius: '0.25rem', // genericMenu.panel.radii.alltooltipRadius: '0.25rem', // tooltip.radii.alltabRadius: '0.25rem', // tabs.radii.all+ /** Click UI sizes a tab trigger by its label, in `tabs.space.x` on each side. */+ tabMinWidth: '0',radiusSm: '0.25rem', // border.radii.1radiusMd: '0.25rem', // border.radii.1radiusLg: '0.25rem', // border.radii.1@@ -416,6 +418,15 @@ const clickHouseShape = {* 0.875rem/1.5 label and a 1px stroke, 32px in all. */buttonHeight: '2rem',buttonHeightSm: '2rem',+ /** Click UI draws one button size, so the `lg` step matches the default too. Its icon button is+ * a 1rem icon in 0.25rem of `iconButton.sm` space on each side, 1.5rem in all, which still meets+ * the 24px target minimum; its `xs` (no space) would not, so `icon-xs` keeps LibreChat's. */+ buttonHeightLg: '2rem',+ buttonHeightCompact: '2rem',+ iconButtonSizeSm: '1.5rem',+ iconSize: '1rem', // image.sm.size.width+ iconSizeMd: '1.25rem', // image.md.size.width+ iconSizeLg: '1.5rem', // image.lg.size.width, the dialog close icon/** Click UI's field is sized by its content, like its button: 0.2813rem of space.y on both* sides of a 0.875rem/1.5 value and a 1px stroke, 32px in all. On focus it swaps its stroke to* `field.color.stroke.active` and draws no ring (InputWrapper); LibreChat adds a 1px ring in@@ -450,6 +461,7 @@ const clickHouseShape = {disabledStyle: 'fill' as const,switchWidth: '2rem', // switch.size.widthswitchHeight: '1rem', // switch.size.height+ checkboxSize: '1rem', // checkbox.size.all/** Click UI's own sizes halve like LibreChat's: `md` is this full space, and the compact tables* every in-repo consumer draws land on `sm` (0.5rem), the size Click UI tables default to. *//** The shared spacing takes two steps of Click UI's `spaces` scale: its 0.5rem gap step, thediff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.jsonindex 34700a82d5..dc03cddb42 100644--- a/packages/client/src/theme/themes/clickui.json+++ b/packages/client/src/theme/themes/clickui.json@@ -27,6 +27,7 @@"click.button.basic.space.x": "1rem","click.button.basic.typography.label.default": "400 0.875rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;","click.button.iconButton.color.primary.background.active": "rgb(86.824% 87.176% 88.235%)",+ "click.checkbox.size.all": "1rem","click.codeblock.lightMode.color.background.default": "#f6f7fa","click.codeblock.lightMode.color.text.default": "#282828","click.dialog.color.background.default": "#ffffff",@@ -49,6 +50,9 @@"click.genericMenu.panel.size.height": "2rem","click.global.color.text.danger": "#c10000","click.global.color.text.warning": "#a33c00",+ "click.image.lg.size.width": "1.5rem",+ "click.image.md.size.width": "1.25rem",+ "click.image.sm.size.width": "1rem","click.switch.color.background.active": "#151515","click.switch.color.background.default": "#cccfd3","click.switch.color.indicator.default": "#ffffff",@@ -169,6 +173,7 @@"click.button.basic.space.x": "1rem","click.button.basic.typography.label.default": "400 0.875rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;","click.button.iconButton.color.primary.background.active": "rgb(14.118% 14.118% 14.118%)",+ "click.checkbox.size.all": "1rem","click.codeblock.darkMode.color.background.default": "#282828","click.codeblock.darkMode.color.text.default": "#ffffff","click.dialog.color.background.default": "#1f1f1c",@@ -191,6 +196,9 @@"click.genericMenu.panel.size.height": "2rem","click.global.color.text.danger": "#ffbaba","click.global.color.text.warning": "#ffb88f",+ "click.image.lg.size.width": "1.5rem",+ "click.image.md.size.width": "1.25rem",+ "click.image.sm.size.width": "1rem","click.switch.color.background.active": "#faff69","click.switch.color.background.default": "#606060","click.switch.color.indicator.default": "#151515",diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.tsindex bf8f3e8d9b..7902188b95 100644--- a/packages/client/src/theme/themes/clickui.spec.ts+++ b/packages/client/src/theme/themes/clickui.spec.ts@@ -511,6 +511,27 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDecistatus: 'match',reason: '2rem: Click UI draws one button size, so the small step matches the default',},+ buttonHeightCompact: {+ value: '2rem',+ status: 'match',+ reason: '2rem: Click UI draws one button size, so the compact step matches the default',+ },+ buttonHeightLg: {+ value: '2rem',+ status: 'match',+ reason: '2rem: Click UI draws one button size, so the large step matches the default',+ },+ tabMinWidth: {+ value: '0',+ status: 'match',+ reason: '0: Click UI sizes tab triggers by their label in tabs.space.x, with no minimum width',+ },+ iconButtonSizeSm: {+ value: '1.5rem',+ status: 'match',+ reason:+ '1.5rem: Click UI IconButton sm is a 1rem icon (iconButton.size.medium) in iconButton.sm.space 0.25rem on each side',+ },fieldHeight: {value: '2rem',status: 'match',@@ -609,6 +630,10 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',switchWidth: 'click.switch.size.width',switchHeight: 'click.switch.size.height',+ checkboxSize: 'click.checkbox.size.all',+ iconSize: 'click.image.sm.size.width',+ iconSizeMd: 'click.image.md.size.width',+ iconSizeLg: 'click.image.lg.size.width',tableCellSpaceY: 'click.table.body.cell.space.md.y',tableRowStroke: 'click.table.cell.stroke',motionFast: 'transition.duration.medium',diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.tsindex 05bba00ed0..892ad9df8e 100644--- a/packages/client/src/theme/types/index.ts+++ b/packages/client/src/theme/types/index.ts@@ -511,6 +511,8 @@ export interface IThemeAppearance {menuRadius: string;tooltipRadius: string;tabRadius: string;+ /** The narrowest a tab trigger draws; `0` sizes it by its label. */+ tabMinWidth: string;radiusSm: string;radiusMd: string;radiusLg: string;@@ -522,16 +524,31 @@ export interface IThemeAppearance {* `spaceCompact` when a theme names those and not these. */controlPaddingX: string;controlGap: string;+ /** An icon beside a label or in a menu row (0.75 to 1.25rem), and the larger one a dialog's+ * close button draws (1 to 2rem). */+ iconSize: string;+ /** The medium icon (1.25 to 1.5rem), such as the exported Dialog's close glyph. */+ iconSizeMd: string;+ iconSizeLg: string;/** A theme-sized control's label weight, and the Button's default and `sm` heights. */controlFontWeight: string;buttonHeight: string;buttonHeightSm: string;+ /** The Button's `xs` and `lg` heights; `icon-xs` is as wide as `xs` is tall, `icon` as the+ * default, and `icon-sm` takes its own size. */+ buttonHeightXs: string;+ buttonHeightLg: string;+ /** The compact toolbar step the Button and Dropdown `compact` recipes share. */+ buttonHeightCompact: string;+ iconButtonSizeSm: string;/*** A form field's height, and its focus treatment: `ring` draws the keyboard-only focus ring,* `border` swaps the field's edge to `border-field-focus` on any focus, and keyboard focus adds* a 1px ring in that color so the indicator keeps a 2px perimeter.*/fieldHeight: string;+ /** The height of the large `title` field. */+ fieldHeightLg: string;/** The field's vertical padding, which has to leave its line room inside `fieldHeight`. */fieldPaddingY: string;fieldFocusStyle: 'ring' | 'border';@@ -548,6 +565,8 @@ export interface IThemeAppearance {labelFontWeight: string;switchWidth: string;switchHeight: string;+ /** A checkbox's box and the check inside it, 1 to 1.5rem. */+ checkboxSize: string;tableCellSpaceY: string;tableRowStroke: string;spaceCompact: string;diff --git a/packages/client/src/utils/utils.spec.ts b/packages/client/src/utils/utils.spec.tsnew file mode 100644index 0000000000..2fa4810419--- /dev/null+++ b/packages/client/src/utils/utils.spec.ts@@ -0,0 +1,16 @@+import { cn } from './utils';++describe('cn', () => {+ /** A caller's own size replaces the role a primitive draws, so the two never both survive and+ * leave the winner to stylesheet order. */+ it.each([+ ['h-theme-control', 'h-9'],+ ['h-theme-button-xs', 'h-8'],+ ['size-theme-button', 'size-9'],+ ['h-theme-control', 'size-theme-control'],+ ['min-w-theme-target', 'min-w-0'],+ ['min-h-theme-target', 'min-h-0'],+ ])('lets a caller size replace %s', (role, caller) => {+ expect(cn(role, caller)).toBe(caller);+ });+});diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.tsindex 3fe6011adf..e87a8ff700 100644--- a/packages/client/src/utils/utils.ts+++ b/packages/client/src/utils/utils.ts@@ -23,11 +23,33 @@ const twMerge = extendTailwindMerge({h: [{h: [+ 'theme-control','theme-table-head','theme-table-head-compact','theme-button','theme-button-sm',+ 'theme-button-xs',+ 'theme-button-lg',+ 'theme-button-compact','theme-field',+ 'theme-field-lg',+ 'theme-target',+ ],+ },+ ],+ 'min-w': [{ 'min-w': ['theme-tab', 'theme-target'] }],+ 'min-h': [{ 'min-h': ['theme-target'] }],+ size: [+ {+ size: [+ 'theme-control',+ 'theme-button',+ 'theme-button-xs',+ 'theme-icon-button-sm',+ 'theme-checkbox',+ 'theme-icon',+ 'theme-icon-md',+ 'theme-icon-lg',],},],diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjsindex 1215c48a21..852f98717a 100644--- a/packages/client/tailwind.preset.cjs+++ b/packages/client/tailwind.preset.cjs@@ -23,13 +23,32 @@ module.exports = {/** The Button's default and `sm` heights. */'theme-button': 'var(--theme-button-height, 2.5rem)','theme-button-sm': 'var(--theme-button-height-sm, 2.25rem)',- /** A form field's height. */+ 'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',+ 'theme-button-lg': 'var(--theme-button-height-lg, 2.75rem)',+ 'theme-button-compact': 'var(--theme-button-height-compact, 2rem)',+ /** A form field's height, and the large `title` field's. */'theme-field': 'var(--theme-field-height, 2.5rem)',+ 'theme-field-lg': 'var(--theme-field-height-lg, 3rem)',+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never+ * smaller. */+ 'theme-target': '24px',/** A header cell: the table's vertical cell space on both sides of one text line. */'theme-table-head': 'calc(var(--theme-table-cell-space-y, 1rem) * 2 + 1rem)',/** A compact header: half the cell space on both sides of a text-sm line. */'theme-table-head-compact': 'calc(var(--theme-table-cell-space-y, 1rem) + 1.25rem)',},+ minHeight: {+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never+ * smaller. */+ 'theme-target': '24px',+ },+ minWidth: {+ /** WCAG 2.5.8's 24px target minimum, fixed so a theme can draw controls larger, never+ * smaller. */+ 'theme-target': '24px',+ /** The narrowest a tab trigger draws. */+ 'theme-tab': 'var(--theme-tab-min-width, 100px)',+ },width: {/** Never narrower than the track is tall, so the knob always has somewhere to travel. */'theme-switch':@@ -39,6 +58,14 @@ module.exports = {'theme-compact': 'var(--theme-space-compact, 0.375rem)','theme-normal': 'var(--theme-space-normal, 0.75rem)','theme-control': 'var(--theme-control-height, 2.25rem)',+ /** Square sizes: icon buttons as wide as their row is tall, the checkbox, and icons. */+ 'theme-button': 'var(--theme-button-height, 2.5rem)',+ 'theme-button-xs': 'var(--theme-button-height-xs, 1.75rem)',+ 'theme-icon-button-sm': 'var(--theme-icon-button-size-sm, 2rem)',+ 'theme-checkbox': 'var(--theme-checkbox-size, 1rem)',+ 'theme-icon': 'var(--theme-icon-size, 1rem)',+ 'theme-icon-md': 'var(--theme-icon-size-md, 1.25rem)',+ 'theme-icon-lg': 'var(--theme-icon-size-lg, 1.5rem)',/** A theme-sized control's inline padding and gap, falling back to the shared spacing it* read before, for a stylesheet that predates the roles. */'theme-control-x': 'var(--theme-control-padding-x, var(--theme-space-normal, 0.75rem))',@@ -51,7 +78,8 @@ module.exports = {/*** The comfortable tap target (2.75rem / 44px), held against the theme's* own control height with `max()` so a theme that already draws larger- * controls is never shrunk on a phone. Pair it with `touch:`.+ * controls is never shrunk on a phone. Pair it+ * with `touch:`.*/'theme-control-touch': 'max(var(--theme-control-height, 2.25rem), 2.75rem)',/** The switch knob inside the track's 2px border, in px so it holds at any root size,diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.tsindex 4ebc47d37e..4bb26d7ea5 100644--- a/packages/data-provider/src/theme.ts+++ b/packages/data-provider/src/theme.ts@@ -229,6 +229,23 @@ const isSwitchLength = (value: unknown): value is string =>* never vanishes; its offset may also be zero or negative, drawing the outline on or inside the* element's edge.*/+/**+ * A positive px or rem length inside the range its layouts were built for, in px on a 16px root:+ * the icon and checkbox roles size glyphs that sit in fixed insets and rows, so a theme can retune+ * them, but not past the room those layouts leave.+ */+const lengthWithin =+ (minPx: number, maxPx: number) =>+ (value: unknown): value is string => {+ if (!isSwitchLength(value)) {+ return false;+ }+ const px = parseFloat(value) * (value.endsWith('rem') ? 16 : 1);+ return px >= minPx && px <= maxPx;+ };+/** A pointer target never drops under WCAG 2.5.8's 24px minimum, written in px or rem. */+const isTargetSize = (value: unknown): value is string =>+ isSwitchLength(value) && parseFloat(value) >= (value.endsWith('rem') ? 1.5 : 24);const isFocusRingOffset = (value: unknown): value is string =>typeof value === 'string' && /^(0|-?\d*\.?\d+(px|rem))$/.test(value);/** A numeric CSS font weight, 1 to 1000, which is all a label weight needs. */@@ -342,6 +359,7 @@ const appearanceValidators = {menuRadius: isLength,tooltipRadius: isLength,tabRadius: isLength,+ tabMinWidth: isTableLength,radiusSm: isLength,radiusMd: isLength,radiusLg: isLength,@@ -353,13 +371,24 @@ const appearanceValidators = {* spacing that also pads message rows. */controlPaddingX: isLength,controlGap: isLength,+ /** An icon's size (0.75 to 1.25rem), and the larger one a dialog's close button draws (1 to+ * 2rem). */+ iconSize: lengthWithin(12, 20),+ iconSizeMd: lengthWithin(20, 24),+ iconSizeLg: lengthWithin(16, 32),/** A theme-sized control's label weight, and the Button's default and `sm` heights. */controlFontWeight: isFontWeight,buttonHeight: isLength,buttonHeightSm: isLength,+ /** The Button's `xs` and `lg` heights and the `icon-sm` square, each a pointer target. */+ buttonHeightXs: isTargetSize,+ buttonHeightLg: isTargetSize,+ buttonHeightCompact: isTargetSize,+ iconButtonSizeSm: isTargetSize,/** A form field's height and vertical padding, and whether focus draws a ring or swaps the* field's edge color. */fieldHeight: isLength,+ fieldHeightLg: isTargetSize,fieldPaddingY: isLength,fieldFocusStyle: (value: unknown) => value === 'ring' || value === 'border',/** Whether a field stays transparent or paints `field-fill`. */@@ -373,6 +402,8 @@ const appearanceValidators = {labelFontWeight: (value: unknown) => value === 'inherit' || isFontWeight(value),switchWidth: isSwitchLength,switchHeight: isSwitchLength,+ /** A checkbox's box and the check inside it, 1 to 1.5rem: never smaller than the box it was. */+ checkboxSize: lengthWithin(16, 24),tableCellSpaceY: isTableLength,tableRowStroke: isTableLength,spaceCompact: isLength,