Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

📏 feat: Give Theme-Sized Controls Their Own Padding and Gap Roles (#16528)

Marco Beretta5c6578fa2504
diff --git a/client/src/components/Chat/Input/CodeApprovalMenu.tsx b/client/src/components/Chat/Input/CodeApprovalMenu.tsx
index 7c3867b7c5..cbbf7bde12 100644
--- a/client/src/components/Chat/Input/CodeApprovalMenu.tsx
+++ b/client/src/components/Chat/Input/CodeApprovalMenu.tsx
@@ -102,7 +102,7 @@ export default function CodeApprovalMenu({
)}`}
className={cn(
composerControlClasses(),
- 'md:px-theme-normal max-w-full min-w-0 px-2.5',
+ 'md:px-theme-control-x max-w-full min-w-0 px-2.5',
isOpen && 'bg-surface-hover',
disabled && 'cursor-not-allowed opacity-50',
)}
diff --git a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx
index 79bea04a98..9582d2d0ae 100644
--- a/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx
+++ b/client/src/components/Chat/Input/CodeWorkspaceMenu.tsx
@@ -374,7 +374,7 @@ export default function CodeWorkspaceMenu({
}
className={cn(
composerControlClasses(),
- 'md:px-theme-normal max-w-full min-w-0 px-2.5',
+ 'md:px-theme-control-x max-w-full min-w-0 px-2.5',
isOpen && 'bg-surface-hover',
buttonDisabled && 'cursor-not-allowed opacity-50',
)}
diff --git a/client/src/components/Chat/Input/__tests__/CodeApprovalMenu.spec.tsx b/client/src/components/Chat/Input/__tests__/CodeApprovalMenu.spec.tsx
index 8a584b561d..0e4f248122 100644
--- a/client/src/components/Chat/Input/__tests__/CodeApprovalMenu.spec.tsx
+++ b/client/src/components/Chat/Input/__tests__/CodeApprovalMenu.spec.tsx
@@ -119,7 +119,7 @@ describe('CodeApprovalMenu', () => {
expect(screen.getByTestId('code-approval-mode')).toHaveClass(
'h-theme-control',
'rounded-theme-control-round',
- 'gap-theme-compact',
+ 'gap-theme-control-gap',
'border-border-medium',
);
});
diff --git a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts
index 2d7e7768b1..adfbe92efe 100644
--- a/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts
+++ b/client/src/components/Chat/Input/__tests__/appearanceTokens.spec.ts
@@ -15,7 +15,7 @@ const themedControls = [
['InterruptSteerButton.tsx', ['size-theme-control', 'rounded-theme-control-round']],
['TokenUsage/index.tsx', ['size-theme-control', 'rounded-theme-control-round']],
['Files/AttachFile.tsx', ['size-theme-control', 'rounded-theme-control-round']],
- ['CodeApprovalMenu.tsx', ['composerControlClasses()', 'md:px-theme-normal']],
+ ['CodeApprovalMenu.tsx', ['composerControlClasses()', 'md:px-theme-control-x']],
] as const;
describe('Composer appearance tokens', () => {
diff --git a/e2e/specs/mock/scenarios/control-spacing.spec.ts b/e2e/specs/mock/scenarios/control-spacing.spec.ts
new file mode 100644
index 0000000000..d786c0b600
--- /dev/null
+++ b/e2e/specs/mock/scenarios/control-spacing.spec.ts
@@ -0,0 +1,131 @@
+import { expect, test } from '@playwright/test';
+import type { Locator, Page } from '@playwright/test';
+import type { ThemeDefinition } from '../../../../packages/client/src/theme/types';
+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
+import { NEW_CHAT_PATH, messagesView, sendMessageAndWaitForCompletion } from '../helpers';
+import { probeStyle } from './style.helpers';
+
+/**
+ * Theme-sized controls read their inline padding and icon-to-label gap from control roles, apart
+ * from the shared spacing that also pads message bubbles and the composer's send button. The
+ * temporary-chat status chip is a real `size="theme"` control on the chat header.
+ */
+test.describe.configure({ timeout: 120_000 });
+test.use({ viewport: { width: 1280, height: 800 } });
+
+const TOGGLE = 'button[aria-label="Temporary Chat"]';
+
+/** A definition from before the control roles, which named only the shared spacing. */
+const legacySpacingTheme: ThemeDefinition = {
+ version: 1,
+ name: 'legacy-spacing-reference',
+ modes: {
+ light: { appearance: { spaceNormal: '0.5rem', spaceCompact: '0.25rem' } },
+ dark: { appearance: { spaceNormal: '0.5rem', spaceCompact: '0.25rem' } },
+ },
+};
+
+async function storeDefinition(page: Page, definition: ThemeDefinition | null) {
+ await page.addInitScript((stored) => {
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ if (stored === null) {
+ localStorage.removeItem('theme-definition');
+ localStorage.removeItem('theme-source');
+ return;
+ }
+ localStorage.setItem('theme-definition', JSON.stringify(stored));
+ localStorage.setItem('theme-source', 'definition');
+ }, definition);
+}
+
+/**
+ * Starts a temporary chat and returns its header status chip, which appears once the first
+ * message is sent; the exchange also renders a message bubble padded by the shared spacing.
+ */
+async function temporaryChip(page: Page): Promise<Locator> {
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ const toggle = page.locator(TOGGLE);
+ await expect(toggle).toBeVisible({ timeout: 20000 });
+ if ((await toggle.getAttribute('aria-pressed')) !== 'true') {
+ await toggle.click();
+ }
+ await expect(toggle).toHaveAttribute('aria-pressed', 'true');
+ await sendMessageAndWaitForCompletion(page, 'Control spacing probe');
+ const chip = page.getByRole('status').filter({ has: page.locator('svg.lucide-hat-glasses') });
+ await expect(chip).toBeVisible({ timeout: 20000 });
+ return chip;
+}
+
+/** The mode is persisted locally, so the next scenario starts from a normal chat. */
+async function leaveTemporaryChat(page: Page) {
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ const toggle = page.locator(TOGGLE);
+ await expect(toggle).toBeVisible({ timeout: 20000 });
+ if ((await toggle.getAttribute('aria-pressed')) === 'true') {
+ await toggle.click();
+ }
+ await expect(toggle).toHaveAttribute('aria-pressed', 'false');
+}
+
+/** The sent message's bubble, the one element padded by `px-theme-normal`. */
+const bubblePadding = (page: Page) =>
+ messagesView(page)
+ .locator('.px-theme-normal')
+ .first()
+ .evaluate((node: HTMLElement) => getComputedStyle(node).paddingLeft);
+
+const spacing = (chip: Locator) =>
+ chip.evaluate((node: HTMLElement) => {
+ const style = getComputedStyle(node);
+ return {
+ paddingLeft: style.paddingLeft,
+ paddingRight: style.paddingRight,
+ gap: style.columnGap,
+ };
+ });
+
+test.describe('theme control spacing', () => {
+ test('theme-sized controls keep 12px padding and a 6px gap without a theme @scenario:theme-controls-keep-default-spacing', async ({
+ page,
+ }) => {
+ await storeDefinition(page, null);
+ const chip = await temporaryChip(page);
+
+ expect(await spacing(chip)).toEqual({ paddingLeft: '12px', paddingRight: '12px', gap: '6px' });
+ expect(await probeStyle(page, 'px-theme-control-x', 'padding-left')).toBe('12px');
+ expect(await probeStyle(page, 'gap-theme-control-gap', 'column-gap')).toBe('6px');
+ expect(await bubblePadding(page)).toBe('12px');
+
+ await leaveTemporaryChat(page);
+ });
+
+ test('ClickHouse controls take Click UI button padding and gap while message spacing stays @scenario:clickhouse-controls-take-click-ui-spacing', async ({
+ page,
+ }) => {
+ await storeDefinition(page, clickHouseTheme);
+ const chip = await temporaryChip(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');
+
+ /** `button.basic.space.x` and `button.basic.space.gap`. */
+ expect(await spacing(chip)).toEqual({ paddingLeft: '16px', paddingRight: '16px', gap: '8px' });
+ /** Message bubbles and the send button keep the shared spacing roles. */
+ expect(await bubblePadding(page)).toBe('12px');
+ expect(await probeStyle(page, 'p-theme-compact', 'padding-top')).toBe('6px');
+
+ await leaveTemporaryChat(page);
+ });
+
+ test('a theme naming only the shared spacing keeps its controls on it @scenario:legacy-space-theme-keeps-control-spacing', async ({
+ page,
+ }) => {
+ await storeDefinition(page, legacySpacingTheme);
+ const chip = await temporaryChip(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'legacy-spacing-reference');
+
+ expect(await spacing(chip)).toEqual({ paddingLeft: '8px', paddingRight: '8px', gap: '4px' });
+ expect(await bubblePadding(page)).toBe('8px');
+
+ await leaveTemporaryChat(page);
+ });
+});
diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsx
index 3ba7ca1c22..34e376dcf1 100644
--- a/packages/client/src/components/Button.spec.tsx
+++ b/packages/client/src/components/Button.spec.tsx
@@ -14,10 +14,20 @@ describe('Button', () => {
expect(screen.getByRole('button', { name: 'Continue' })).toHaveClass(
'h-theme-control',
'rounded-theme-control',
- 'gap-theme-compact',
+ 'gap-theme-control-gap',
+ 'px-theme-control-x',
);
});
+ /** The base `gap-2` and the default size's `px-4` would otherwise survive beside the roles and
+ * leave the winner to stylesheet order, and a caller's own padding must still win. */
+ it('lets the control spacing roles replace the base gap and a caller replace them', () => {
+ const themed = cn(buttonVariants({ size: 'theme' }));
+ expect(themed).not.toMatch(/(^|\s)gap-2(\s|$)/);
+ expect(cn(themed, 'px-2')).not.toContain('px-theme-control-x');
+ expect(cn(themed, 'gap-1')).not.toContain('gap-theme-control-gap');
+ });
+
it('offers the composer action row geometry as a size and a shape', () => {
render(
<Button size="icon-theme" shape="round" aria-label="Scroll to bottom">
diff --git a/packages/client/src/components/Button.tsx b/packages/client/src/components/Button.tsx
index 32ab865eb9..d7da863f23 100644
--- a/packages/client/src/components/Button.tsx
+++ b/packages/client/src/components/Button.tsx
@@ -150,7 +150,7 @@ const buttonVariantRecipe = cva(
* line up with them.
*/
'icon-theme': 'size-theme-control p-0',
- theme: 'h-theme-control gap-theme-compact px-theme-normal',
+ theme: 'h-theme-control gap-theme-control-gap px-theme-control-x',
/** The padding of a list row that is itself the click target. */
row: 'h-auto gap-3 px-3.5 py-3',
/** The padding of a tile that reserves a corner for an overflow menu. */
diff --git a/packages/client/src/components/CheckboxButton.spec.tsx b/packages/client/src/components/CheckboxButton.spec.tsx
index 90e56e7f6f..5f3c1e53c8 100644
--- a/packages/client/src/components/CheckboxButton.spec.tsx
+++ b/packages/client/src/components/CheckboxButton.spec.tsx
@@ -10,9 +10,9 @@ describe('CheckboxButton', () => {
'h-theme-control',
'w-theme-control',
'rounded-theme-control-round',
- 'gap-theme-compact',
+ 'gap-theme-control-gap',
'p-theme-compact',
- 'md:px-theme-normal',
+ 'md:px-theme-control-x',
);
});
});
diff --git a/packages/client/src/components/CheckboxButton.tsx b/packages/client/src/components/CheckboxButton.tsx
index ca46b31e28..a49547fedc 100644
--- a/packages/client/src/components/CheckboxButton.tsx
+++ b/packages/client/src/components/CheckboxButton.tsx
@@ -63,7 +63,7 @@ const CheckboxButton: React.ForwardRefExoticComponent<
onChange={onChange}
className={cn(
composerControlClasses(),
- 'w-theme-control max-w-fit p-theme-compact md:w-full md:px-theme-normal',
+ 'w-theme-control p-theme-compact md:px-theme-control-x max-w-fit md:w-full',
// Checked state styling
isChecked && isCheckedClassName && isCheckedClassName,
diff --git a/packages/client/src/components/Chip.spec.tsx b/packages/client/src/components/Chip.spec.tsx
index ab331d19b2..63611e580d 100644
--- a/packages/client/src/components/Chip.spec.tsx
+++ b/packages/client/src/components/Chip.spec.tsx
@@ -50,7 +50,8 @@ describe('Chip', () => {
expect(screen.getByText('Themeable').parentElement).toHaveClass(
'h-theme-control',
'rounded-theme-control',
- 'gap-theme-compact',
+ 'gap-theme-control-gap',
+ 'px-theme-control-x',
);
expect(screen.getByRole('button', { name: 'Remove theme' })).toHaveClass(
'rounded-theme-control-round',
diff --git a/packages/client/src/components/Chip.tsx b/packages/client/src/components/Chip.tsx
index 2f7c3436bf..c9e1d11c95 100644
--- a/packages/client/src/components/Chip.tsx
+++ b/packages/client/src/components/Chip.tsx
@@ -26,7 +26,7 @@ const chipVariants: (props?: ChipVariantProps & ClassProp) => string = cva(
size: {
sm: 'min-h-6 px-2 py-0.5',
md: 'min-h-8 px-2.5 py-1',
- theme: 'h-theme-control gap-theme-compact px-theme-normal',
+ theme: 'h-theme-control gap-theme-control-gap px-theme-control-x',
},
shape: {
round: 'rounded-full',
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 44a6674dc5..5a5cd33762 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -207,7 +207,7 @@ v4 loads no config file on its own, so without the directive the preset, the `co
and class-based dark mode are all silently absent.
The published preset supplies the semantic appearance utilities used by theme-aware component
-variants, including `h-theme-control`, `rounded-theme-control`, `gap-theme-compact`, and
+variants, including `h-theme-control`, `rounded-theme-control`, `px-theme-control-x`, `gap-theme-control-gap`, and
`duration-theme-fast`. Keep the preset enabled even when defining additional project utilities.
The published stylesheet and preset preserve the host's standard Tailwind color palettes.
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index 2b58c225f3..99e49698e6 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -197,6 +197,8 @@ html {
--theme-radius-2xl: 1rem;
--theme-radius-3xl: 1.5rem;
--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-switch-width: 2.75rem;
--theme-switch-height: 1.5rem;
--theme-table-cell-space-y: 1rem;
diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts
index f3a39740b5..b9f6f89ea1 100644
--- a/packages/client/src/theme/defaults.spec.ts
+++ b/packages/client/src/theme/defaults.spec.ts
@@ -77,12 +77,21 @@ describe.each([
});
});
+/** Control roles split out of the shared spacing alias it, so a stylesheet that sets only the
+ * shared role still spaces its controls. */
+const stockAliases: Partial<
+ Record<keyof typeof defaultAppearance, keyof typeof defaultAppearance>
+> = { controlPaddingX: 'spaceNormal', controlGap: 'spaceCompact' };
+
describe('the stock appearance and brands', () => {
it('declares every appearance property with the registry default', () => {
Object.entries(themeAppearanceProperties).forEach(([key, property]) => {
+ const role = key as keyof typeof defaultAppearance;
+ const value = defaultAppearance[role].replace(/\s+/g, ' ');
+ const source = stockAliases[role];
expect([property, light.get(property)]).toEqual([
property,
- defaultAppearance[key as keyof typeof defaultAppearance].replace(/\s+/g, ' '),
+ source ? `var(${themeAppearanceProperties[source]}, ${value})` : value,
]);
});
});
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index b51ff6a708..644b406d32 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -591,6 +591,52 @@ describe('theme registry', () => {
expect(bundled.appearance.displayFontFamily).toBe(defaultAppearance.fontFamily);
});
+ it('pads theme-sized controls with the shared spacing by default', () => {
+ expect(defaultAppearance.controlPaddingX).toBe(defaultAppearance.spaceNormal);
+ expect(defaultAppearance.controlGap).toBe(defaultAppearance.spaceCompact);
+ });
+
+ it('keeps the controls of a theme that names only the shared spacing on it', () => {
+ const { appearance } = resolveTheme(compactTheme, 'light');
+
+ expect(appearance).toMatchObject({ controlPaddingX: '0.5rem', controlGap: '0.25rem' });
+ });
+
+ it('spaces controls apart from message rows when a theme names the control roles', () => {
+ const { appearance } = resolveTheme(
+ {
+ version: 1,
+ name: 'roomy-controls-reference',
+ modes: {
+ light: {
+ appearance: { spaceNormal: '0.5rem', controlPaddingX: '2rem', controlGap: '1rem' },
+ },
+ },
+ },
+ 'light',
+ );
+
+ expect(appearance).toMatchObject({
+ spaceNormal: '0.5rem',
+ spaceCompact: defaultAppearance.spaceCompact,
+ controlPaddingX: '2rem',
+ controlGap: '1rem',
+ });
+ });
+
+ it('rejects a control spacing role that is not a length', () => {
+ const issues = (appearance: Record<string, string>) =>
+ validateThemeDefinition({
+ version: 1,
+ name: 'bad-controls',
+ modes: { light: { appearance } },
+ });
+
+ expect(issues({ controlPaddingX: '1rem', controlGap: 'calc(1rem - 2px)' })).toEqual([]);
+ expect(issues({ controlPaddingX: '12' })).toHaveLength(1);
+ expect(issues({ controlGap: '1rem; color: red' })).toHaveLength(1);
+ });
+
it('reproduces Tailwind’s own type scale by default', () => {
const tailwind = readFileSync(
join(__dirname, '..', '..', '..', '..', 'node_modules', 'tailwindcss', 'theme.css'),
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index a4ce393206..cb68882fed 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -135,6 +135,8 @@ export const themeAppearanceProperties: Readonly<
radius2xl: '--theme-radius-2xl',
radius3xl: '--theme-radius-3xl',
controlHeight: '--theme-control-height',
+ controlPaddingX: '--theme-control-padding-x',
+ controlGap: '--theme-control-gap',
switchWidth: '--theme-switch-width',
switchHeight: '--theme-switch-height',
tableCellSpaceY: '--theme-table-cell-space-y',
@@ -184,6 +186,8 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
radius2xl: '1rem',
radius3xl: '1.5rem',
controlHeight: '2.25rem',
+ controlPaddingX: '0.75rem',
+ controlGap: '0.375rem',
...defaultSwitchSize,
tableCellSpaceY: '1rem',
tableRowStroke: '0px',
@@ -355,16 +359,24 @@ function withComposableShadows(appearance: IThemeAppearance): IThemeAppearance {
}
/**
- * Headings drew the UI family before the display role existed, so a theme that
- * names its own `fontFamily` and no display family keeps its headings in it.
+ * Roles split out of a broader one, each paired with the role it read before. Headings drew the UI
+ * family before the display role existed, and theme-sized controls were padded by the shared
+ * spacing, so a theme that names the broader role and not the split one keeps what it drew.
*/
-function withDisplayFamily(appearance?: Partial<IThemeAppearance>): IThemeAppearance {
+const inheritedAppearance: ReadonlyArray<[keyof IThemeAppearance, keyof IThemeAppearance]> = [
+ ['displayFontFamily', 'fontFamily'],
+ ['controlPaddingX', 'spaceNormal'],
+ ['controlGap', 'spaceCompact'],
+];
+
+function withInheritedRoles(appearance?: Partial<IThemeAppearance>): IThemeAppearance {
const known = knownAppearance(appearance);
- const display =
- known.displayFontFamily === undefined && known.fontFamily !== undefined
- ? { displayFontFamily: known.fontFamily }
- : {};
- return { ...defaultAppearance, ...known, ...display };
+ const inherited = Object.fromEntries(
+ inheritedAppearance
+ .filter(([role, source]) => known[role] === undefined && known[source] !== undefined)
+ .map(([role, source]) => [role, known[source]]),
+ );
+ return { ...defaultAppearance, ...known, ...inherited };
}
export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedThemeDefinition {
@@ -544,7 +556,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...seriesEightFallback,
...verifiedFallback,
} as Required<IThemeRGB>,
- appearance: withComposableShadows(withDisplayFamily(definition?.appearance)),
+ appearance: withComposableShadows(withInheritedRoles(definition?.appearance)),
/** Mode last: a mode override is more specific than the theme-wide set. */
brands: {
...defaultBrands,
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index 2bbf7cc41c..b8012ce72a 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -144,7 +144,13 @@ describe('LibreChat Tailwind preset', () => {
['duration-theme-normal', '--theme-motion-normal', defaultAppearance.motionNormal],
];
- const css = await generate([...roles.map(([candidate]) => candidate), 'font-sans', 'p-4']);
+ const css = await generate([
+ ...roles.map(([candidate]) => candidate),
+ 'px-theme-control-x',
+ 'gap-theme-control-gap',
+ 'font-sans',
+ 'p-4',
+ ]);
roles.forEach(([candidate, property, fallback]) => {
expect(css).toContain(`.${candidate}`);
@@ -157,6 +163,15 @@ describe('LibreChat Tailwind preset', () => {
`max(var(--theme-control-height, ${defaultAppearance.controlHeight}), 2.75rem)`,
);
+ /** 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(
+ `padding-inline: var(--theme-control-padding-x, var(--theme-space-normal, ${defaultAppearance.spaceNormal}))`,
+ );
+ expect(rule(css, 'gap-theme-control-gap')).toContain(
+ `gap: var(--theme-control-gap, var(--theme-space-compact, ${defaultAppearance.spaceCompact}))`,
+ );
+
/** The preset extends the default theme rather than replacing it. */
expect(css).toContain('.font-sans');
expect(css).toContain('.p-4');
@@ -204,8 +219,13 @@ describe('LibreChat Tailwind preset', () => {
/** Prettier wraps a long font stack, so declarations compare with whitespace collapsed. */
const collapsed = stockStyles.replace(/\s+/g, ' ');
+ /** The control spacing roles alias the shared spacing they were split from. */
+ const aliases = { controlPaddingX: 'spaceNormal', controlGap: 'spaceCompact' };
Object.entries(themeAppearanceProperties).forEach(([key, property]) => {
- expect(collapsed).toContain(`${property}: ${defaultAppearance[key]};`);
+ const value = aliases[key]
+ ? `var(${themeAppearanceProperties[aliases[key]]}, ${defaultAppearance[key]})`
+ : defaultAppearance[key];
+ expect(collapsed).toContain(`${property}: ${value};`);
});
});
});
diff --git a/packages/client/src/theme/themes/clickhouse.spec.tsx b/packages/client/src/theme/themes/clickhouse.spec.tsx
index dd50712e24..142d32a60d 100644
--- a/packages/client/src/theme/themes/clickhouse.spec.tsx
+++ b/packages/client/src/theme/themes/clickhouse.spec.tsx
@@ -359,6 +359,8 @@ describe('clickhouse theme definition', () => {
'shadow2xl',
'elevationSurface',
'controlHeight',
+ 'controlPaddingX',
+ 'controlGap',
'motionFast',
] as const;
expect(
@@ -366,12 +368,17 @@ describe('clickhouse theme definition', () => {
).toEqual([]);
});
- /** Click UI's control height and `transition.default`. The spacing roles keep LibreChat's
- * values: they also pad message bubbles and the composer's send button, and 0.75rem is
- * already Click UI's field padding. */
+ /** Click UI's control height, button padding and gap, and `transition.default`. The shared
+ * spacing roles keep LibreChat's values: they also pad message bubbles and the composer's send
+ * button, and 0.75rem is already Click UI's field padding. */
it('sizes theme controls from Click UI and leaves the shared spacing alone', () => {
const { appearance } = resolveTheme(clickHouseTheme, 'light');
- expect(appearance).toMatchObject({ controlHeight: '2rem', motionFast: '100ms' });
+ expect(appearance).toMatchObject({
+ controlHeight: '2rem',
+ controlPaddingX: '1rem',
+ controlGap: '0.5rem',
+ motionFast: '100ms',
+ });
expect(appearance.spaceCompact).toBe(defaultAppearance.spaceCompact);
expect(appearance.spaceNormal).toBe(defaultAppearance.spaceNormal);
});
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index 6fed6c6a79..232c19d94c 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -358,6 +358,8 @@ const clickHouseShape = {
shadowXs: '0 2px 2px 0 rgb(0 0 0 / 0.03)', // shadow.5
shadowSm: '0 2px 2px 0 rgb(0 0 0 / 0.03)', // shadow.5
controlHeight: '2rem', // genericMenu.panel.size.height
+ controlPaddingX: '1rem', // button.basic.space.x
+ controlGap: '0.5rem', // button.basic.space.gap
scrimOpacity: '0.75', // dialog.color.opaqueBackground alpha
alertScrimOpacity: '0.75', // dialog.color.opaqueBackground alpha
modalScrimOpacity: '0.75', // dialog.color.opaqueBackground alpha
diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json
index e4705d9856..36c7715070 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -20,6 +20,8 @@
"click.button.basic.color.primary.background.disabled": "#dfdfdf",
"click.button.basic.color.primary.text.default": "#ffffff",
"click.button.basic.color.secondary.stroke.default": "#e6e7e9",
+ "click.button.basic.space.gap": "0.5rem",
+ "click.button.basic.space.x": "1rem",
"click.button.iconButton.color.primary.background.active": "rgb(86.824% 87.176% 88.235%)",
"click.codeblock.lightMode.color.background.default": "#f6f7fa",
"click.codeblock.lightMode.color.text.default": "#282828",
@@ -127,6 +129,8 @@
"click.button.basic.color.primary.background.hover": "rgb(98.627% 100% 58.824%)",
"click.button.basic.color.primary.text.default": "#1f1f1c",
"click.button.basic.color.secondary.stroke.default": "#414141",
+ "click.button.basic.space.gap": "0.5rem",
+ "click.button.basic.space.x": "1rem",
"click.button.iconButton.color.primary.background.active": "rgb(14.118% 14.118% 14.118%)",
"click.codeblock.darkMode.color.background.default": "#282828",
"click.codeblock.darkMode.color.text.default": "#ffffff",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index bc9903e349..ca67fe6343 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -314,6 +314,8 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
shadow2xl: 'shadow.1',
elevationSurface: 'shadow.1',
controlHeight: 'click.genericMenu.panel.size.height',
+ controlPaddingX: 'click.button.basic.space.x',
+ controlGap: 'click.button.basic.space.gap',
scrimOpacity: 'click.dialog.color.opaqueBackground.default',
alertScrimOpacity: 'click.dialog.color.opaqueBackground.default',
modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',
@@ -448,7 +450,7 @@ function comparable(key: keyof IThemeAppearance, raw: string | number): string {
* every decision; the floors below only move up.
*/
type ParityKind = 'color' | 'shape';
-type Utility = 'bg' | 'text' | 'border' | 'rounded' | 'w' | 'h' | 'py';
+type Utility = 'bg' | 'text' | 'border' | 'rounded' | 'w' | 'h' | 'py' | 'px' | 'gap';
interface ParityProbe {
/** The Click UI component token the primitive should reproduce. */
@@ -523,6 +525,10 @@ const dropdownProbe = () =>
const buttonProbe = (variant: 'default' | 'outline') => () =>
mount(createElement(Button, { variant }, 'Save'), 'button');
+/** A button on the theme's control metrics, the size that reads the control spacing roles. */
+const themeButtonProbe = () =>
+ mount(createElement(Button, { size: 'theme', shape: 'theme' }, 'Save'), 'button');
+
const parityProbes: Record<string, ParityProbe> = {
'Button primary fill': {
token: 'click.button.basic.color.primary.background.default',
@@ -548,6 +554,18 @@ const parityProbes: Record<string, ParityProbe> = {
utility: 'rounded',
element: buttonProbe('default'),
},
+ 'Button inline padding': {
+ token: 'click.button.basic.space.x',
+ kind: 'shape',
+ utility: 'px',
+ element: themeButtonProbe,
+ },
+ 'Button gap': {
+ token: 'click.button.basic.space.gap',
+ kind: 'shape',
+ utility: 'gap',
+ element: themeButtonProbe,
+ },
'Field fill': {
token: 'click.field.color.background.default',
kind: 'color',
@@ -733,8 +751,8 @@ const parityProbes: Record<string, ParityProbe> = {
/** The fewest decisions per mode that must match; raise a floor when a change closes a gap. */
const parityFloors: Record<ThemeMode, Record<ParityKind, number>> = {
- light: { color: 9, shape: 10 },
- dark: { color: 10, shape: 10 },
+ light: { color: 9, shape: 12 },
+ dark: { color: 10, shape: 12 },
};
const radiusRoles: Record<string, keyof IThemeAppearance> = {
@@ -752,12 +770,14 @@ const radiusRoles: Record<string, keyof IThemeAppearance> = {
const fixedRadii: Record<string, string> = { full: '9999px', none: '0px' };
-type SizeUtility = 'w' | 'h' | 'py';
+type SizeUtility = 'w' | 'h' | 'py' | 'px' | 'gap';
const sizeRoles: Record<SizeUtility, Record<string, keyof IThemeAppearance>> = {
w: { 'theme-switch': 'switchWidth' },
h: { 'theme-switch': 'switchHeight', 'theme-control': 'controlHeight' },
py: { 'theme-table-cell': 'tableCellSpaceY' },
+ px: { 'theme-control-x': 'controlPaddingX' },
+ gap: { 'theme-control-gap': 'controlGap' },
};
/** The compact and dense table sizes divide the cell space, as the preset does. */
@@ -766,8 +786,7 @@ const derivedSizes: Record<string, [keyof IThemeAppearance, number]> = {
'theme-table-cell-dense': ['tableCellSpaceY', 4],
};
-const isSizeUtility = (utility: Utility): utility is SizeUtility =>
- utility === 'w' || utility === 'h' || utility === 'py';
+const isSizeUtility = (utility: Utility): utility is SizeUtility => utility in sizeRoles;
/** A `border`, `border-2` or one-sided `border-b` class, or a theme stroke role that is not
* zero: the width a border color needs to show. */
@@ -781,7 +800,7 @@ const drawsBorder = (classes: string[], resolved: Resolved) =>
type Resolved = ReturnType<typeof resolveTheme>;
-/** A `w-*`, `h-*` or `py-*` step: a theme role, or Tailwind's 0.25rem spacing scale. */
+/** A `w-*`, `h-*`, `py-*`, `px-*` or `gap-*` step: a theme role, or Tailwind's 0.25rem scale. */
function sizeValue(utility: SizeUtility, name: string, resolved: Resolved): string | undefined {
const role = sizeRoles[utility][name];
if (role !== undefined) {
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index 17ea1e8b8b..1340e0e1f7 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -422,6 +422,10 @@ export interface IThemeAppearance {
radius2xl: string;
radius3xl: string;
controlHeight: string;
+ /** A theme-sized control's inline padding and icon-to-label gap; they follow `spaceNormal` and
+ * `spaceCompact` when a theme names those and not these. */
+ controlPaddingX: string;
+ controlGap: string;
switchWidth: string;
switchHeight: string;
tableCellSpaceY: string;
diff --git a/packages/client/src/utils/composer.spec.ts b/packages/client/src/utils/composer.spec.ts
index 5bbe828512..6a981cefd9 100644
--- a/packages/client/src/utils/composer.spec.ts
+++ b/packages/client/src/utils/composer.spec.ts
@@ -42,7 +42,7 @@ describe('composerControlClasses', () => {
expect(classes).toContain('h-theme-control');
expect(classes).toContain('rounded-theme-control-round');
- expect(classes).toContain('gap-theme-compact');
+ expect(classes).toContain('gap-theme-control-gap');
});
it('draws its border and fills from semantic roles', () => {
diff --git a/packages/client/src/utils/composer.ts b/packages/client/src/utils/composer.ts
index fac779d19f..373aece7ce 100644
--- a/packages/client/src/utils/composer.ts
+++ b/packages/client/src/utils/composer.ts
@@ -52,7 +52,7 @@ export const composerSubmitClasses = (): string =>
*/
export const composerControlClasses = (): string =>
cn(
- 'group relative inline-flex items-center justify-center gap-theme-compact',
+ 'group relative inline-flex items-center justify-center gap-theme-control-gap',
'h-theme-control rounded-theme-control-round border border-border-medium',
'bg-transparent text-sm font-medium text-text-primary transition-all',
/** No elevation: a row of raised pills inside the composer competes with the
diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.ts
index 6d0005fbe5..a2d1016049 100644
--- a/packages/client/src/utils/utils.ts
+++ b/packages/client/src/utils/utils.ts
@@ -12,6 +12,8 @@ const twMerge = extendTailwindMerge({
classGroups: {
py: [{ py: ['theme-table-cell', 'theme-table-cell-compact', 'theme-table-cell-dense'] }],
h: [{ h: ['theme-table-head', 'theme-table-head-compact'] }],
+ px: [{ px: ['theme-control-x'] }],
+ gap: [{ gap: ['theme-control-gap'] }],
},
},
});
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index 340c929c8d..3ed22f99b0 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -22,6 +22,10 @@ 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)',
+ /** 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))',
+ 'theme-control-gap': 'var(--theme-control-gap, var(--theme-space-compact, 0.375rem))',
/**
* The comfortable tap target (2.75rem / 44px), held against the theme's
* own control height with `max()` so a theme that already draws larger
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index 33927bff8e..7c03b478c0 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -308,6 +308,10 @@ const appearanceValidators = {
radius2xl: isLength,
radius3xl: isLength,
controlHeight: isLength,
+ /** The inline padding and icon-to-label gap of a theme-sized control, apart from the shared
+ * spacing that also pads message rows. */
+ controlPaddingX: isLength,
+ controlGap: isLength,
switchWidth: isSwitchLength,
switchHeight: isSwitchLength,
tableCellSpaceY: isTableLength,