mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-18 22:14:27 +00:00
📐 feat: Size Roles for the Shared Primitives (#16617)
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
Some checks are pending
Backend Unit Tests / Build packages (push) Waiting to run
Backend Unit Tests / Codegraph select (push) Waiting to run
Backend Unit Tests / TypeScript type checks (push) Blocked by required conditions
Backend Unit Tests / Circular dependency checks (push) Waiting to run
Backend Unit Tests / Tests: api (shard 1/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 2/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: api (shard 3/3) (push) Blocked by required conditions
Backend Unit Tests / Tests: data-provider (push) Blocked by required conditions
Backend Unit Tests / Tests: data-schemas (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 1/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 2/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 3/4) (push) Blocked by required conditions
Backend Unit Tests / Tests: @librechat/api (shard 4/4) (push) Blocked by required conditions
Codegraph E2E Votes / vote (full suite) (push) Waiting to run
Docker Dev Branch Images Build / publish (push) Waiting to run
Frontend Unit Tests / Client build recovery regression (push) Waiting to run
Frontend Unit Tests / Codegraph select (push) Waiting to run
Frontend Unit Tests / Build packages (push) Waiting to run
Frontend Unit Tests / TypeScript type checks (client) (push) Blocked by required conditions
Frontend Unit Tests / Tests: @librechat/client (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 1/2) (push) Blocked by required conditions
Frontend Unit Tests / Tests: Ubuntu (shard 2/2) (push) Blocked by required conditions
Frontend Unit Tests / Vite build verification (push) Blocked by required conditions
* 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
This commit is contained in:
parent
3699557010
commit
7baa814868
47 changed files with 755 additions and 73 deletions
|
|
@ -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',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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')}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
/>
|
||||
<TooltipAnchor
|
||||
description={localize('com_ui_save')}
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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 */}
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
/>
|
||||
<label
|
||||
id="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>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
<VersionContent
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ export default function AppendDateCheckbox({ control, setValue }: AppendDateChec
|
|||
id="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"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
164
e2e/specs/mock/scenarios/primitive-sizes.spec.ts
Normal file
164
e2e/specs/mock/scenarios/primitive-sizes.spec.ts
Normal file
|
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -27,14 +27,14 @@ const Checkbox: React.ForwardRefExoticComponent<
|
|||
<CheckboxPrimitive.Root
|
||||
ref={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 }> = ({
|
|||
<span
|
||||
aria-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';
|
||||
|
|
|
|||
|
|
@ -80,9 +80,9 @@ export default function ComboboxComponent({
|
|||
<SelectTrigger
|
||||
aria-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>
|
||||
|
|
|
|||
|
|
@ -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.Close
|
||||
ref={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 */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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.Combobox
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<
|
|||
<SelectPrimitive.Trigger
|
||||
ref={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>
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<
|
|||
>(({ className = '', ...props }, ref) => (
|
||||
<TabsPrimitive.Trigger
|
||||
className={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,
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -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 (2px
|
||||
each 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. The
|
||||
ink follows `text-primary` and the fill follows `surface-primary` when a theme
|
||||
names those and not these. Fields stay clear unless the theme's
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
190
packages/client/src/theme/primitives.spec.ts
Normal file
190
packages/client/src/theme/primitives.spec.ts
Normal file
|
|
@ -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]);
|
||||
});
|
||||
});
|
||||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -382,6 +382,8 @@ const clickHouseShape = {
|
|||
menuRadius: '0.25rem', // genericMenu.panel.radii.all
|
||||
tooltipRadius: '0.25rem', // tooltip.radii.all
|
||||
tabRadius: '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.1
|
||||
radiusMd: '0.25rem', // border.radii.1
|
||||
radiusLg: '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.width
|
||||
switchHeight: '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, the
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -511,6 +511,27 @@ const appearanceDecisions: Partial<Record<keyof IThemeAppearance, AppearanceDeci
|
|||
status: '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',
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
16
packages/client/src/utils/utils.spec.ts
Normal file
16
packages/client/src/utils/utils.spec.ts
Normal file
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
@ -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',
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue