From 7baa8148682a9cb9387c49fa952bb4996fee576a Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Fri, 2 Oct 2026 11:03:19 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=90=20feat:=20Size=20Roles=20for=20the?= =?UTF-8?q?=20Shared=20Primitives=20(#16617)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Size roles for the shared primitives Button's xs, lg and icon squares, the large title input, the checkbox, menu, select and dialog icons and the switch's hit area read new size roles whose defaults are the fixed sizes they drew, and the menu row corner reads radiusLg. The ClickHouse theme takes Click UI's single button size, its small icon button and its checkbox and icon sizes. A spec pins the strict count of theme-driven primitives at eight of ten and what the other two still hard-code. * fix: Hold the switch hit area to the target minimum in width and scan stylesheet colors * test: Read every raw palette hue in the primitive guard * test: Exempt only theme role fallbacks in the primitive guard * feat: Tab minimum width role and a wider fixed-size guard The primitive guard now also reads absolute arbitrary sizes, ring-offset palettes and 4 and 8 digit hex colors. The Tabs trigger's 100px minimum becomes the tabMinWidth role, which the ClickHouse theme sets to 0 so tabs size by their label as in Click UI. * fix: Keep app icon buttons and their companions on the button size role The passkey rename input keeps the field height, and the agent builder panel headers size their back button and balancing spacer from size-theme-button, so a theme that changes the button height keeps those rows aligned. * fix: Size menu glyphs from the icon role and floor touch targets at the minimum target size * fix: Let menu glyphs fill their slot and keep the dialog close target at the minimum size * test: Probe the menu glyph inside a flex row, as DropdownPopup renders it * fix: Hold icon button squares to the minimum target size * fix: Bound the icon and checkbox size roles to the room their layouts leave iconSize takes 0.75 to 1.25rem, iconSizeLg 1 to 2rem and checkboxSize 1 to 1.5rem, so a theme can retune them without shrinking a checkbox below the box it was or pushing an icon past the inset it sits in. * fix: Hold the icon-only Dropdown and header spacers to the minimum target size * fix: Floor the button size roles at the target minimum and let callers replace the control height * test: Move the unknown appearance markers off the new title field height * fix: Size the compact step, the exported Dialog and the combobox icons from roles The Button and Dropdown compact recipes read a buttonHeightCompact role, the exported Dialog's action buttons and close glyph read buttonHeight and a bounded iconSizeMd, Combobox icons follow iconSize, and the checkbox callers drop their fixed sizes so checkboxSize reaches them. minTargetSize may no longer exceed buttonHeight or fieldHeight, so the target floor never pulls icon buttons out of line with the fields beside them. * fix: Size the collapsed Combobox square from the control height role * fix: Hold every Button size and the collapsed Combobox to the target minimum * fix: Let section header buttons keep their own text height * test: Treat a zero size as a reset in the primitive guard * fix: Enforce the target size at the roles instead of on every Button A minimum height on every Button size grew callers that draw a smaller control on purpose, such as the sortable table header (h-auto) and the 20px artifact and attachment row actions. The floors come off the Button sizes and icon squares; a theme that sets minTargetSize may instead not size any button or field below it, and the new Button size roles keep their 24px floor. * fix: Check the control and large field heights against the target floor * fix: Hold the target floor at a fixed 24px and floor the large field height * fix: Keep the passkey rename field on the button height and drop the fixed MCP checkbox size * fix: Size the Combobox check glyph from the icon role and scope the README floor claim --- .../__tests__/DeploymentTheme.spec.tsx | 4 +- .../src/components/Bookmarks/BookmarkForm.tsx | 2 +- .../Account/Passkeys/PasskeyItem.tsx | 2 +- .../Passkeys/__tests__/PasskeyItem.spec.tsx | 9 +- .../Agents/Advanced/AdvancedPanel.tsx | 7 +- .../SidePanel/Agents/ImageVision.tsx | 2 +- .../SidePanel/Agents/ModelPanel.tsx | 7 +- .../ItemDialog/sections/BuiltinSection.tsx | 12 +- .../Tools/ItemDialog/sections/McpSection.tsx | 2 +- .../SidePanel/Agents/Version/VersionPanel.tsx | 5 +- .../SidePanel/Builder/AppendDateCheckbox.tsx | 2 +- .../src/components/SidePanel/Builder/Code.tsx | 2 +- .../SidePanel/Builder/ImageVision.tsx | 2 +- .../SidePanel/Builder/Retrieval.tsx | 2 +- client/src/style.css | 2 +- .../mock/scenarios/primitive-sizes.spec.ts | 164 +++++++++++++++ .../theme-unknown-appearance.spec.ts | 9 +- .../client/src/components/Button.spec.tsx | 11 +- packages/client/src/components/Button.tsx | 16 +- packages/client/src/components/Checkbox.tsx | 8 +- packages/client/src/components/Combobox.tsx | 8 +- packages/client/src/components/Dialog.tsx | 6 +- packages/client/src/components/Dropdown.css | 2 +- .../client/src/components/Dropdown.spec.tsx | 14 +- packages/client/src/components/Dropdown.tsx | 10 +- .../client/src/components/DropdownPopup.tsx | 10 +- packages/client/src/components/Input.tsx | 7 +- .../src/components/OGDialogTemplate.tsx | 6 +- .../client/src/components/OriginalDialog.tsx | 4 +- packages/client/src/components/Select.tsx | 6 +- packages/client/src/components/Switch.tsx | 2 +- packages/client/src/components/Tabs.tsx | 2 +- packages/client/src/theme/README.md | 16 ++ .../src/theme/context/ThemeProvider.spec.tsx | 6 +- packages/client/src/theme/defaults.css | 10 + packages/client/src/theme/primitives.spec.ts | 190 ++++++++++++++++++ packages/client/src/theme/registry.spec.ts | 48 +++++ packages/client/src/theme/registry.ts | 20 ++ packages/client/src/theme/tailwind.spec.js | 26 +++ .../client/src/theme/themes/clickhouse.ts | 12 ++ packages/client/src/theme/themes/clickui.json | 8 + .../client/src/theme/themes/clickui.spec.ts | 25 +++ packages/client/src/theme/types/index.ts | 19 ++ packages/client/src/utils/utils.spec.ts | 16 ++ packages/client/src/utils/utils.ts | 22 ++ packages/client/tailwind.preset.cjs | 32 ++- packages/data-provider/src/theme.ts | 31 +++ 47 files changed, 755 insertions(+), 73 deletions(-) create mode 100644 e2e/specs/mock/scenarios/primitive-sizes.spec.ts create mode 100644 packages/client/src/theme/primitives.spec.ts create mode 100644 packages/client/src/utils/utils.spec.ts diff --git a/client/src/Providers/__tests__/DeploymentTheme.spec.tsx b/client/src/Providers/__tests__/DeploymentTheme.spec.tsx index 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.tsx index 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.tsx index 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" /> { 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.tsx index 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" >