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 OGDialog Theme Roles for Its Edge, Padding and Title (#16546)

Marco Beretta0b7d49f82974
diff --git a/client/src/components/MCP/McpOAuthDialog.tsx b/client/src/components/MCP/McpOAuthDialog.tsx
index 7102829190..40a8d9a098 100644
--- a/client/src/components/MCP/McpOAuthDialog.tsx
+++ b/client/src/components/MCP/McpOAuthDialog.tsx
@@ -64,7 +64,7 @@ export default function McpOAuthDialog({
/>
</span>
)}
- <OGDialogTitle className="text-text-primary text-base leading-6 font-semibold">
+ <OGDialogTitle className="text-base leading-6 font-semibold">
{localize('com_nav_mcp_connect_server', { 0: serverName })}
</OGDialogTitle>
</div>
diff --git a/client/src/components/Nav/KeyboardShortcutsDialog.tsx b/client/src/components/Nav/KeyboardShortcutsDialog.tsx
index fbc4d4cf6c..eeb2260bed 100644
--- a/client/src/components/Nav/KeyboardShortcutsDialog.tsx
+++ b/client/src/components/Nav/KeyboardShortcutsDialog.tsx
@@ -378,7 +378,7 @@ function KeyboardShortcutsDialog() {
className="flex max-h-[85vh] w-11/12 max-w-3xl flex-col overflow-hidden p-0 lg:max-w-5xl"
>
<header className="flex shrink-0 items-center justify-between gap-4 px-7 pt-6">
- <OGDialogTitle className="text-text-primary text-[16px] font-semibold">
+ <OGDialogTitle className="text-[16px] font-semibold">
{localize('com_shortcut_keyboard_shortcuts')}
</OGDialogTitle>
<OGDialogClose
diff --git a/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx b/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
index a65e65cea0..91a34f5a19 100644
--- a/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
+++ b/client/src/components/Nav/SettingsTabs/Account/Avatar.tsx
@@ -199,7 +199,7 @@ function Avatar() {
<OGDialogContent className="w-11/12 max-w-md">
<OGDialogHeader>
- <OGDialogTitle className="text-lg font-medium leading-6 text-text-primary">
+ <OGDialogTitle className="text-lg leading-6 font-medium">
{image != null ? localize('com_ui_preview') : localize('com_ui_upload_image')}
</OGDialogTitle>
</OGDialogHeader>
@@ -208,8 +208,8 @@ function Avatar() {
<>
<div
className={cn(
- 'relative overflow-hidden rounded-full ring-4 ring-border-light transition-all',
- isDragging && 'cursor-move ring-ring-primary',
+ 'ring-border-light relative overflow-hidden rounded-full ring-4 transition-all',
+ isDragging && 'ring-ring-primary cursor-move',
)}
onMouseDown={() => setIsDragging(true)}
onMouseUp={() => setIsDragging(false)}
@@ -245,7 +245,7 @@ function Avatar() {
<Label htmlFor="zoom-slider" className="text-sm font-medium">
{localize('com_ui_zoom')}
</Label>
- <span className="text-sm text-text-secondary">{Math.round(scale * 100)}%</span>
+ <span className="text-text-secondary text-sm">{Math.round(scale * 100)}%</span>
</div>
<div className="flex items-center space-x-3">
<Button
@@ -307,7 +307,7 @@ function Avatar() {
</div>
{/* Helper Text */}
- <p className="text-center text-xs text-text-tertiary">
+ <p className="text-text-tertiary text-center text-xs">
{localize('com_ui_editor_instructions')}
</p>
</div>
@@ -341,15 +341,15 @@ function Avatar() {
</>
) : (
<div
- className="flex h-72 w-full flex-col items-center justify-center rounded-lg border-2 border-dashed border-border-medium bg-transparent transition-colors hover:border-border-heavy"
+ className="border-border-medium hover:border-border-heavy flex h-72 w-full flex-col items-center justify-center rounded-lg border-2 border-dashed bg-transparent transition-colors"
onDrop={handleDrop}
onDragOver={handleDragOver}
>
- <FileImage className="mb-4 size-16 text-text-tertiary" aria-hidden="true" />
- <p className="mb-2 text-center text-sm font-medium text-text-primary">
+ <FileImage className="text-text-tertiary mb-4 size-16" aria-hidden="true" />
+ <p className="text-text-primary mb-2 text-center text-sm font-medium">
{localize('com_ui_avatar_drop_image')}
</p>
- <p className="mb-4 text-center text-xs text-text-secondary">
+ <p className="text-text-secondary mb-4 text-center text-xs">
{localize('com_ui_avatar_file_requirements', {
0: avatarSizeLimitMB,
})}
diff --git a/client/src/components/SidePanel/Agents/ActionsInput.tsx b/client/src/components/SidePanel/Agents/ActionsInput.tsx
index d895d8766f..0eeb7fe168 100644
--- a/client/src/components/SidePanel/Agents/ActionsInput.tsx
+++ b/client/src/components/SidePanel/Agents/ActionsInput.tsx
@@ -305,7 +305,7 @@ export default function ActionsInput({
<OGDialog open={isSchemaDialogOpen} onOpenChange={setIsSchemaDialogOpen}>
<OGDialogContent className="flex h-[85vh] max-h-[85vh] w-11/12 max-w-5xl flex-col gap-3 p-5">
<OGDialogHeader className="space-y-0 pr-10">
- <OGDialogTitle className="text-text-primary text-left text-sm font-medium">
+ <OGDialogTitle className="text-left text-sm font-medium">
{localize('com_ui_schema')}
</OGDialogTitle>
<OGDialogDescription className="sr-only">
diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialogHeader.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialogHeader.tsx
index 97e07d0320..7e28416163 100644
--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialogHeader.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/ItemDialogHeader.tsx
@@ -54,9 +54,7 @@ export default function ItemDialogHeader({ item }: { item: AgentItem }) {
<OGDialogHeader className="flex flex-row items-center gap-3 space-y-0 px-6 pt-5 pb-4 text-left">
<HeaderIcon item={item} />
<div className="min-w-0 flex-1">
- <OGDialogTitle className="text-text-primary truncate text-base font-semibold">
- {displayName}
- </OGDialogTitle>
+ <OGDialogTitle className="truncate text-base font-semibold">{displayName}</OGDialogTitle>
<OGDialogDescription className="text-text-secondary m-0 text-[11px] tracking-wide uppercase">
{kindLabel}
</OGDialogDescription>
diff --git a/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx b/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
index cd460dad21..b4ca4d97e0 100644
--- a/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx
@@ -244,7 +244,7 @@ export default function SkillsDialog({ open, onOpenChange, agentId }: SkillsDial
<div className="flex h-[80dvh] max-h-[760px] flex-col">
<div className="border-border-light flex flex-col gap-3 border-b px-4 pt-4 pb-3 md:px-6 md:pt-5 md:pb-4">
<div className="flex items-center gap-2 pr-10">
- <OGDialogTitle className="text-text-primary text-base font-semibold">
+ <OGDialogTitle className="text-base font-semibold">
{localize('com_ui_skills')}
</OGDialogTitle>
</div>
diff --git a/client/src/components/Tools/AssistantToolsDialog.tsx b/client/src/components/Tools/AssistantToolsDialog.tsx
index c80a387882..58ce7f1b9d 100644
--- a/client/src/components/Tools/AssistantToolsDialog.tsx
+++ b/client/src/components/Tools/AssistantToolsDialog.tsx
@@ -164,7 +164,7 @@ function AssistantToolsDialog({
<div className="border-border-medium flex items-center justify-between border-b-[1px] px-4 pt-5 pb-4 sm:p-6">
<div className="flex items-center">
<div className="text-center sm:text-left">
- <OGDialogTitle className="text-text-primary text-lg leading-6 font-medium">
+ <OGDialogTitle className="text-lg leading-6 font-medium">
{isAgentTools
? localize('com_nav_tool_dialog_agents')
: localize('com_nav_tool_dialog')}
diff --git a/e2e/specs/mock/scenarios/dialog-chrome.spec.ts b/e2e/specs/mock/scenarios/dialog-chrome.spec.ts
new file mode 100644
index 0000000000..b1f12b2db1
--- /dev/null
+++ b/e2e/specs/mock/scenarios/dialog-chrome.spec.ts
@@ -0,0 +1,138 @@
+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 } from '../helpers';
+import { probeStyle } from './style.helpers';
+
+/**
+ * An OGDialog reads its edge stroke, inline padding and title type from theme roles. The Data &
+ * Privacy tab's "Confirm Archive" dialog is a plain OGDialogTemplate with no chrome of its own,
+ * so it shows what the primitive draws.
+ */
+test.describe.configure({ timeout: 120_000 });
+test.use({ viewport: { width: 1280, height: 800 } });
+
+type Mode = 'light' | 'dark';
+
+/** A definition from before the dialog roles, which set only the UI type and the body ink. */
+const legacyTypeTheme: ThemeDefinition = {
+ version: 1,
+ name: 'legacy-type-reference',
+ modes: {
+ light: {
+ colors: { 'rgb-text-primary': '10 20 30' },
+ appearance: { fontFamily: 'Georgia, serif', textLg: '1.4rem' },
+ },
+ dark: {
+ colors: { 'rgb-text-primary': '10 20 30' },
+ appearance: { fontFamily: 'Georgia, serif', textLg: '1.4rem' },
+ },
+ },
+};
+
+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);
+}
+
+async function confirmArchiveDialog(page: Page): Promise<Locator> {
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ await page.getByTestId('nav-user').click();
+ await page.getByRole('menuitem', { name: 'Settings' }).click();
+ const settings = page.getByRole('dialog', { name: 'Settings' });
+ await expect(settings.getByRole('heading', { name: 'Settings', exact: true })).toBeVisible({
+ timeout: 15000,
+ });
+ await settings.getByRole('tab', { name: 'Data & Privacy' }).click();
+ await settings.getByRole('button', { name: 'Archive all chats' }).click();
+ const dialog = page.getByRole('dialog', { name: 'Confirm Archive' });
+ await expect(dialog).toBeVisible();
+ return dialog;
+}
+
+const chrome = (dialog: Locator) =>
+ dialog.evaluate((node: HTMLElement) => {
+ const surface = getComputedStyle(node);
+ const title = getComputedStyle(node.querySelector('h2') as HTMLElement);
+ return {
+ stroke: surface.borderTopWidth,
+ strokeColor: surface.borderTopColor,
+ paddingX: surface.paddingLeft,
+ titleSize: title.fontSize,
+ titleLeading: title.lineHeight,
+ titleWeight: title.fontWeight,
+ titleFamily: title.fontFamily,
+ titleColor: title.color,
+ };
+ });
+
+const resolvedMode = (page: Page) =>
+ page.evaluate(() =>
+ document.documentElement.classList.contains('dark') ? 'dark' : 'light',
+ ) as Promise<Mode>;
+
+test.describe('theme dialog chrome', () => {
+ test('dialogs keep no edge, 24px padding and an 18px semibold title without a theme @scenario:dialogs-keep-default-chrome', async ({
+ page,
+ }) => {
+ await storeDefinition(page, null);
+ const dialog = await confirmArchiveDialog(page);
+ const drawn = await chrome(dialog);
+
+ expect(drawn).toMatchObject({
+ stroke: '0px',
+ paddingX: '24px',
+ titleSize: '18px',
+ titleLeading: '18px',
+ titleWeight: '600',
+ });
+ expect(drawn.titleFamily).toBe(await probeStyle(page, 'font-display', 'font-family'));
+ expect(drawn.titleColor).toBe(await probeStyle(page, 'text-text-primary', 'color'));
+ });
+
+ test('ClickHouse dialogs take Click UI stroke, padding and title @scenario:clickhouse-dialogs-follow-click-ui', async ({
+ page,
+ }) => {
+ await storeDefinition(page, clickHouseTheme);
+ const dialog = await confirmArchiveDialog(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');
+ const mode = await resolvedMode(page);
+ const drawn = await chrome(dialog);
+
+ /** `dialog.stroke.default`, `dialog.space.x` and `dialog.typography.title.default`. */
+ expect(drawn).toMatchObject({
+ stroke: '1px',
+ strokeColor: mode === 'light' ? 'rgb(230, 231, 233)' : 'rgb(50, 50, 50)',
+ paddingX: '32px',
+ titleSize: '20px',
+ titleLeading: '30px',
+ titleWeight: '700',
+ titleColor: mode === 'light' ? 'rgb(30, 29, 31)' : 'rgb(249, 249, 249)',
+ });
+ /** The regular family, not the display one ClickHouse headings use. */
+ expect(drawn.titleFamily.split(',')[0].replace(/"/g, '')).toBe('Inter');
+ });
+
+ test('a theme that sets only its type and body ink keeps its dialog titles on them @scenario:legacy-type-theme-keeps-dialog-title', async ({
+ page,
+ }) => {
+ await storeDefinition(page, legacyTypeTheme);
+ const dialog = await confirmArchiveDialog(page);
+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'legacy-type-reference');
+ const drawn = await chrome(dialog);
+
+ expect(drawn.titleFamily).toBe('Georgia, serif');
+ expect(drawn.titleSize).toBe('22.4px');
+ expect(drawn.titleColor).toBe('rgb(10, 20, 30)');
+ });
+});
diff --git a/eslint-suppressions.json b/eslint-suppressions.json
index c06908c1ea..7a0d93e661 100644
--- a/eslint-suppressions.json
+++ b/eslint-suppressions.json
@@ -1120,7 +1120,7 @@
"count": 3
},
"shadcn/no-restyle": {
- "count": 9
+ "count": 8
}
},
"client/src/components/MCP/StackedMCPIcons.tsx": {
@@ -1196,7 +1196,7 @@
"count": 11
},
"shadcn/no-restyle": {
- "count": 13
+ "count": 12
}
},
"client/src/components/Nav/NavToggle.tsx": {
@@ -1211,7 +1211,7 @@
},
"client/src/components/Nav/SettingsTabs/Account/Avatar.tsx": {
"shadcn/no-restyle": {
- "count": 7
+ "count": 6
}
},
"client/src/components/Nav/SettingsTabs/Account/BackupCodesItem.tsx": {
@@ -1544,7 +1544,7 @@
"count": 1
},
"shadcn/no-restyle": {
- "count": 25
+ "count": 24
}
},
"client/src/components/SidePanel/Agents/ActionsTable/Columns.tsx": {
@@ -1728,7 +1728,7 @@
"count": 1
},
"shadcn/no-restyle": {
- "count": 13
+ "count": 12
}
},
"client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/McpSection.tsx": {
@@ -1757,7 +1757,7 @@
},
"client/src/components/SidePanel/Agents/Tools/SkillsDialog.tsx": {
"shadcn/no-restyle": {
- "count": 11
+ "count": 10
}
},
"client/src/components/SidePanel/Agents/Tools/SkillsSection.tsx": {
@@ -2076,7 +2076,7 @@
"count": 1
},
"shadcn/no-restyle": {
- "count": 16
+ "count": 15
}
},
"client/src/components/Tools/ToolItem.tsx": {
diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsx
index c841b9130f..da6042c129 100644
--- a/packages/client/src/components/Button.spec.tsx
+++ b/packages/client/src/components/Button.spec.tsx
@@ -1,8 +1,14 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import { Button, buttonVariants } from './Button';
+import OGDialogTemplate from './OGDialogTemplate';
+import { OGDialog } from './OriginalDialog';
import { cn } from '~/utils';
+jest.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
describe('Button', () => {
it('exposes theme-owned shape and density recipes', () => {
render(
@@ -198,4 +204,27 @@ describe('Button', () => {
'h-theme-button-sm',
);
});
+
+ /** A templated dialog's legacy `selection` action sits beside the shared cancel Button, so it
+ * has to take the same height and primary fill roles or the two part under a theme. */
+ it('draws a templated dialog’s legacy confirm action from the Button roles', () => {
+ render(
+ <OGDialog open={true}>
+ <OGDialogTemplate
+ title="Delete"
+ selection={{ selectHandler: jest.fn(), selectText: 'Delete' }}
+ />
+ </OGDialog>,
+ );
+
+ const cancel = screen.getByRole('button', { name: 'com_ui_cancel' });
+ const confirm = screen.getByRole('button', { name: 'Delete' });
+ expect(cancel).toHaveClass('h-theme-button');
+ expect(confirm).toHaveClass(
+ 'h-theme-button',
+ 'bg-button-primary',
+ 'hover:bg-button-primary-hover',
+ );
+ expect(confirm).not.toHaveClass('h-10');
+ });
});
diff --git a/packages/client/src/components/OGDialogTemplate.spec.tsx b/packages/client/src/components/OGDialogTemplate.spec.tsx
new file mode 100644
index 0000000000..7161405f67
--- /dev/null
+++ b/packages/client/src/components/OGDialogTemplate.spec.tsx
@@ -0,0 +1,69 @@
+import React from 'react';
+import '@testing-library/jest-dom';
+import { render, screen } from '@testing-library/react';
+import { OGDialog, OGDialogContent, OGDialogTitle } from './OriginalDialog';
+import OGDialogTemplate from './OGDialogTemplate';
+
+jest.mock('react-i18next', () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+/**
+ * A dialog reads its edge, inline padding, header gap and title from theme roles. The template
+ * cleared the edge with `border-none`, so a theme's stroke never reached a templated dialog.
+ */
+describe('OGDialog chrome roles', () => {
+ it('lets the theme stroke and pad a templated dialog', () => {
+ render(
+ <OGDialog open={true}>
+ <OGDialogTemplate title="Archive all chats" description="Archive every chat" />
+ </OGDialog>,
+ );
+
+ const dialog = screen.getByRole('dialog', { name: 'Archive all chats' });
+ expect(dialog).toHaveClass(
+ 'border-(length:--theme-dialog-stroke)',
+ 'border-border-light',
+ 'px-theme-dialog-x',
+ );
+ expect(dialog).not.toHaveClass('border-none');
+ expect(dialog.querySelector('.space-y-theme-dialog-header')).not.toBeNull();
+ });
+
+ it('sets the title from the dialog title roles', () => {
+ render(
+ <OGDialog open={true}>
+ <OGDialogTemplate title="Archive all chats" />
+ </OGDialog>,
+ );
+
+ expect(screen.getByRole('heading', { name: 'Archive all chats' })).toHaveClass(
+ 'text-(length:--theme-dialog-title-size)',
+ 'leading-(--theme-dialog-title-leading)',
+ 'font-theme-dialog-title',
+ 'font-theme-dialog-title-weight',
+ 'text-dialog-title',
+ );
+ });
+
+ it('keeps a caller’s own title size, weight and padding over the roles', () => {
+ render(
+ <OGDialog open={true}>
+ <OGDialogContent className="p-4">
+ <OGDialogTitle className="text-sm font-medium">Rename</OGDialogTitle>
+ </OGDialogContent>
+ </OGDialog>,
+ );
+
+ const title = screen.getByRole('heading', { name: 'Rename' });
+ expect(title).toHaveClass('text-sm', 'font-medium');
+ expect(title).not.toHaveClass(
+ 'text-(length:--theme-dialog-title-size)',
+ 'leading-(--theme-dialog-title-leading)',
+ 'font-theme-dialog-title-weight',
+ );
+ const dialog = screen.getByRole('dialog', { name: 'Rename' });
+ expect(dialog).toHaveClass('p-4');
+ expect(dialog).not.toHaveClass('px-theme-dialog-x');
+ });
+});
diff --git a/packages/client/src/components/OGDialogTemplate.tsx b/packages/client/src/components/OGDialogTemplate.tsx
index eff1fa197e..633a303385 100644
--- a/packages/client/src/components/OGDialogTemplate.tsx
+++ b/packages/client/src/components/OGDialogTemplate.tsx
@@ -104,7 +104,7 @@ const OGDialogTemplate: ForwardRefExoticComponent<
const { selectHandler, selectClasses, selectText, isLoading } = legacySelection ?? {};
const defaultSelect =
- 'bg-surface-inverted text-text-inverted transition-colors hover:bg-surface-inverted-hover disabled:cursor-not-allowed disabled:opacity-50';
+ 'bg-button-primary text-text-inverted transition-colors hover:bg-button-primary-hover disabled:cursor-not-allowed disabled:opacity-50';
let selectionContent = null;
if (isLegacySelection) {
@@ -114,7 +114,7 @@ const OGDialogTemplate: ForwardRefExoticComponent<
disabled={isLoading}
className={`${
selectClasses ?? defaultSelect
- } flex h-10 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`}
+ } 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="text-text-primary size-4" />
@@ -136,12 +136,7 @@ const OGDialogTemplate: ForwardRefExoticComponent<
onEscapeKeyDown={onEscapeKeyDown}
onInteractOutside={onInteractOutside}
ref={ref}
- className={cn(
- /** `border-none` clears the default edge; the contrast variant has to
- * restore the style as well as the width to survive it. */
- 'bg-surface-dialog text-text-primary high-contrast:border high-contrast:border-solid high-contrast:border-border-medium high-contrast:shadow-none w-11/12 border-none',
- className ?? '',
- )}
+ className={cn('bg-surface-dialog text-text-primary w-11/12', className ?? '')}
onClick={(e) => e.stopPropagation()}
>
<OGDialogHeader className={cn(headerClassName ?? '')}>
diff --git a/packages/client/src/components/OriginalDialog.tsx b/packages/client/src/components/OriginalDialog.tsx
index 91e999d429..74844f2cae 100644
--- a/packages/client/src/components/OriginalDialog.tsx
+++ b/packages/client/src/components/OriginalDialog.tsx
@@ -196,10 +196,11 @@ type DialogContentProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.
const DIALOG_SURFACE_CLASSES =
/** `shadow-lg` is a black shadow, which carries no separation against
* a pure black surface, so high contrast trades it for a real edge. The
+ * theme's own edge is `dialogStroke`, none by default. The
* centering `translate-*` is the `translate` property, which the enter and
* exit keyframes' `transform` composes with instead of replacing, so the
* slide names only the 2% the surface travels. */
- 'left-[50%] top-[50%] grid max-h-[90vh] w-full translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto rounded-2xl bg-surface-dialog p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-bottom-[2%] data-[state=open]:slide-in-from-bottom-[2%] high-contrast:border high-contrast:border-solid high-contrast:border-border-medium high-contrast:shadow-none';
+ 'left-[50%] top-[50%] grid max-h-[90vh] w-full translate-x-[-50%] translate-y-[-50%] gap-4 overflow-y-auto rounded-2xl border-(length:--theme-dialog-stroke) border-border-light bg-surface-dialog py-6 px-theme-dialog-x shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-bottom-[2%] data-[state=open]:slide-in-from-bottom-[2%] high-contrast:border high-contrast:border-solid high-contrast:border-border-medium high-contrast:shadow-none';
const DialogContent: React.ForwardRefExoticComponent<
Omit<DialogPrimitive.DialogContentProps & React.RefAttributes<HTMLDivElement>, 'ref'> & {
@@ -387,7 +388,10 @@ const DialogHeader: {
({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element;
displayName: string;
} = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): JSX.Element => (
- <div className={cn('flex flex-col space-y-1.5 text-center sm:text-left', className)} {...props} />
+ <div
+ className={cn('space-y-theme-dialog-header flex flex-col text-center sm:text-left', className)}
+ {...props}
+ />
);
DialogHeader.displayName = 'DialogHeader';
@@ -413,7 +417,7 @@ const DialogTitle: React.ForwardRefExoticComponent<
<DialogPrimitive.Title
ref={ref}
className={cn(
- 'font-display text-lg leading-none font-semibold tracking-tight',
+ 'font-theme-dialog-title font-theme-dialog-title-weight text-dialog-title text-(length:--theme-dialog-title-size) leading-(--theme-dialog-title-leading) tracking-tight',
focusOutlineVariants({ focusOutline }),
className,
)}
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 2d0ba42137..01d6bcc870 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -339,8 +339,19 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
disabled fill, ink and edge, painted through the `theme-disabled:` variant only
when the theme's `disabledStyle` appearance role is `fill`. The default `dim`
keeps the half-opacity treatment every primitive carries.
-- `font-display` - Headings and dialog titles (`displayFontFamily`). Follows the
- theme's `fontFamily` when it names no display family.
+- `font-display` - Headings (`displayFontFamily`). Follows the theme's
+ `fontFamily` when it names no display family.
+- `text-dialog-title` - An OGDialog title's ink. Follows `text-primary` when a
+ theme names only that.
+- OGDialog chrome - `border-(length:--theme-dialog-stroke)` (`dialogStroke`, painted in
+ `border-light`, none by default), `px-theme-dialog-x` (`dialogPaddingX`),
+ `space-y-theme-dialog-header` (`dialogHeaderGap`), and for the title
+ `text-(length:--theme-dialog-title-size)` and
+ `leading-(--theme-dialog-title-leading)` (`dialogTitleSize`, `dialogTitleLeading`),
+ `font-theme-dialog-title-weight` (`dialogTitleFontWeight`) and
+ `font-theme-dialog-title` (`dialogTitleFontFamily`). The title size and family
+ follow `textLg` and `displayFontFamily` when a theme omits them, and a caller's
+ own padding, size or weight class replaces the role.
- `text-xs` to `text-2xl` - Sizes and line heights read `textXs`..`text2xl` and
`leadingXs`..`leading2xl`, in the app and in a consumer alike; the defaults are
Tailwind's own values.
diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css
index e745b171e3..58bc29d7b2 100644
--- a/packages/client/src/theme/defaults.css
+++ b/packages/client/src/theme/defaults.css
@@ -116,6 +116,7 @@ html {
--surface-tertiary: var(--gray-100);
--surface-tertiary-alt: var(--white);
--surface-dialog: var(--white);
+ --dialog-title: var(--text-primary);
--surface-overlay: var(--gray-500);
--surface-submit: var(--green-700);
--surface-submit-hover: var(--green-800);
@@ -184,8 +185,8 @@ html {
--surface-inverted: var(--gray-850);
--surface-inverted-hover: var(--gray-700);
--surface-inverted-pressed: var(--gray-700);
- --button-primary: var(--gray-850);
- --button-primary-hover: var(--gray-700);
+ --button-primary: var(--surface-inverted);
+ --button-primary-hover: var(--surface-inverted-hover);
--surface-disabled: var(--gray-100);
--text-inverted: var(--white);
--surface-fixed: var(--white);
@@ -214,6 +215,13 @@ html {
--theme-space-compact: 0.375rem;
--theme-space-normal: 0.75rem;
--theme-disabled-style: dim;
+ --theme-dialog-stroke: 0px;
+ --theme-dialog-padding-x: 1.5rem;
+ --theme-dialog-header-gap: 0.375rem;
+ --theme-dialog-title-size: var(--theme-text-lg, 1.125rem);
+ --theme-dialog-title-leading: 1;
+ --theme-dialog-title-font-weight: 600;
+ --theme-dialog-title-font-family: var(--theme-display-font-family, Inter, sans-serif);
--theme-scrim-opacity: 0.8;
--theme-alert-scrim-opacity: 0.9;
--theme-modal-scrim-opacity: 0.65;
@@ -306,6 +314,7 @@ html {
--surface-tertiary: var(--gray-700);
--surface-tertiary-alt: var(--gray-700);
--surface-dialog: var(--gray-875);
+ --dialog-title: var(--text-primary);
--surface-overlay: 0 0 0;
--surface-submit: var(--green-700);
--surface-submit-hover: var(--green-800);
@@ -372,8 +381,8 @@ html {
--surface-inverted: var(--white);
--surface-inverted-hover: var(--gray-100);
--surface-inverted-pressed: var(--gray-100);
- --button-primary: var(--white);
- --button-primary-hover: var(--gray-100);
+ --button-primary: var(--surface-inverted);
+ --button-primary-hover: var(--surface-inverted-hover);
--surface-disabled: var(--gray-700);
--text-inverted: var(--gray-850);
--surface-fixed: var(--white);
diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts
index f6f03a5076..d65c88b84c 100644
--- a/packages/client/src/theme/defaults.spec.ts
+++ b/packages/client/src/theme/defaults.spec.ts
@@ -63,7 +63,7 @@ describe.each([
const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
it('covers every registry color', () => {
- expect(tokens).toHaveLength(111);
+ expect(tokens).toHaveLength(112);
});
it('resolves every registry color to the runtime theme value', () => {
@@ -77,11 +77,31 @@ 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. */
+/** Roles split out of a broader one alias it, so a stylesheet that sets only the broader role
+ * still reaches what the split role draws. */
const stockAliases: Partial<
Record<keyof typeof defaultAppearance, keyof typeof defaultAppearance>
-> = { controlPaddingX: 'spaceNormal', controlGap: 'spaceCompact' };
+> = {
+ controlPaddingX: 'spaceNormal',
+ controlGap: 'spaceCompact',
+ dialogTitleSize: 'textLg',
+ dialogTitleFontFamily: 'displayFontFamily',
+};
+
+/** Color roles split out of a broader one read it in the stylesheet, in both modes, so a
+ * stylesheet that overrides only the broader role still reaches what the split role paints. */
+const colorAliases: Array<[string, string]> = [
+ ['--button-primary', '--surface-inverted'],
+ ['--button-primary-hover', '--surface-inverted-hover'],
+ ['--dialog-title', '--text-primary'],
+];
+
+describe('the stock color aliases', () => {
+ it.each(colorAliases)('declares %s as the %s it split from', (property, source) => {
+ expect(light.get(property)).toBe(`var(${source})`);
+ expect(dark.get(property) ?? light.get(property)).toBe(`var(${source})`);
+ });
+});
describe('the stock appearance and brands', () => {
it('declares every appearance property with the registry default', () => {
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index 9da2d10b39..70aa00fc1b 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -762,6 +762,113 @@ describe('theme registry', () => {
);
});
+ it('keeps LibreChat’s dialog chrome by default', () => {
+ expect(defaultAppearance).toMatchObject({
+ dialogStroke: '0px',
+ dialogPaddingX: '1.5rem',
+ dialogHeaderGap: '0.375rem',
+ dialogTitleSize: defaultAppearance.textLg,
+ dialogTitleLeading: '1',
+ dialogTitleFontWeight: '600',
+ dialogTitleFontFamily: defaultAppearance.displayFontFamily,
+ });
+ expect(defaultTheme['rgb-dialog-title']).toBe(defaultTheme['rgb-text-primary']);
+ expect(darkTheme['rgb-dialog-title']).toBe(darkTheme['rgb-text-primary']);
+ });
+
+ it('keeps the dialog titles of a theme that predates the roles on its type and ink', () => {
+ const { colors, appearance } = resolveTheme(
+ {
+ version: 1,
+ name: 'type-reference',
+ modes: {
+ light: {
+ colors: { 'rgb-text-primary': '10 20 30' },
+ appearance: { fontFamily: 'Georgia, serif', textLg: '1.4rem' },
+ },
+ },
+ },
+ 'light',
+ );
+
+ expect(colors['rgb-dialog-title']).toBe('10 20 30');
+ /** The family chains through the display role, which itself follows `fontFamily`. */
+ expect(appearance.displayFontFamily).toBe('Georgia, serif');
+ expect(appearance.dialogTitleFontFamily).toBe('Georgia, serif');
+ expect(appearance.dialogTitleSize).toBe('1.4rem');
+ });
+
+ it('draws dialog chrome from its own roles apart from the type scale and body ink', () => {
+ const { colors, appearance } = resolveTheme(
+ {
+ version: 1,
+ name: 'framed-dialog-reference',
+ modes: {
+ dark: {
+ colors: { 'rgb-dialog-title': '200 30 90' },
+ appearance: {
+ dialogStroke: '3px',
+ dialogPaddingX: '3rem',
+ dialogHeaderGap: '1rem',
+ dialogTitleSize: '2rem',
+ dialogTitleLeading: '1.2',
+ dialogTitleFontWeight: '800',
+ dialogTitleFontFamily: 'Georgia, serif',
+ },
+ },
+ },
+ },
+ 'dark',
+ );
+
+ expect(colors['rgb-text-primary']).toBe(darkTheme['rgb-text-primary']);
+ expect(colors['rgb-dialog-title']).toBe('200 30 90');
+ expect(appearance.textLg).toBe(defaultAppearance.textLg);
+ expect(appearance.displayFontFamily).toBe(defaultAppearance.displayFontFamily);
+ expect(appearance).toMatchObject({
+ dialogStroke: '3px',
+ dialogPaddingX: '3rem',
+ dialogHeaderGap: '1rem',
+ dialogTitleSize: '2rem',
+ dialogTitleLeading: '1.2',
+ dialogTitleFontWeight: '800',
+ dialogTitleFontFamily: 'Georgia, serif',
+ });
+ });
+
+ it('does not count the dialog title ink among the surfaces the verified mark sits on', () => {
+ const { colors } = resolveTheme(
+ {
+ version: 1,
+ name: 'title-ink-reference',
+ modes: { light: { colors: { 'rgb-dialog-title': '200 30 90' } } },
+ },
+ 'light',
+ );
+
+ expect(colors['rgb-status-verified']).toBe(defaultTheme['rgb-status-verified']);
+ });
+
+ it('rejects dialog chrome values the shared validators refuse', () => {
+ const issues = (appearance: Record<string, string>) =>
+ validateThemeDefinition({
+ version: 1,
+ name: 'dialog-values',
+ modes: { light: { appearance } },
+ });
+
+ expect(issues({ dialogStroke: '1px', dialogTitleLeading: '1.5' })).toEqual([]);
+ [
+ { dialogStroke: 'thin' },
+ { dialogPaddingX: '2' },
+ { dialogHeaderGap: 'red' },
+ { dialogTitleSize: '1.25rem;' },
+ { dialogTitleLeading: 'calc(1 / 0)' },
+ { dialogTitleFontWeight: '1001' },
+ { dialogTitleFontFamily: 'Inter; color: red' },
+ ].forEach((appearance) => expect(issues(appearance)).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 ed9507d730..d23225ef64 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -118,6 +118,12 @@ export function primaryButtonFallbacks(colors: IThemeRGB): IThemeRGB {
};
}
+/** Dialog titles were set in the primary ink, so a theme that repaints it keeps its titles on it. */
+export function dialogTitleFallback(colors: IThemeRGB): IThemeRGB {
+ const title = colors['rgb-dialog-title'] ?? colors['rgb-text-primary'];
+ return title !== undefined ? { 'rgb-dialog-title': title } : {};
+}
+
/**
* The focus roles for a stored or environment theme that predates them. The
* global outline followed a theme's `rgb-ring-primary` whenever it named one,
@@ -175,6 +181,13 @@ export const themeAppearanceProperties: Readonly<
leadingLg: '--theme-text-lg-leading',
leadingXl: '--theme-text-xl-leading',
leading2xl: '--theme-text-2xl-leading',
+ dialogStroke: '--theme-dialog-stroke',
+ dialogPaddingX: '--theme-dialog-padding-x',
+ dialogHeaderGap: '--theme-dialog-header-gap',
+ dialogTitleSize: '--theme-dialog-title-size',
+ dialogTitleLeading: '--theme-dialog-title-leading',
+ dialogTitleFontWeight: '--theme-dialog-title-font-weight',
+ dialogTitleFontFamily: '--theme-dialog-title-font-family',
scrimOpacity: '--theme-scrim-opacity',
alertScrimOpacity: '--theme-alert-scrim-opacity',
modalScrimOpacity: '--theme-modal-scrim-opacity',
@@ -229,6 +242,13 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
leadingLg: 'calc(1.75 / 1.125)',
leadingXl: 'calc(1.75 / 1.25)',
leading2xl: 'calc(2 / 1.5)',
+ dialogStroke: '0px',
+ dialogPaddingX: '1.5rem',
+ dialogHeaderGap: '0.375rem',
+ dialogTitleSize: '1.125rem',
+ dialogTitleLeading: '1',
+ dialogTitleFontWeight: '600',
+ dialogTitleFontFamily: 'Inter, sans-serif',
scrimOpacity: '0.8',
alertScrimOpacity: '0.9',
modalScrimOpacity: '0.65',
@@ -375,23 +395,29 @@ function withComposableShadows(appearance: IThemeAppearance): IThemeAppearance {
/**
* 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.
+ * family before the display role existed, theme-sized controls were padded by the shared spacing,
+ * and dialog titles were set in the `text-lg` step and the display family, so a theme that names
+ * the broader role and not the split one keeps what it drew. Pairs resolve in order, so a role can
+ * follow one that is itself inherited.
*/
const inheritedAppearance: ReadonlyArray<[keyof IThemeAppearance, keyof IThemeAppearance]> = [
['displayFontFamily', 'fontFamily'],
['controlPaddingX', 'spaceNormal'],
['controlGap', 'spaceCompact'],
+ ['dialogTitleSize', 'textLg'],
+ ['dialogTitleFontFamily', 'displayFontFamily'],
];
function withInheritedRoles(appearance?: Partial<IThemeAppearance>): IThemeAppearance {
const known = knownAppearance(appearance);
- const inherited = Object.fromEntries(
- inheritedAppearance
- .filter(([role, source]) => known[role] === undefined && known[source] !== undefined)
- .map(([role, source]) => [role, known[source]]),
+ const resolved = inheritedAppearance.reduce<Partial<IThemeAppearance>>(
+ (roles, [role, source]) =>
+ roles[role] === undefined && roles[source] !== undefined
+ ? { ...roles, [role]: roles[source] }
+ : roles,
+ known,
);
- return { ...defaultAppearance, ...known, ...inherited };
+ return { ...defaultAppearance, ...resolved };
}
export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedThemeDefinition {
@@ -521,6 +547,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
const focusFallback = customColors != null ? focusFallbacks(customColors) : {};
const pressedFallback = customColors != null ? pressedFallbacks(customColors) : {};
const primaryButtonFallback = customColors != null ? primaryButtonFallbacks(customColors) : {};
+ const dialogTitleColor = customColors != null ? dialogTitleFallback(customColors) : {};
/**
* Slot 8 arrived after the seven-slot scale shipped, so a stored or
* environment theme that paints its own scale cannot name it. Filling the
@@ -590,6 +617,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...focusFallback,
...pressedFallback,
...primaryButtonFallback,
+ ...dialogTitleColor,
...seriesEightFallback,
...verifiedFallback,
} as Required<IThemeRGB>,
diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.ts
index db2eea9337..1530ea29c2 100644
--- a/packages/client/src/theme/semanticTokens.spec.ts
+++ b/packages/client/src/theme/semanticTokens.spec.ts
@@ -782,6 +782,24 @@ describe('state role defaults', () => {
expect(theme['rgb-button-primary']).toBe(theme['rgb-surface-inverted']);
expect(theme['rgb-button-primary-hover']).toBe(theme['rgb-surface-inverted-hover']);
});
+
+ it.each([
+ ['default light', defaultTheme],
+ ['default dark', darkTheme],
+ ['high contrast light', highContrastLightTheme],
+ ['high contrast dark', highContrastDarkTheme],
+ ])('sets %s dialog titles in the primary ink', (_name, theme: IThemeRGB) => {
+ expect(theme['rgb-dialog-title']).toBe(theme['rgb-text-primary']);
+ });
+
+ it.each([
+ ['clickhouse light', clickHouseLightTheme],
+ ['clickhouse dark', clickHouseDarkTheme],
+ ])('keeps %s dialog titles at AA on the dialog surface', (_name, theme: IThemeRGB) => {
+ expect(
+ contrast(toRgb(theme, 'rgb-dialog-title'), toRgb(theme, 'rgb-surface-dialog')),
+ ).toBeGreaterThanOrEqual(4.5);
+ });
});
/**
diff --git a/packages/client/src/theme/tailwind.spec.js b/packages/client/src/theme/tailwind.spec.js
index b4f3ec979d..fdf8d438a3 100644
--- a/packages/client/src/theme/tailwind.spec.js
+++ b/packages/client/src/theme/tailwind.spec.js
@@ -107,6 +107,12 @@ describe('LibreChat Tailwind preset', () => {
['h-theme-button', '--theme-button-height', defaultAppearance.buttonHeight],
['h-theme-button-sm', '--theme-button-height-sm', defaultAppearance.buttonHeightSm],
['font-theme-control', '--theme-control-font-weight', defaultAppearance.controlFontWeight],
+ ['px-theme-dialog-x', '--theme-dialog-padding-x', defaultAppearance.dialogPaddingX],
+ [
+ 'font-theme-dialog-title-weight',
+ '--theme-dialog-title-font-weight',
+ defaultAppearance.dialogTitleFontWeight,
+ ],
['w-theme-switch', '--theme-switch-width', defaultAppearance.switchWidth],
['size-theme-switch-thumb', '--theme-switch-height', defaultAppearance.switchHeight],
['translate-x-theme-switch-travel', '--theme-switch-width', defaultAppearance.switchWidth],
@@ -151,6 +157,8 @@ describe('LibreChat Tailwind preset', () => {
...roles.map(([candidate]) => candidate),
'px-theme-control-x',
'gap-theme-control-gap',
+ 'font-theme-dialog-title',
+ 'space-y-theme-dialog-header',
'font-sans',
'p-4',
]);
@@ -175,6 +183,12 @@ describe('LibreChat Tailwind preset', () => {
`gap: var(--theme-control-gap, var(--theme-space-compact, ${defaultAppearance.spaceCompact}))`,
);
+ /** A dialog title falls back to the display family it was set in. */
+ expect(rule(css, 'font-theme-dialog-title')).toContain(
+ 'font-family: var(--theme-dialog-title-font-family, var(--theme-display-font-family, inherit))',
+ );
+ expect(css).toContain(`var(--theme-dialog-header-gap, ${defaultAppearance.dialogHeaderGap})`);
+
/** The preset extends the default theme rather than replacing it. */
expect(css).toContain('.font-sans');
expect(css).toContain('.p-4');
@@ -222,8 +236,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' };
+ /** Roles split out of a broader one alias the role they were split from. */
+ const aliases = {
+ controlPaddingX: 'spaceNormal',
+ controlGap: 'spaceCompact',
+ dialogTitleSize: 'textLg',
+ dialogTitleFontFamily: 'displayFontFamily',
+ };
Object.entries(themeAppearanceProperties).forEach(([key, property]) => {
const value = aliases[key]
? `var(${themeAppearanceProperties[aliases[key]]}, ${defaultAppearance[key]})`
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index cbdb71ad1a..585324a2c7 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -76,6 +76,7 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-surface-tertiary': '246 247 250', // #f6f7fa (background.muted)
'rgb-surface-tertiary-alt': '255 255 255', // #ffffff (background.default)
'rgb-surface-dialog': '255 255 255', // #ffffff (background.default)
+ 'rgb-dialog-title': '30 29 31', // #1e1d1f (dialog.color.title.default, lch(11.126 1.374 305.43))
'rgb-surface-overlay': '21 21 21', // #151515 (dialog.color.opaqueBackground, lch(6.7738 0 none))
'rgb-surface-submit': '21 21 21', // #151515 (accent.default)
'rgb-surface-submit-hover': '50 50 50', // #323232 (palette.neutral.712)
@@ -216,6 +217,7 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-surface-tertiary': '40 40 40', // #282828 (background.muted)
'rgb-surface-tertiary-alt': '50 50 50', // #323232 (palette.neutral.712)
'rgb-surface-dialog': '31 31 28', // #1f1f1c (background.default)
+ 'rgb-dialog-title': '249 249 249', // #f9f9f9 (dialog.color.title.default, rgb(97.5% 97.5% 97.5%))
/** Not a Click UI value. Its dark scrim, dialog.color.opaqueBackground lch(40.731 0 none), is a
* #606060 gray that lifts the page instead of dimming it. A bundled scrim never lifts the page
* (`semanticTokens.spec.ts`), so black keeps the dark scrim; the 0.75 alpha is Click UI's. */
@@ -376,6 +378,16 @@ const clickHouseShape = {
* 0.875rem/1.5 label and a 1px stroke, 32px in all. */
buttonHeight: '2rem',
buttonHeightSm: '2rem',
+ dialogStroke: '1px', // dialog.stroke.default, in stroke.default (border-light)
+ dialogPaddingX: '2rem', // dialog.space.x; its space.y is LibreChat's 1.5rem
+ dialogHeaderGap: '0.25rem', // dialog.title.space.gap
+ /** `dialog.typography.title.default`: 700 1.25rem/1.5 in the regular family, not the display
+ * one Click UI keeps for page titles. */
+ dialogTitleSize: '1.25rem',
+ dialogTitleLeading: '1.5',
+ dialogTitleFontWeight: '700',
+ dialogTitleFontFamily:
+ '"Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif',
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 6e4e3935a7..3f42f51ee1 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -33,7 +33,10 @@
"click.dialog.color.opaqueBackground.default": "lch(6.7738 0 none / 0.75)",
"click.dialog.color.title.default": "lch(11.126 1.374 305.43)",
"click.dialog.radii.all": "0.5rem",
+ "click.dialog.space.x": "2rem",
"click.dialog.stroke.default": "1px solid #e6e7e9",
+ "click.dialog.title.space.gap": "0.25rem",
+ "click.dialog.typography.title.default": "700 1.25rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.field.color.background.default": "#fbfcff",
"click.field.color.stroke.default": "#e6e7e9",
"click.field.color.stroke.disabled": "#dfdfdf",
@@ -152,7 +155,10 @@
"click.dialog.color.opaqueBackground.default": "lch(40.731 0 none / 0.75)",
"click.dialog.color.title.default": "rgb(97.5% 97.5% 97.5%)",
"click.dialog.radii.all": "0.5rem",
+ "click.dialog.space.x": "2rem",
"click.dialog.stroke.default": "1px solid #323232",
+ "click.dialog.title.space.gap": "0.25rem",
+ "click.dialog.typography.title.default": "700 1.25rem/1.5 \"Inter\", \"SF Pro Display\", -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif;",
"click.field.color.background.default": "rgb(17.794% 17.794% 17.794%)",
"click.field.color.stroke.default": "rgb(23.627% 23.627% 23.627%)",
"click.field.color.stroke.disabled": "#414141",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index 937f533aeb..30e8ca42f0 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -91,6 +91,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-tertiary': 'global.color.background.muted',
'rgb-surface-tertiary-alt': 'global.color.background.default',
'rgb-surface-dialog': 'global.color.background.default',
+ 'rgb-dialog-title': 'click.dialog.color.title.default',
'rgb-surface-overlay': 'click.dialog.color.opaqueBackground.default',
'rgb-surface-submit': 'global.color.accent.default',
'rgb-surface-submit-hover': 'palette.neutral.712',
@@ -204,6 +205,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-tertiary': 'global.color.background.muted',
'rgb-surface-tertiary-alt': 'palette.neutral.712',
'rgb-surface-dialog': 'global.color.background.default',
+ 'rgb-dialog-title': 'click.dialog.color.title.default',
'rgb-surface-submit': 'global.color.accent.default',
'rgb-surface-submit-hover': 'palette.brand.200',
'rgb-surface-destructive': 'palette.danger.300',
@@ -482,6 +484,13 @@ const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
controlPaddingX: 'click.button.basic.space.x',
controlGap: 'click.button.basic.space.gap',
controlFontWeight: 'click.button.basic.typography.label.default',
+ dialogStroke: 'click.dialog.stroke.default',
+ dialogPaddingX: 'click.dialog.space.x',
+ dialogHeaderGap: 'click.dialog.title.space.gap',
+ dialogTitleSize: 'click.dialog.typography.title.default',
+ dialogTitleLeading: 'click.dialog.typography.title.default',
+ dialogTitleFontWeight: 'click.dialog.typography.title.default',
+ dialogTitleFontFamily: 'click.dialog.typography.title.default',
scrimOpacity: 'click.dialog.color.opaqueBackground.default',
alertScrimOpacity: 'click.dialog.color.opaqueBackground.default',
modalScrimOpacity: 'click.dialog.color.opaqueBackground.default',
@@ -645,6 +654,16 @@ const scrimKeys: ReadonlySet<keyof IThemeAppearance> = new Set([
'modalScrimOpacity',
]);
+/** Roles read out of a Click UI `font` shorthand, and the part each one is. */
+const fontShorthandParts: Partial<
+ Record<keyof IThemeAppearance, 'weight' | 'size' | 'leading' | 'family'>
+> = {
+ dialogTitleFontWeight: 'weight',
+ dialogTitleSize: 'size',
+ dialogTitleLeading: 'leading',
+ dialogTitleFontFamily: 'family',
+};
+
function comparable(key: keyof IThemeAppearance, raw: string | number): string {
const value = String(raw);
/** A scrim role is the alpha of Click UI's scrim color; the color itself is `surface-overlay`. */
@@ -663,6 +682,16 @@ function comparable(key: keyof IThemeAppearance, raw: string | number): string {
if (key === 'controlFontWeight') {
return value.trim().split(/\s+/)[0];
}
+ /** A title or label is a `weight size/leading family` shorthand, one part per role. */
+ if (fontShorthandParts[key] !== undefined) {
+ const [, weight, size, leading, family] =
+ /^(\d+)\s+([^/\s]+)\/(\S+)\s+(.+?);?$/.exec(value.trim()) ?? [];
+ return { weight, size, leading, family }[fontShorthandParts[key]] ?? value;
+ }
+ /** A stroke is `width style color`; the role is its width, and its color is `border-light`. */
+ if (key === 'dialogStroke') {
+ return value.trim().split(/\s+/)[0];
+ }
return value.replace(/;$/, '').trim();
}
@@ -912,7 +941,6 @@ const parityProbes: Record<string, ParityProbe> = {
kind: 'color',
utility: 'text',
element: dialogProbe('h2'),
- near: ['light', 'dark'],
},
'Dialog scrim': {
token: 'click.dialog.color.opaqueBackground.default',
@@ -923,6 +951,12 @@ const parityProbes: Record<string, ParityProbe> = {
dark: 'surface-overlay keeps the dark scrim black; Click UI #606060 lifts the page it covers',
},
},
+ 'Dialog inline padding': {
+ token: 'click.dialog.space.x',
+ kind: 'shape',
+ utility: 'px',
+ element: dialogProbe('[role="dialog"]'),
+ },
'Dialog corner': {
token: 'click.dialog.radii.all',
kind: 'shape',
@@ -1072,12 +1106,6 @@ const notExpressible: Record<string, NotExpressible> = {
'the field is transparent and inks with text-primary; a color role is an opaque triplet, so no role can default to no fill, and no role holds field ink apart from body copy',
issue: 'https://github.com/berry-13/LibreChat/issues/206',
},
- 'Dialog edge': {
- decisions: { light: ['Dialog stroke'], dark: ['Dialog stroke'] },
- reason:
- 'the dialog draws no border and no role sets a dialog stroke width, so a 1px edge would change the default dialog',
- issue: 'https://github.com/berry-13/LibreChat/issues/138',
- },
'Badge label': {
decisions: { light: ['Badge label'], dark: ['Badge label'] },
reason:
@@ -1134,7 +1162,7 @@ const sizeRoles: Record<SizeUtility, Record<string, keyof IThemeAppearance>> = {
'theme-button-sm': 'buttonHeightSm',
},
py: { 'theme-table-cell': 'tableCellSpaceY' },
- px: { 'theme-control-x': 'controlPaddingX' },
+ px: { 'theme-control-x': 'controlPaddingX', 'theme-dialog-x': 'dialogPaddingX' },
gap: { 'theme-control-gap': 'controlGap' },
};
@@ -1153,7 +1181,9 @@ const drawsBorder = (classes: string[], resolved: Resolved) =>
(name) =>
/^border(-[0-9]+|-[xytblrse](-[0-9]+)?)?$/.test(name) ||
(/^border(-[xytblrse])?-\(length:--theme-table-row-stroke\)$/.test(name) &&
- parseFloat(resolved.appearance.tableRowStroke) > 0),
+ parseFloat(resolved.appearance.tableRowStroke) > 0) ||
+ (name === 'border-(length:--theme-dialog-stroke)' &&
+ parseFloat(resolved.appearance.dialogStroke) > 0),
);
type Resolved = ReturnType<typeof resolveTheme>;
diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts
index 332bcac3a2..2b6c74380e 100644
--- a/packages/client/src/theme/themes/dark.ts
+++ b/packages/client/src/theme/themes/dark.ts
@@ -51,6 +51,7 @@ export const darkTheme: IThemeRGB = {
'rgb-surface-tertiary': '47 47 47', // #2f2f2f (gray-700)
'rgb-surface-tertiary-alt': '47 47 47', // #2f2f2f (gray-700)
'rgb-surface-dialog': '18 18 18', // #121212 (legacy dark dialog)
+ 'rgb-dialog-title': '236 236 236', // #ececec (gray-100, matching text-primary)
'rgb-surface-overlay': '0 0 0', // #000 (black)
'rgb-surface-submit': '4 120 87', // #047857 (green-700)
'rgb-surface-submit-hover': '6 95 70', // #065f46 (green-800)
diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts
index c0b6b9fa7a..82aac5adab 100644
--- a/packages/client/src/theme/themes/default.ts
+++ b/packages/client/src/theme/themes/default.ts
@@ -51,6 +51,7 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-tertiary': '236 236 236', // #ececec (gray-100)
'rgb-surface-tertiary-alt': '255 255 255', // #fff (white)
'rgb-surface-dialog': '255 255 255', // #fff (white)
+ 'rgb-dialog-title': '33 33 33', // #212121 (gray-800, matching text-primary)
'rgb-surface-overlay': '89 89 89', // #595959 (gray-500)
'rgb-surface-submit': '4 120 87', // #047857 (green-700)
'rgb-surface-submit-hover': '6 95 70', // #065f46 (green-800)
diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts
index 1c20852a13..a08cea6138 100644
--- a/packages/client/src/theme/themes/highContrast.ts
+++ b/packages/client/src/theme/themes/highContrast.ts
@@ -87,6 +87,7 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-surface-tertiary': '255 255 255', // #ffffff
'rgb-surface-tertiary-alt': '255 255 255', // #ffffff
'rgb-surface-dialog': '255 255 255', // #ffffff
+ 'rgb-dialog-title': '0 0 0', // #000000 (matching text-primary)
'rgb-surface-overlay': '0 0 0', // #000000
'rgb-surface-submit': '0 92 46', // #005c2e
'rgb-surface-submit-hover': '0 61 30', // #003d1e
@@ -246,6 +247,7 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-surface-tertiary': '0 0 0', // #000000
'rgb-surface-tertiary-alt': '0 0 0', // #000000
'rgb-surface-dialog': '0 0 0', // #000000
+ 'rgb-dialog-title': '255 255 255', // #ffffff (matching text-primary)
'rgb-surface-overlay': '0 0 0', // #000000
'rgb-surface-submit': '127 240 179', // #7ff0b3
'rgb-surface-submit-hover': '163 245 204', // #a3f5cc
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index 9aca03c885..8c3823fa6c 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -48,6 +48,8 @@
--color-surface-tertiary: rgb(var(--surface-tertiary));
--color-surface-tertiary-alt: rgb(var(--surface-tertiary-alt));
--color-surface-dialog: rgb(var(--surface-dialog));
+ /* Falls back to the ink dialog titles were set in, for a stylesheet that predates it. */
+ --color-dialog-title: rgb(var(--dialog-title, var(--text-primary)));
--color-surface-overlay: rgb(var(--surface-overlay));
/* The dialog scrims: the overlay at the opacity each dialog family's appearance
* role sets (OGDialog, AlertDialog, Dialog), defaulting to the 80%, 90% and 65%
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index c7236ec718..e6e16a8053 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -55,6 +55,8 @@ export interface IThemeRGB {
'rgb-surface-tertiary'?: string;
'rgb-surface-tertiary-alt'?: string;
'rgb-surface-dialog'?: string;
+ /** An OGDialog title's ink; follows `rgb-text-primary` when a theme omits it. */
+ 'rgb-dialog-title'?: string;
'rgb-surface-overlay'?: string;
'rgb-surface-submit'?: string;
'rgb-surface-submit-hover'?: string;
@@ -226,6 +228,7 @@ export interface IThemeVariables {
'--surface-tertiary': string;
'--surface-tertiary-alt': string;
'--surface-dialog': string;
+ '--dialog-title': string;
'--surface-overlay': string;
'--surface-submit': string;
'--surface-submit-hover': string;
@@ -349,6 +352,7 @@ export interface IThemeColors {
'surface-tertiary'?: string;
'surface-tertiary-alt'?: string;
'surface-dialog'?: string;
+ 'dialog-title'?: string;
'surface-overlay'?: string;
'surface-submit'?: string;
'surface-submit-hover'?: string;
@@ -461,7 +465,7 @@ export interface IThemeAppearance {
disabledStyle: 'dim' | 'fill';
fontFamily: string;
monoFontFamily: string;
- /** Headings and dialog titles; follows `fontFamily` when a theme omits it. */
+ /** Headings; follows `fontFamily` when a theme omits it. */
displayFontFamily: string;
/** The `text-*` scale: size and line height per step, Tailwind's own values by default. */
textXs: string;
@@ -476,6 +480,18 @@ export interface IThemeAppearance {
leadingLg: string;
leadingXl: string;
leading2xl: string;
+ /**
+ * An OGDialog's edge stroke width (painted in `border-light`), inline padding and title to
+ * description gap, and its title's size, leading, weight and family. The title follows `textLg`
+ * and `displayFontFamily` when a theme omits its size and family.
+ */
+ dialogStroke: string;
+ dialogPaddingX: string;
+ dialogHeaderGap: string;
+ dialogTitleSize: string;
+ dialogTitleLeading: string;
+ dialogTitleFontWeight: string;
+ dialogTitleFontFamily: string;
/** Opacity of `surface-overlay` under OGDialog, AlertDialog and Dialog, in that order. */
scrimOpacity: string;
alertScrimOpacity: string;
diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.ts
index 5350b6cde5..e9e71d6b88 100644
--- a/packages/client/src/theme/utils/applyTheme.spec.ts
+++ b/packages/client/src/theme/utils/applyTheme.spec.ts
@@ -352,6 +352,14 @@ describe('applyTheme', () => {
expect(root.style.getPropertyValue('--surface-inverted-pressed')).toBe('20 21 22');
});
+ it('sets dialog titles in the primary ink of a theme that predates the role', () => {
+ const root = document.documentElement;
+
+ applyTheme({ 'rgb-text-primary': '30 31 32' }, root, defaultTheme);
+
+ expect(root.style.getPropertyValue('--dialog-title')).toBe('30 31 32');
+ });
+
it('fills the primary button with the inverted surface of a theme that predates the role', () => {
const root = document.documentElement;
diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.ts
index 4990064d47..0001be2a06 100644
--- a/packages/client/src/theme/utils/applyTheme.ts
+++ b/packages/client/src/theme/utils/applyTheme.ts
@@ -4,6 +4,7 @@ import {
focusFallbacks,
pressedFallbacks,
primaryButtonFallbacks,
+ dialogTitleFallback,
MARK_NEIGHBOURHOOD,
themeAppearanceProperties,
themeBrandTokens,
@@ -126,6 +127,11 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]>
variables.push(['--button-primary-hover', primary['rgb-button-primary-hover']]);
}
+ const title = dialogTitleFallback(colors)['rgb-dialog-title'];
+ if (colors['rgb-dialog-title'] === undefined && title !== undefined) {
+ variables.push(['--dialog-title', title]);
+ }
+
/**
* Same rule as `resolveTheme`: a theme that paints what the mark is measured
* against coordinated the `status-success-strong` the mark wore before it had
diff --git a/packages/client/src/utils/utils.ts b/packages/client/src/utils/utils.ts
index 5f58a126bb..da8034b89e 100644
--- a/packages/client/src/utils/utils.ts
+++ b/packages/client/src/utils/utils.ts
@@ -14,9 +14,11 @@ const twMerge = extendTailwindMerge({
h: [
{ h: ['theme-table-head', 'theme-table-head-compact', 'theme-button', 'theme-button-sm'] },
],
- px: [{ px: ['theme-control-x'] }],
+ px: [{ px: ['theme-control-x', 'theme-dialog-x'] }],
gap: [{ gap: ['theme-control-gap'] }],
- 'font-weight': [{ font: ['theme-control'] }],
+ 'space-y': [{ 'space-y': ['theme-dialog-header'] }],
+ 'font-weight': [{ font: ['theme-control', 'theme-dialog-title-weight'] }],
+ 'font-family': [{ font: ['theme-dialog-title'] }],
},
},
});
diff --git a/packages/client/tailwind.preset.cjs b/packages/client/tailwind.preset.cjs
index 305177aa8f..ad05aafd13 100644
--- a/packages/client/tailwind.preset.cjs
+++ b/packages/client/tailwind.preset.cjs
@@ -4,10 +4,16 @@ module.exports = {
extend: {
fontFamily: {
'theme-ui': ['var(--theme-font-family, Inter, sans-serif)'],
+ /** A dialog title's family, the display family unless a theme names its own. */
+ 'theme-dialog-title': [
+ 'var(--theme-dialog-title-font-family, var(--theme-display-font-family, inherit))',
+ ],
},
fontWeight: {
/** A theme-sized control's label weight. */
'theme-control': 'var(--theme-control-font-weight, 500)',
+ /** A dialog title's weight; `-weight` keeps it apart from the family of the same name. */
+ 'theme-dialog-title-weight': 'var(--theme-dialog-title-font-weight, 600)',
},
height: {
'theme-control': 'var(--theme-control-height, 2.25rem)',
@@ -33,6 +39,9 @@ module.exports = {
* 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))',
+ /** A dialog's inline padding and the gap between its title and description. */
+ 'theme-dialog-x': 'var(--theme-dialog-padding-x, 1.5rem)',
+ 'theme-dialog-header': 'var(--theme-dialog-header-gap, 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 2e5370c807..91780b6fce 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -51,6 +51,7 @@ export const themeColorTokens = Object.freeze([
'rgb-surface-tertiary',
'rgb-surface-tertiary-alt',
'rgb-surface-dialog',
+ 'rgb-dialog-title',
'rgb-surface-overlay',
'rgb-surface-submit',
'rgb-surface-submit-hover',
@@ -350,6 +351,15 @@ const appearanceValidators = {
leadingLg: isLineHeight,
leadingXl: isLineHeight,
leading2xl: isLineHeight,
+ /** A dialog's edge stroke width, inline padding and title-to-description gap, and its title's
+ * size, leading, weight and family. */
+ dialogStroke: isLength,
+ dialogPaddingX: isLength,
+ dialogHeaderGap: isLength,
+ dialogTitleSize: isLength,
+ dialogTitleLeading: isLineHeight,
+ dialogTitleFontWeight: isFontWeight,
+ dialogTitleFontFamily: isFontFamily,
/** How much of `surface-overlay` each dialog family's scrim lays over the page. */
scrimOpacity: isOpacity,
alertScrimOpacity: isOpacity,