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 Pressed and Disabled States Their Own Theme Roles (#16487)

Marco Berettab2da59f08da2
diff --git a/client/src/Providers/__tests__/DeploymentTheme.spec.tsx b/client/src/Providers/__tests__/DeploymentTheme.spec.tsx
index a38f928782..2972563466 100644
--- a/client/src/Providers/__tests__/DeploymentTheme.spec.tsx
+++ b/client/src/Providers/__tests__/DeploymentTheme.spec.tsx
@@ -172,10 +172,31 @@ describe('DeploymentTheme', () => {
expect(snapshotStorage()).toEqual(before);
});
+ it('applies an inline definition carrying a color role this build predates', async () => {
+ serveTheme({
+ ...inlineTheme,
+ modes: {
+ ...inlineTheme.modes,
+ light: {
+ ...inlineTheme.modes.light,
+ colors: { ...inlineTheme.modes.light.colors, 'rgb-future-role': '1 2 3' },
+ },
+ },
+ });
+ renderTheme(queryClient);
+
+ await waitFor(() => expect(root().dataset.theme).toBe('acme'));
+ expect(root().style.getPropertyValue('--surface-primary')).toBe('10 20 30');
+ expect(root().getAttribute('style')).not.toContain('--future-role');
+ expect(warn).toHaveBeenCalledWith(
+ '[ThemeProvider] Unknown light color token ignored: rgb-future-role',
+ );
+ });
+
it('ignores an invalid inline definition with a warning and keeps the stored theme', async () => {
serveTheme({
...inlineTheme,
- modes: { light: { colors: { 'rgb-not-a-token': '1 2 3' } } },
+ modes: { light: { colors: { 'rgb-not-a-token': 'red' } } },
});
renderTheme(queryClient);
diff --git a/client/src/style.css b/client/src/style.css
index b02463a00e..4a5145a212 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -321,6 +321,7 @@ html {
--theme-control-height: 2.25rem;
--theme-space-compact: 0.375rem;
--theme-space-normal: 0.75rem;
+ --theme-disabled-style: dim;
--theme-font-family: Inter, sans-serif;
/* Roboto Mono is self-hosted (the `@font-face` block below), so code renders the same on every
* platform with real bold and italic faces. The tail is reached while the font loads, if it
diff --git a/e2e/specs/mock/scenarios/deployment-theme.spec.ts b/e2e/specs/mock/scenarios/deployment-theme.spec.ts
index 5915f03bad..3a032588b1 100644
--- a/e2e/specs/mock/scenarios/deployment-theme.spec.ts
+++ b/e2e/specs/mock/scenarios/deployment-theme.spec.ts
@@ -150,7 +150,7 @@ test.describe('deployment theme from librechat.yaml', () => {
});
await serveTheme(page, {
...INLINE_THEME,
- modes: { light: { colors: { 'rgb-not-a-token': '1 2 3' } } },
+ modes: { light: { colors: { 'rgb-not-a-token': 'red' } } },
});
await openLogin(page);
diff --git a/e2e/specs/mock/scenarios/state-roles.spec.ts b/e2e/specs/mock/scenarios/state-roles.spec.ts
new file mode 100644
index 0000000000..72ec896309
--- /dev/null
+++ b/e2e/specs/mock/scenarios/state-roles.spec.ts
@@ -0,0 +1,315 @@
+import { expect, test } from '@playwright/test';
+import type { Page } from '@playwright/test';
+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';
+import { NEW_CHAT_PATH } from '../helpers';
+
+/**
+ * The pressed and disabled state roles. A held control takes `surface-pressed` (or the inverted
+ * pressed fill), which defaults to the hover fill a pointer press has always shown. A disabled
+ * control dims to half opacity unless the theme's `disabledStyle` is `fill`, which paints it in
+ * `surface-disabled` and `text-disabled` at full opacity. The probes carry the class lists the
+ * shared `IconButton` and `Field` primitives compose, so only those rules style them.
+ */
+
+type Mode = 'light' | 'dark';
+
+const PRESS_CLASSES = 'bg-surface-secondary hover:bg-surface-hover hover:active:bg-surface-pressed';
+const DISABLED_CLASSES =
+ 'bg-transparent text-text-primary disabled:opacity-50 theme-disabled:bg-surface-disabled theme-disabled:text-text-disabled theme-disabled:opacity-100';
+
+/** Names every state role apart from the hover and ink it would otherwise follow. */
+const STATE_ROLE_THEME = {
+ version: 1,
+ name: 'e2e-state-roles',
+ modes: {
+ light: {
+ colors: {
+ 'rgb-surface-hover': '200 200 200',
+ 'rgb-surface-pressed': '150 60 20',
+ 'rgb-surface-disabled': '20 150 60',
+ 'rgb-text-disabled': '60 20 150',
+ },
+ appearance: { disabledStyle: 'fill' },
+ },
+ dark: {
+ colors: {
+ 'rgb-surface-hover': '60 60 60',
+ 'rgb-surface-pressed': '240 160 120',
+ 'rgb-surface-disabled': '120 240 160',
+ 'rgb-text-disabled': '160 120 240',
+ },
+ appearance: { disabledStyle: 'fill' },
+ },
+ },
+} as const;
+
+async function openChat(page: Page, mode: Mode, definition?: { name: string }) {
+ await page.addInitScript(
+ ([appearance, stored]) => {
+ localStorage.setItem('color-theme', appearance as string);
+ localStorage.removeItem('theme-colors');
+ localStorage.removeItem('theme-name');
+ if (stored) {
+ localStorage.setItem('theme-definition', JSON.stringify(stored));
+ localStorage.setItem('theme-source', 'definition');
+ } else {
+ localStorage.removeItem('theme-definition');
+ localStorage.removeItem('theme-source');
+ }
+ },
+ [mode, definition ?? null] as [string, unknown],
+ );
+ await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
+ await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({
+ timeout: 30000,
+ });
+ const root = page.locator('html');
+ if (definition) {
+ await expect(root).toHaveAttribute('data-theme', definition.name);
+ } else {
+ await expect(root).not.toHaveAttribute('data-theme');
+ }
+ await expect(root).toHaveClass(mode === 'dark' ? /\bdark\b/ : /\blight\b/);
+}
+
+async function addProbe(page: Page, id: string, className: string, disabled = false) {
+ await page.evaluate(
+ ([probeId, classes, isDisabled]) => {
+ const probe = document.createElement('button');
+ probe.id = probeId as string;
+ probe.className = classes as string;
+ probe.disabled = isDisabled as boolean;
+ probe.textContent = 'State probe';
+ probe.style.position = 'fixed';
+ probe.style.top = '8px';
+ probe.style.left = '8px';
+ probe.style.zIndex = '2147483647';
+ document.body.append(probe);
+ },
+ [id, className, disabled] as [string, string, boolean],
+ );
+ return page.locator(`#${id}`);
+}
+
+/**
+ * Holds the pointer down on a hovered probe and reads its fill. Tailwind gates `hover:` behind
+ * `(hover: hover)`, so on a touch device neither the hover nor the pressed fill applies and the
+ * probe keeps its resting fill, as it always has; `null` marks that case.
+ */
+async function pressedFill(page: Page): Promise<string | null> {
+ if (!(await page.evaluate(() => matchMedia('(hover: hover)').matches))) {
+ return null;
+ }
+ const probe = await addProbe(page, 'state-press-probe', PRESS_CLASSES);
+ const box = await probe.boundingBox();
+ if (!box) {
+ throw new Error('press probe has no box');
+ }
+ await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
+ await page.mouse.down();
+ const fill = await probe.evaluate((node) => getComputedStyle(node).backgroundColor);
+ await page.mouse.up();
+ return fill;
+}
+
+/** The ink an empty disabled field shows is its placeholder, which `Field` colors on its own. */
+const PLACEHOLDER_CLASSES =
+ 'placeholder:text-text-secondary disabled:opacity-50 theme-disabled:placeholder:text-text-disabled';
+
+async function disabledLook(page: Page) {
+ const probe = await addProbe(page, 'state-disabled-probe', DISABLED_CLASSES, true);
+ const look = await probe.evaluate((node) => {
+ const style = getComputedStyle(node);
+ return { fill: style.backgroundColor, ink: style.color, opacity: style.opacity };
+ });
+ const placeholder = await page.evaluate((classes) => {
+ const field = document.createElement('input');
+ field.className = classes;
+ field.placeholder = 'Disabled field';
+ field.disabled = true;
+ document.body.append(field);
+ const color = getComputedStyle(field, '::placeholder').color;
+ field.remove();
+ return color;
+ }, PLACEHOLDER_CLASSES);
+ /** Radix marks a disabled part that is not a form control, a slider thumb, with `data-disabled`. */
+ const part = await page.evaluate(() => {
+ const thumb = document.createElement('span');
+ thumb.className = 'bg-surface-primary theme-disabled:bg-surface-disabled';
+ thumb.setAttribute('data-disabled', '');
+ document.body.append(thumb);
+ const fill = getComputedStyle(thumb).backgroundColor;
+ thumb.remove();
+ return fill;
+ });
+ /** `InputNumber` styles a wrapper whose disabled input sits inside it. */
+ const wrapper = await page.evaluate(() => {
+ const box = document.createElement('div');
+ box.className =
+ 'bg-transparent text-text-primary theme-disabled-within:bg-surface-disabled theme-disabled-within:text-text-disabled theme-disabled-within:[&_*]:border-border-disabled';
+ const field = document.createElement('input');
+ field.disabled = true;
+ const slot = document.createElement('div');
+ slot.className = 'border border-border-control';
+ box.append(field, slot);
+ document.body.append(box);
+ const style = getComputedStyle(box);
+ const result = `${style.backgroundColor} ${getComputedStyle(field).color} ${getComputedStyle(slot).borderTopColor}`;
+ box.remove();
+ return result;
+ });
+ /** A menu item keeps its surface and grays its text; a label follows its control through `peer`. */
+ const items = await page.evaluate(() => {
+ const item = document.createElement('div');
+ item.className =
+ 'text-text-primary theme-disabled:text-text-disabled theme-disabled:[&_*]:text-text-disabled';
+ item.setAttribute('data-disabled', '');
+ const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ icon.setAttribute('class', 'text-status-warning');
+ item.append(icon);
+ const field = document.createElement('input');
+ field.className = 'peer';
+ field.disabled = true;
+ const label = document.createElement('label');
+ label.className = 'text-text-secondary peer-theme-disabled:text-text-disabled';
+ document.body.append(item, field, label);
+ const result = `${getComputedStyle(icon).color} ${getComputedStyle(label).color}`;
+ item.remove();
+ field.remove();
+ label.remove();
+ return result;
+ });
+ return { ...look, placeholder, part, wrapper, items };
+}
+
+/** Each tag is written out whole: the runner finds a scenario by its literal tag. */
+const CASES: Array<{
+ title: string;
+ mode: Mode;
+ definition?: { name: string };
+ pressed: string;
+ disabled: {
+ fill: string;
+ ink: string;
+ opacity: string;
+ placeholder: string;
+ part: string;
+ wrapper: string;
+ items: string;
+ };
+}> = [
+ {
+ title:
+ 'the default light theme presses in its hover fill and dims disabled controls @scenario:state-roles-default-light-unchanged',
+ mode: 'light',
+ pressed: 'rgb(227, 227, 227)',
+ disabled: {
+ fill: 'rgba(0, 0, 0, 0)',
+ ink: 'rgb(33, 33, 33)',
+ opacity: '0.5',
+ placeholder: 'rgb(66, 66, 66)',
+ part: 'rgb(255, 255, 255)',
+ wrapper: 'rgba(0, 0, 0, 0) rgb(33, 33, 33) rgb(227, 227, 227)',
+ items: 'rgb(180, 83, 9) rgb(66, 66, 66)',
+ },
+ },
+ {
+ title:
+ 'the default dark theme presses in its hover fill and dims disabled controls @scenario:state-roles-default-dark-unchanged',
+ mode: 'dark',
+ pressed: 'rgb(57, 57, 57)',
+ disabled: {
+ fill: 'rgba(0, 0, 0, 0)',
+ ink: 'rgb(236, 236, 236)',
+ opacity: '0.5',
+ placeholder: 'rgb(205, 205, 205)',
+ part: 'rgb(13, 13, 13)',
+ wrapper: 'rgba(0, 0, 0, 0) rgb(236, 236, 236) rgb(33, 33, 33)',
+ items: 'rgb(252, 211, 77) rgb(205, 205, 205)',
+ },
+ },
+ {
+ title:
+ 'the ClickHouse light theme presses and disables in Click UI fills @scenario:state-roles-clickhouse-light',
+ mode: 'light',
+ definition: clickHouseTheme,
+ pressed: 'rgb(221, 222, 225)',
+ disabled: {
+ fill: 'rgb(223, 223, 223)',
+ ink: 'rgb(160, 160, 160)',
+ opacity: '1',
+ placeholder: 'rgb(160, 160, 160)',
+ part: 'rgb(223, 223, 223)',
+ wrapper: 'rgb(223, 223, 223) rgb(160, 160, 160) rgb(223, 223, 223)',
+ items: 'rgb(160, 160, 160) rgb(160, 160, 160)',
+ },
+ },
+ {
+ title:
+ 'the ClickHouse dark theme presses and disables in Click UI fills @scenario:state-roles-clickhouse-dark',
+ mode: 'dark',
+ definition: clickHouseTheme,
+ pressed: 'rgb(36, 36, 36)',
+ disabled: {
+ fill: 'rgb(65, 65, 65)',
+ ink: 'rgb(128, 128, 128)',
+ opacity: '1',
+ placeholder: 'rgb(128, 128, 128)',
+ part: 'rgb(65, 65, 65)',
+ wrapper: 'rgb(65, 65, 65) rgb(128, 128, 128) rgb(65, 65, 65)',
+ items: 'rgb(128, 128, 128) rgb(128, 128, 128)',
+ },
+ },
+];
+
+test.describe('pressed and disabled state roles', () => {
+ for (const { title, mode, definition, pressed, disabled } of CASES) {
+ test(title, async ({ page }) => {
+ await openChat(page, mode, definition);
+
+ const fill = await pressedFill(page);
+ if (fill !== null) {
+ expect(fill).toBe(pressed);
+ }
+ expect(await disabledLook(page)).toEqual(disabled);
+ });
+ }
+
+ test('a theme that names the state roles presses and disables in them, in both modes @scenario:state-roles-follow-reference-theme', async ({
+ page,
+ }) => {
+ const expected: Record<Mode, { pressed: string; fill: string; ink: string; edge: string }> = {
+ light: {
+ pressed: 'rgb(150, 60, 20)',
+ fill: 'rgb(20, 150, 60)',
+ ink: 'rgb(60, 20, 150)',
+ edge: 'rgb(227, 227, 227)',
+ },
+ dark: {
+ pressed: 'rgb(240, 160, 120)',
+ fill: 'rgb(120, 240, 160)',
+ ink: 'rgb(160, 120, 240)',
+ edge: 'rgb(57, 57, 57)',
+ },
+ };
+ /** One page per mode: a page's init scripts accumulate, and their order is not guaranteed. */
+ for (const mode of ['light', 'dark'] as const) {
+ const modePage = mode === 'light' ? page : await page.context().newPage();
+ await openChat(modePage, mode, STATE_ROLE_THEME);
+
+ const fill = await pressedFill(modePage);
+ if (fill !== null) {
+ expect(fill).toBe(expected[mode].pressed);
+ }
+ expect(await disabledLook(modePage)).toEqual({
+ fill: expected[mode].fill,
+ ink: expected[mode].ink,
+ opacity: '1',
+ placeholder: expected[mode].ink,
+ part: expected[mode].fill,
+ wrapper: `${expected[mode].fill} ${expected[mode].ink} ${expected[mode].edge}`,
+ items: `${expected[mode].ink} ${expected[mode].ink}`,
+ });
+ }
+ });
+});
diff --git a/packages/client/src/components/AlertDialog.tsx b/packages/client/src/components/AlertDialog.tsx
index 6e6bbee22c..2607dc8ee9 100644
--- a/packages/client/src/components/AlertDialog.tsx
+++ b/packages/client/src/components/AlertDialog.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import { JSX } from 'react/jsx-runtime';
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
import { useDialogDepth } from './OriginalDialog';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses } from '~/utils';
const AlertDialog: React.FC<AlertDialogPrimitive.AlertDialogProps> = AlertDialogPrimitive.Root;
@@ -148,6 +148,7 @@ const AlertDialogAction: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'bg-surface-inverted text-text-inverted hover:bg-surface-inverted-hover focus:ring-focus-control inline-flex h-10 items-center justify-center rounded-md px-4 py-2 text-sm font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
className,
)}
{...props}
@@ -169,6 +170,7 @@ const AlertDialogCancel: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'border-border-light text-text-primary hover:bg-surface-hover focus:ring-focus-control mt-2 inline-flex h-10 items-center justify-center rounded-md border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',
+ disabledFillClasses,
className,
)}
{...props}
diff --git a/packages/client/src/components/AnimatedTabs.tsx b/packages/client/src/components/AnimatedTabs.tsx
index b58a31f686..2c13fff3ae 100644
--- a/packages/client/src/components/AnimatedTabs.tsx
+++ b/packages/client/src/components/AnimatedTabs.tsx
@@ -1,7 +1,7 @@
import { forwardRef, useEffect, useRef } from 'react';
import * as Ariakit from '@ariakit/react';
import type { ElementRef } from 'react';
-import { cn } from '~/utils';
+import { cn, disabledInkClasses } from '~/utils';
import './AnimatedTabs.css';
import { JSX } from 'react/jsx-runtime';
@@ -60,7 +60,11 @@ const Tab = forwardRef<ElementRef<typeof Ariakit.Tab>, Ariakit.TabProps>(functio
else if (ref) ref.current = node;
}}
{...props}
- className={`animated-tab aria-selected:text-text-primary flex items-center justify-center gap-2 border-none text-sm font-medium whitespace-nowrap outline-hidden transition-colors select-none aria-disabled:opacity-50 ${props.className || ''}`}
+ className={cn(
+ 'animated-tab aria-selected:text-text-primary flex items-center justify-center gap-2 border-none text-sm font-medium whitespace-nowrap outline-hidden transition-colors select-none aria-disabled:opacity-50',
+ disabledInkClasses,
+ props.className,
+ )}
/>
);
});
diff --git a/packages/client/src/components/Checkbox.tsx b/packages/client/src/components/Checkbox.tsx
index ff0dcfc225..f26f44d7d3 100644
--- a/packages/client/src/components/Checkbox.tsx
+++ b/packages/client/src/components/Checkbox.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Check } from 'lucide-react';
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses } from '~/utils';
type BaseCheckboxProps = Omit<
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
@@ -28,6 +28,7 @@ const Checkbox: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'peer border-border-xheavy ring-offset-surface-primary focus-visible:ring-focus-control data-[state=checked]:bg-surface-inverted data-[state=checked]:text-text-inverted h-4 w-4 shrink-0 rounded-sm border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
className,
)}
{...props}
diff --git a/packages/client/src/components/Combobox.tsx b/packages/client/src/components/Combobox.tsx
index 47c68fc6b1..aa1b1b9c35 100644
--- a/packages/client/src/components/Combobox.tsx
+++ b/packages/client/src/components/Combobox.tsx
@@ -13,8 +13,8 @@ import {
import type { OptionWithIcon } from '~/common';
import { SelectTrigger, SelectValue, SelectScrollDownButton } from './Select';
import { useNestedPopoverStyle } from './OriginalDialog';
+import { cn, disabledInkClasses } from '~/utils';
import { useCombobox } from '~/hooks';
-import { cn } from '~/utils';
export default function ComboboxComponent({
selectedValue,
@@ -145,6 +145,7 @@ export default function ComboboxComponent({
<ComboboxItem
className={cn(
'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ disabledInkClasses,
'hover:bg-surface-hover rounded-lg',
)}
/** Hacky fix for radix-ui Android issue: https://github.com/radix-ui/primitives/issues/1658 */
diff --git a/packages/client/src/components/Dialog.tsx b/packages/client/src/components/Dialog.tsx
index 49fb1fa2a2..2862dd9f5a 100644
--- a/packages/client/src/components/Dialog.tsx
+++ b/packages/client/src/components/Dialog.tsx
@@ -2,9 +2,9 @@ import * as React from 'react';
import { X } from 'lucide-react';
import { JSX } from 'react/jsx-runtime';
import * as DialogPrimitive from '@radix-ui/react-dialog';
+import { cn, disabledFillClasses } from '~/utils';
import { Button, ButtonProps } from './Button';
import { useMediaQuery } from '~/hooks';
-import { cn } from '~/utils';
const Dialog: React.FC<DialogPrimitive.DialogProps> = DialogPrimitive.Root;
@@ -145,6 +145,7 @@ const DialogClose: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'border-border-light text-text-primary hover:bg-surface-hover mt-2 inline-flex h-10 items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',
+ disabledFillClasses,
className ?? '',
/* Important: for accessibility */
'focus:ring-focus-control focus:ring-2 focus:ring-offset-2',
@@ -166,6 +167,7 @@ const DialogButton: React.ForwardRefExoticComponent<
variant="outline"
className={cn(
'border-border-light text-text-primary hover:bg-surface-hover focus:ring-focus-control mt-2 inline-flex h-10 items-center justify-center rounded-lg border bg-transparent px-4 py-2 text-sm font-semibold transition-colors focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 sm:mt-0',
+ disabledFillClasses,
className ?? '',
/* Important: for accessibility */
'focus:ring-focus-control focus:ring-2 focus:ring-offset-2',
diff --git a/packages/client/src/components/DialogTemplate.tsx b/packages/client/src/components/DialogTemplate.tsx
index ab3f02930e..5623067745 100644
--- a/packages/client/src/components/DialogTemplate.tsx
+++ b/packages/client/src/components/DialogTemplate.tsx
@@ -7,7 +7,7 @@ import {
DialogHeader,
DialogTitle,
} from './Dialog';
-import { cn } from '~/utils/';
+import { cn, disabledFillClasses } from '~/utils';
type SelectionProps = {
selectHandler?: () => void;
@@ -48,20 +48,22 @@ const DialogTemplate: ForwardRefExoticComponent<
const { selectHandler, selectClasses, selectText } = selection || {};
const Cancel = 'cancel';
- const defaultSelect =
- 'bg-surface-inverted text-text-inverted transition-colors hover:bg-surface-inverted-hover disabled:cursor-not-allowed disabled:opacity-50';
+ const defaultSelect = cn(
+ 'bg-surface-inverted text-text-inverted transition-colors hover:bg-surface-inverted-hover disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
+ );
return (
<DialogContent
showCloseButton={showCloseButton}
ref={ref}
className={cn(
- 'bg-surface-dialog shadow-2xl high-contrast:border high-contrast:border-solid high-contrast:border-border-medium high-contrast:shadow-none',
+ 'bg-surface-dialog high-contrast:border high-contrast:border-solid high-contrast:border-border-medium high-contrast:shadow-none shadow-2xl',
className || '',
)}
onClick={(e) => e.stopPropagation()}
>
<DialogHeader className={cn(headerClassName ?? '')}>
- <DialogTitle className="text-lg font-medium leading-6 text-text-primary">
+ <DialogTitle className="text-text-primary text-lg leading-6 font-medium">
{title}
</DialogTitle>
{description && (
diff --git a/packages/client/src/components/Dropdown.tsx b/packages/client/src/components/Dropdown.tsx
index 79e4495efe..ca9d909c7d 100644
--- a/packages/client/src/components/Dropdown.tsx
+++ b/packages/client/src/components/Dropdown.tsx
@@ -4,8 +4,8 @@ import { matchSorter } from 'match-sorter';
import * as Select from '@ariakit/react/select';
import * as Combobox from '@ariakit/react/combobox';
import type { Option } from '~/common';
+import { cn, disabledFillClasses } from '~/utils';
import { fieldControl } from './Field';
-import { cn } from '~/utils/';
import './Dropdown.css';
interface DropdownProps {
@@ -152,6 +152,7 @@ const Dropdown: React.FC<DropdownProps> = ({
className={cn(
'border-border-control text-text-primary hover:bg-surface-hover hover:text-text-primary relative inline-flex items-center justify-between rounded-xl border bg-transparent py-2 text-sm transition-all duration-200 ease-in-out',
'disabled:hover:text-text-primary disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:bg-transparent',
+ disabledFillClasses,
/** Horizontal padding would squeeze the icon, which flex-shrinks to fit */
iconOnly ? 'size-10 justify-center px-0' : 'w-fit gap-2 px-3',
variant === 'field' && fieldControl,
diff --git a/packages/client/src/components/DropdownMenu.tsx b/packages/client/src/components/DropdownMenu.tsx
index cdb31b3d25..4bcf059e1b 100644
--- a/packages/client/src/components/DropdownMenu.tsx
+++ b/packages/client/src/components/DropdownMenu.tsx
@@ -3,7 +3,7 @@ import { JSX } from 'react/jsx-runtime';
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
import { CheckIcon, ChevronRightIcon, CircleIcon } from 'lucide-react';
import { usePopoverZIndex } from './OriginalDialog';
-import { cn } from '~/utils';
+import { cn, disabledInkClasses } from '~/utils';
function DropdownMenu({
...props
@@ -68,6 +68,7 @@ function DropdownMenuItem({
data-variant={variant}
className={cn(
"focus:bg-surface-hover focus:text-text-primary data-[variant=destructive]:text-text-destructive data-[variant=destructive]:focus:bg-status-error-subtle data-[variant=destructive]:focus:text-text-destructive [&_svg:not([class*='text-'])]:text-text-secondary relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ disabledInkClasses,
className,
)}
{...props}
@@ -86,6 +87,7 @@ function DropdownMenuCheckboxItem({
data-slot="dropdown-menu-checkbox-item"
className={cn(
"focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ disabledInkClasses,
className,
)}
checked={checked}
@@ -117,6 +119,7 @@ function DropdownMenuRadioItem({
data-slot="dropdown-menu-radio-item"
className={cn(
"focus:bg-surface-hover focus:text-text-primary relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ disabledInkClasses,
className,
)}
{...props}
diff --git a/packages/client/src/components/DropdownPopup.tsx b/packages/client/src/components/DropdownPopup.tsx
index 038186a2a3..ab6dfd4ad5 100644
--- a/packages/client/src/components/DropdownPopup.tsx
+++ b/packages/client/src/components/DropdownPopup.tsx
@@ -2,7 +2,7 @@ import React from 'react';
import * as Ariakit from '@ariakit/react';
import type * as t from '~/common';
import { usePopoverZIndex } from './OriginalDialog';
-import { cn } from '~/utils';
+import { cn, disabledInkClasses } from '~/utils';
import './Dropdown.css';
interface DropdownProps {
@@ -113,6 +113,7 @@ const Menu: React.FC<MenuProps> = ({
<Ariakit.MenuButton
className={cn(
'group text-text-primary hover:bg-surface-hover focus:bg-surface-hover flex w-full cursor-pointer items-center justify-between gap-2 rounded-lg px-3 py-3.5 text-sm outline-hidden md:px-2.5 md:py-2',
+ disabledInkClasses,
itemClassName,
)}
disabled={item.disabled}
@@ -148,6 +149,7 @@ const Menu: React.FC<MenuProps> = ({
id={item.id}
className={cn(
'group text-text-primary hover:bg-surface-hover focus:bg-surface-hover flex w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-3.5 text-sm outline-hidden md:px-2.5 md:py-2',
+ disabledInkClasses,
itemClassName,
item.className,
)}
diff --git a/packages/client/src/components/Field.ts b/packages/client/src/components/Field.ts
index c2177e8ffd..377a9a24b3 100644
--- a/packages/client/src/components/Field.ts
+++ b/packages/client/src/components/Field.ts
@@ -1,3 +1,5 @@
+import { disabledFillClasses } from '~/utils/theme';
+
/**
* The shared appearance of a form control: border, radius, type scale and focus
* treatment. Owned here so `Input`, `Textarea`, and the select/combobox triggers
@@ -6,8 +8,7 @@
* border is `border-control` because it is the only edge the control has, so a
* palette can raise it to the 3:1 non-text floor without touching separators.
*/
-export const fieldBase: string =
- 'lc-field flex w-full rounded-lg border border-border-control px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control disabled:cursor-not-allowed disabled:opacity-50';
+export const fieldBase: string = `lc-field flex w-full rounded-lg border border-border-control px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control disabled:cursor-not-allowed disabled:opacity-50 ${disabledFillClasses}`;
/** A single-line control sized to sit in a form row, matching `Input`. */
export const fieldControl: string = `${fieldBase} h-10 bg-transparent`;
diff --git a/packages/client/src/components/FilterInput.tsx b/packages/client/src/components/FilterInput.tsx
index 0fc66c2173..43b0620dda 100644
--- a/packages/client/src/components/FilterInput.tsx
+++ b/packages/client/src/components/FilterInput.tsx
@@ -1,5 +1,5 @@
import * as React from 'react';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses, peerDisabledInkClasses } from '~/utils';
export interface FilterInputProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'placeholder'> {
@@ -48,13 +48,17 @@ const FilterInput: React.ForwardRefExoticComponent<
aria-label={label}
className={cn(
'peer border-border-light text-text-primary ring-offset-surface-primary placeholder:text-text-secondary flex h-9 w-full rounded-lg border bg-transparent px-3 py-2 text-sm focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
className,
)}
{...props}
/>
<label
htmlFor={inputId}
- className="text-text-secondary pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:bg-inherit peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-inherit peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs"
+ className={cn(
+ peerDisabledInkClasses,
+ 'text-text-secondary pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-sm transition-all duration-200 peer-focus:top-0 peer-focus:bg-inherit peer-focus:px-1 peer-focus:text-xs peer-[:not(:placeholder-shown)]:top-0 peer-[:not(:placeholder-shown)]:bg-inherit peer-[:not(:placeholder-shown)]:px-1 peer-[:not(:placeholder-shown)]:text-xs',
+ )}
>
{label}
</label>
diff --git a/packages/client/src/components/IconButton.tsx b/packages/client/src/components/IconButton.tsx
index b3c2fc8af0..9100bb132a 100644
--- a/packages/client/src/components/IconButton.tsx
+++ b/packages/client/src/components/IconButton.tsx
@@ -2,6 +2,7 @@ import * as React from 'react';
import { cva } from 'class-variance-authority';
import type { ClassProp } from 'class-variance-authority/types';
import { composerSubmitClasses } from '~/utils/composer';
+import { disabledFillClasses } from '~/utils/theme';
import { cn } from '~/utils';
type IconButtonVariantProps = {
@@ -19,21 +20,29 @@ type IconButtonVariantProps = {
};
const iconButtonVariants: (props?: IconButtonVariantProps & ClassProp) => string = cva(
- 'inline-flex shrink-0 items-center justify-center text-text-primary transition-colors duration-theme-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control focus-visible:ring-offset-2 focus-visible:ring-offset-surface-primary disabled:pointer-events-none disabled:opacity-50',
+ [
+ 'inline-flex shrink-0 items-center justify-center text-text-primary transition-colors duration-theme-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control focus-visible:ring-offset-2 focus-visible:ring-offset-surface-primary disabled:pointer-events-none disabled:opacity-50',
+ disabledFillClasses,
+ ],
{
variants: {
variant: {
- default: 'bg-surface-secondary hover:bg-surface-hover',
- primary: 'bg-surface-inverted text-text-inverted hover:bg-surface-inverted-hover',
- secondary: 'border border-border-light bg-surface-secondary hover:bg-surface-hover',
- ghost: 'bg-transparent hover:bg-surface-hover',
+ default: 'bg-surface-secondary hover:bg-surface-hover hover:active:bg-surface-pressed',
+ primary:
+ 'bg-surface-inverted text-text-inverted hover:bg-surface-inverted-hover hover:active:bg-surface-inverted-pressed',
+ secondary:
+ 'border border-border-light bg-surface-secondary hover:bg-surface-hover hover:active:bg-surface-pressed',
+ ghost: 'bg-transparent hover:bg-surface-hover hover:active:bg-surface-pressed',
/** An action inside a list row whose highlight is already `surface-hover`,
* so its own hover takes the active fill to stay visible on top of it. */
'row-action': 'bg-transparent hover:bg-surface-active',
destructive:
'bg-surface-destructive text-text-on-status hover:bg-surface-destructive-hover',
/** The composer's submit slot: send, stop and the during-run send share it. */
- submit: cn('hover:bg-surface-inverted-hover', composerSubmitClasses()),
+ submit: cn(
+ 'hover:bg-surface-inverted-hover hover:active:bg-surface-inverted-pressed',
+ composerSubmitClasses(),
+ ),
},
size: {
xs: 'size-6',
diff --git a/packages/client/src/components/InputNumber.tsx b/packages/client/src/components/InputNumber.tsx
index d18f17f563..6d149940ca 100644
--- a/packages/client/src/components/InputNumber.tsx
+++ b/packages/client/src/components/InputNumber.tsx
@@ -5,7 +5,7 @@ import * as React from 'react';
import RCInputNumber from 'rc-input-number';
import * as InputNumberPrimitive from 'rc-input-number';
import type { ValueType } from '@rc-component/mini-decimal';
-import { cn } from '~/utils';
+import { cn, disabledWithinFillClasses } from '~/utils';
// TODO help needed
// React.ElementRef<typeof LabelPrimitive.Root>,
@@ -19,6 +19,7 @@ const InputNumber: React.ForwardRefExoticComponent<
<RCInputNumber
className={cn(
'border-border-medium text-text-primary placeholder:text-text-tertiary flex max-h-5 w-full rounded-md border bg-transparent px-3 py-2 text-sm focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledWithinFillClasses,
className ?? '',
)}
ref={ref}
diff --git a/packages/client/src/components/InputOTP.tsx b/packages/client/src/components/InputOTP.tsx
index db6500b71f..8048b5cdfc 100644
--- a/packages/client/src/components/InputOTP.tsx
+++ b/packages/client/src/components/InputOTP.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Minus } from 'lucide-react';
import { OTPInput, OTPInputContext, RenderProps } from 'input-otp';
-import { cn } from '~/utils';
+import { cn, disabledWithinFillClasses } from '~/utils';
const InputOTP: React.ForwardRefExoticComponent<
(
@@ -71,6 +71,7 @@ const InputOTP: React.ForwardRefExoticComponent<
ref={ref}
containerClassName={cn(
'flex items-center gap-2 has-[:disabled]:opacity-50',
+ disabledWithinFillClasses,
containerClassName,
)}
className={cn('disabled:cursor-not-allowed', className)}
diff --git a/packages/client/src/components/Label.tsx b/packages/client/src/components/Label.tsx
index 04bb94e52b..ab0c1685cb 100644
--- a/packages/client/src/components/Label.tsx
+++ b/packages/client/src/components/Label.tsx
@@ -2,7 +2,7 @@ import * as React from 'react';
import * as LabelPrimitive from '@radix-ui/react-label';
import { ClassProp } from 'class-variance-authority/types';
import { cva, type VariantProps } from 'class-variance-authority';
-import { cn } from '~/utils';
+import { cn, peerDisabledInkClasses } from '~/utils';
type LabelVariantOptions =
| ({ variant?: 'default' | 'section' | null | undefined } & ClassProp)
@@ -45,6 +45,7 @@ const Label: React.ForwardRefExoticComponent<
{...{
className: cn(
'block w-full break-all peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
+ peerDisabledInkClasses,
labelVariants({ variant }),
className,
),
diff --git a/packages/client/src/components/MultiSelect.tsx b/packages/client/src/components/MultiSelect.tsx
index 7cddff6d83..92f8c166e0 100644
--- a/packages/client/src/components/MultiSelect.tsx
+++ b/packages/client/src/components/MultiSelect.tsx
@@ -12,7 +12,7 @@ import {
} from '@ariakit/react';
import './AnimatePopover.css';
import { JSX } from 'react/jsx-runtime';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses } from '~/utils';
type MultiSelectItem<T extends string> = T | { label: string; value: T };
@@ -147,6 +147,7 @@ export default function MultiSelect<T extends string>({
'flex items-center justify-between gap-2 rounded-xl px-3 py-2 text-sm',
'bg-surface-tertiary text-text-primary hover:bg-surface-hover shadow-xs hover:cursor-pointer',
'disabled:hover:bg-surface-tertiary disabled:cursor-not-allowed disabled:opacity-60',
+ disabledFillClasses,
'focus-visible:ring-focus-control outline-hidden focus-visible:ring-2 focus-visible:outline-hidden',
selectClassName,
selectedValues.length > 0 && selectItemsClassName != null && selectItemsClassName,
diff --git a/packages/client/src/components/Radio.tsx b/packages/client/src/components/Radio.tsx
index 86070ff093..7f59490ccf 100644
--- a/packages/client/src/components/Radio.tsx
+++ b/packages/client/src/components/Radio.tsx
@@ -1,4 +1,5 @@
import React, { useState, useRef, useLayoutEffect, useCallback, memo } from 'react';
+import { disabledInkClasses } from '~/utils';
import { useLocalize } from '~/hooks';
/** Matches the `inset-y-1` the single-row indicator uses. */
@@ -190,7 +191,7 @@ const Radio: React.NamedExoticComponent<RadioProps> = memo(function Radio({
disabled={disabled}
className={`focus-visible:ring-focus-control relative z-10 flex h-[34px] items-center justify-center gap-2 rounded-md px-4 text-sm font-medium transition-colors duration-150 focus-visible:ring-2 focus-visible:outline-hidden ${
currentValue === option.value ? 'text-text-primary' : 'text-text-secondary'
- } ${disabled ? 'cursor-not-allowed opacity-50' : ''} ${fullWidth ? 'flex-1' : ''} ${buttonClassName}`}
+ } ${disabled ? 'cursor-not-allowed opacity-50' : ''} ${disabledInkClasses} ${fullWidth ? 'flex-1' : ''} ${buttonClassName}`}
>
{option.icon && (
<span className="shrink-0" aria-hidden="true">
diff --git a/packages/client/src/components/SecretInput.tsx b/packages/client/src/components/SecretInput.tsx
index dabc37fdff..8190e0c0c8 100644
--- a/packages/client/src/components/SecretInput.tsx
+++ b/packages/client/src/components/SecretInput.tsx
@@ -1,8 +1,8 @@
import * as React from 'react';
import { useState, useCallback } from 'react';
import { Eye, EyeOff, Copy, Check } from 'lucide';
+import { cn, disabledFillClasses, disabledInkClasses } from '~/utils';
import { MorphIcon } from './MorphIcon';
-import { cn } from '~/utils';
export interface SecretInputProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type'> {
@@ -84,6 +84,7 @@ const SecretInput: React.ForwardRefExoticComponent<
type={isVisible ? 'text' : 'password'}
className={cn(
'border-border-control placeholder:text-text-secondary flex h-10 w-full rounded-lg border bg-transparent py-2 pl-3 text-sm focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
colorTransition && 'transition-colors',
className ?? '',
copyButton != null || showCopy ? 'pr-20' : 'pr-11',
@@ -119,6 +120,7 @@ const SecretInput: React.ForwardRefExoticComponent<
disabled || !value
? 'cursor-not-allowed opacity-50'
: 'hover:bg-surface-hover hover:text-text-primary',
+ disabledInkClasses,
buttonClassName,
)}
aria-label={isCopied ? 'Copied' : 'Copy to clipboard'}
@@ -135,6 +137,7 @@ const SecretInput: React.ForwardRefExoticComponent<
disabled
? 'cursor-not-allowed opacity-50'
: 'hover:bg-surface-hover hover:text-text-primary',
+ disabledInkClasses,
buttonClassName,
)}
aria-label={isVisible ? 'Hide secret' : 'Show secret'}
diff --git a/packages/client/src/components/Select.tsx b/packages/client/src/components/Select.tsx
index 1c14b63bc1..1760bd45de 100644
--- a/packages/client/src/components/Select.tsx
+++ b/packages/client/src/components/Select.tsx
@@ -1,8 +1,8 @@
import * as React from 'react';
import * as SelectPrimitive from '@radix-ui/react-select';
import { CaretSortIcon, CheckIcon, ChevronDownIcon, ChevronUpIcon } from '@radix-ui/react-icons';
+import { cn, disabledFillClasses, disabledInkClasses } from '~/utils';
import { useNestedPopoverStyle } from './OriginalDialog';
-import { cn } from '~/utils';
// @ts-ignore - Radix UI type conflicts with React types
const Select: React.FC<SelectPrimitive.SelectProps> = SelectPrimitive.Root;
@@ -28,6 +28,7 @@ const SelectTrigger: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'border-border-control ring-offset-surface-primary placeholder:text-text-secondary flex h-9 w-full items-center justify-between rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
+ disabledFillClasses,
'hover:bg-surface-hover rounded-lg',
className,
)}
@@ -142,6 +143,7 @@ const SelectItem: React.ForwardRefExoticComponent<
ref={ref}
className={cn(
'focus:bg-surface-hover focus:text-text-primary relative flex w-full cursor-pointer items-center rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
+ disabledInkClasses,
'hover:bg-surface-hover rounded-lg',
className,
)}
diff --git a/packages/client/src/components/SelectDropDown.tsx b/packages/client/src/components/SelectDropDown.tsx
index 1d924b31d8..6cad33796c 100644
--- a/packages/client/src/components/SelectDropDown.tsx
+++ b/packages/client/src/components/SelectDropDown.tsx
@@ -9,9 +9,9 @@ import {
ListboxOptions,
} from '@headlessui/react';
import type { Option, OptionWithIcon, DropdownValueSetter } from '~/common';
+import { cn, disabledFillClasses } from '~/utils';
import { useMultiSearch } from './MultiSearch';
import { CheckMark } from '~/svgs';
-import { cn } from '~/utils';
type SelectDropDownProps = {
id?: string;
@@ -120,6 +120,7 @@ function SelectDropDown({
}}
className={cn(
'border-border-control bg-surface-secondary focus-visible:ring-focus-control disabled:bg-surface-secondary relative flex w-full cursor-default flex-col rounded-md border py-2 pr-10 pl-3 text-left focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden sm:text-sm',
+ disabledFillClasses,
className ?? '',
)}
>
diff --git a/packages/client/src/components/SendActions.tsx b/packages/client/src/components/SendActions.tsx
index 510048adb3..1e41e7c18a 100644
--- a/packages/client/src/components/SendActions.tsx
+++ b/packages/client/src/components/SendActions.tsx
@@ -1,6 +1,7 @@
import * as Ariakit from '@ariakit/react';
import type { ReactElement, ReactNode } from 'react';
import type { JSX } from 'react/jsx-runtime';
+import { cn, disabledInkClasses } from '~/utils';
/** One alternate way to submit, offered from the send control rather than
* standing beside the field. */
@@ -16,8 +17,10 @@ export interface SendAction {
onClick: () => void;
}
-const ROW_CLASS =
- 'flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-text-primary hover:bg-surface-tertiary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-xheavy aria-disabled:cursor-not-allowed aria-disabled:opacity-50';
+const ROW_CLASS = cn(
+ 'flex w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm text-text-primary hover:bg-surface-tertiary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-xheavy aria-disabled:cursor-not-allowed aria-disabled:opacity-50',
+ disabledInkClasses,
+);
function Kbd({ children }: { children: ReactNode }): JSX.Element {
return (
diff --git a/packages/client/src/components/Slider.tsx b/packages/client/src/components/Slider.tsx
index 4ae8afba7e..2b2889ad66 100644
--- a/packages/client/src/components/Slider.tsx
+++ b/packages/client/src/components/Slider.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as SliderPrimitive from '@radix-ui/react-slider';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses } from '~/utils';
type SliderProps = React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & {
className?: string;
@@ -47,8 +47,10 @@ const Slider: React.ForwardRefExoticComponent<SliderProps & React.RefAttributes<
</SliderPrimitive.Track>
<SliderPrimitive.Thumb
{...{
- className:
+ className: cn(
'block h-5 w-5 rounded-full border-2 border-border-xheavy bg-surface-primary ring-offset-surface-primary transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-focus-control focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
+ disabledFillClasses,
+ ),
'aria-labelledby': ariaLabelledBy,
'aria-label': ariaLabel,
'aria-describedby': ariaDescribedBy,
diff --git a/packages/client/src/components/Switch.tsx b/packages/client/src/components/Switch.tsx
index cb663a9d8e..9556a3688e 100644
--- a/packages/client/src/components/Switch.tsx
+++ b/packages/client/src/components/Switch.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as SwitchPrimitives from '@radix-ui/react-switch';
-import { cn } from '~/utils';
+import { cn, disabledFillClasses } from '~/utils';
type BaseSwitchProps = Omit<
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>,
@@ -24,6 +24,7 @@ const Switch: React.ForwardRefExoticComponent<
<SwitchPrimitives.Root
className={cn(
'peer focus-visible:ring-focus-control focus-visible:ring-offset-surface-primary data-[state=checked]:bg-surface-inverted data-[state=unchecked]:bg-switch-unchecked inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50',
+ disabledFillClasses,
className,
)}
{...props}
diff --git a/packages/client/src/components/Tabs.tsx b/packages/client/src/components/Tabs.tsx
index a3f166201b..cf6a59e21b 100644
--- a/packages/client/src/components/Tabs.tsx
+++ b/packages/client/src/components/Tabs.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
import * as TabsPrimitive from '@radix-ui/react-tabs';
-import { cn } from '~/utils';
+import { cn, disabledInkClasses } from '~/utils';
const Tabs: React.ForwardRefExoticComponent<
TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>
@@ -34,6 +34,7 @@ const TabsTrigger: React.ForwardRefExoticComponent<
<TabsPrimitive.Trigger
className={cn(
'text-text-secondary data-[state=active]:bg-surface-primary data-[state=active]:text-text-primary inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50',
+ disabledInkClasses,
className,
)}
{...props}
diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md
index 20d3fb71cb..9c40279567 100644
--- a/packages/client/src/theme/README.md
+++ b/packages/client/src/theme/README.md
@@ -309,6 +309,14 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a
- `focus-outline` - The app-wide keyboard focus outline. Defaults to black in
light and white in dark; a theme that names only `rgb-ring-primary` draws its
outline in that ring.
+- `bg-surface-pressed` / `bg-surface-inverted-pressed` - The fill a neutral or
+ inverted control takes while held (`hover:active:`). Defaults to the hover fill,
+ which a pointer press has always shown; a theme that names only its hover fills
+ presses in them.
+- `bg-surface-disabled` / `text-text-disabled` / `border-border-disabled` - The
+ 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.
- `ring-focus-control` - The keyboard focus ring of the shared primitives
(`Checkbox`, `Switch`, `Field`, `IconButton` and their siblings). Defaults to
the primary text ink; a theme that names only `rgb-text-primary` rings its
diff --git a/packages/client/src/theme/context/ThemeProvider.tsx b/packages/client/src/theme/context/ThemeProvider.tsx
index 82467fbe21..6982a5e726 100644
--- a/packages/client/src/theme/context/ThemeProvider.tsx
+++ b/packages/client/src/theme/context/ThemeProvider.tsx
@@ -16,7 +16,11 @@ import {
resolveTheme,
validateThemeDefinition,
} from '../registry';
-import applyTheme, { applyResolvedTheme, themeOwnedProperties } from '../utils/applyTheme';
+import applyTheme, {
+ applyResolvedTheme,
+ themeOwnedProperties,
+ THEME_DISABLED_ATTRIBUTE,
+} from '../utils/applyTheme';
import { defaultTheme } from '../themes/default';
import { darkTheme } from '../themes/dark';
import '../highContrast.css';
@@ -48,6 +52,7 @@ type ThemeDOMSnapshot = {
properties: Map<string, { value: string; priority: string }>;
colorScheme: { value: string; priority: string };
dataTheme: string | null;
+ disabledStyle: string | null;
};
type ThemeClassSnapshot = {
@@ -282,6 +287,7 @@ const captureThemeDOM = (root: HTMLElement): ThemeDOMSnapshot => ({
priority: root.style.getPropertyPriority('color-scheme'),
},
dataTheme: root.getAttribute('data-theme'),
+ disabledStyle: root.getAttribute(THEME_DISABLED_ATTRIBUTE),
});
const restoreThemeDOM = (snapshot: ThemeDOMSnapshot, root: HTMLElement): void => {
@@ -308,6 +314,11 @@ const restoreThemeDOM = (snapshot: ThemeDOMSnapshot, root: HTMLElement): void =>
} else {
root.setAttribute('data-theme', snapshot.dataTheme);
}
+ if (snapshot.disabledStyle === null) {
+ root.removeAttribute(THEME_DISABLED_ATTRIBUTE);
+ } else {
+ root.setAttribute(THEME_DISABLED_ATTRIBUTE, snapshot.disabledStyle);
+ }
};
export function ThemeProvider({
diff --git a/packages/client/src/theme/controls.css b/packages/client/src/theme/controls.css
index b1dbd7041b..6da3479ce5 100644
--- a/packages/client/src/theme/controls.css
+++ b/packages/client/src/theme/controls.css
@@ -1,7 +1,9 @@
/**
* Stylesheet defaults for the roles the package's own primitives paint:
- * `--border-control`, the form-control boundary, and `--focus-control`, the
- * keyboard focus ring of `Checkbox`, `Switch`, `Field` and their siblings.
+ * `--border-control`, the form-control boundary, `--focus-control`, the
+ * keyboard focus ring of `Checkbox`, `Switch`, `Field` and their siblings, the
+ * pressed fills `IconButton` takes while held (the hover fills, which a pointer
+ * press has always shown), and the disabled roles a `fill` theme paints.
*
* Every other color role is declared by the app stylesheet, but these ship
* with the package so a consumer rendering `Input`, `Select` or `Checkbox` gets
@@ -16,9 +18,19 @@
html {
--border-control: 227 227 227;
--focus-control: 33 33 33;
+ --surface-pressed: 227 227 227;
+ --surface-inverted-pressed: 47 47 47;
+ --surface-disabled: 236 236 236;
+ --text-disabled: 153 150 150;
+ --border-disabled: 227 227 227;
}
.dark {
--border-control: 33 33 33;
--focus-control: 236 236 236;
+ --surface-pressed: 57 57 57;
+ --surface-inverted-pressed: 236 236 236;
+ --surface-disabled: 47 47 47;
+ --text-disabled: 153 150 150;
+ --border-disabled: 57 57 57;
}
diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts
index 431ec8f89b..e6becb91f2 100644
--- a/packages/client/src/theme/registry.spec.ts
+++ b/packages/client/src/theme/registry.spec.ts
@@ -291,6 +291,81 @@ describe('theme registry', () => {
expect(resolved.colors['rgb-border-control']).toBe(darkTheme['rgb-border-control']);
});
+ it('presses a theme that predates the pressed roles in the hover fills it painted', () => {
+ const resolved = resolveTheme(
+ {
+ version: 1,
+ name: 'hover-only-reference',
+ modes: {
+ dark: {
+ colors: {
+ 'rgb-surface-hover': '70 71 72',
+ 'rgb-surface-inverted-hover': '200 201 202',
+ },
+ },
+ },
+ },
+ 'dark',
+ );
+
+ expect(resolved.colors['rgb-surface-pressed']).toBe('70 71 72');
+ expect(resolved.colors['rgb-surface-inverted-pressed']).toBe('200 201 202');
+ });
+
+ it('keeps the bundled pressed fills, equal to the bundled hovers, for a theme that paints none', () => {
+ const resolved = resolveTheme(
+ {
+ version: 1,
+ name: 'pressless-reference',
+ modes: { light: { colors: { 'rgb-accent-primary': '1 2 3' } } },
+ },
+ 'light',
+ );
+
+ expect(resolved.colors['rgb-surface-pressed']).toBe(defaultTheme['rgb-surface-hover']);
+ expect(resolved.colors['rgb-surface-inverted-pressed']).toBe(
+ defaultTheme['rgb-surface-inverted-hover'],
+ );
+ });
+
+ it('preserves explicit pressed fills over the hovers they would follow', () => {
+ const resolved = resolveTheme(
+ {
+ version: 1,
+ name: 'pressed-reference',
+ modes: {
+ light: {
+ colors: {
+ 'rgb-surface-hover': '10 20 30',
+ 'rgb-surface-pressed': '40 50 60',
+ 'rgb-surface-inverted-pressed': '70 80 90',
+ },
+ },
+ },
+ },
+ 'light',
+ );
+
+ expect(resolved.colors['rgb-surface-pressed']).toBe('40 50 60');
+ expect(resolved.colors['rgb-surface-inverted-pressed']).toBe('70 80 90');
+ });
+
+ it('dims disabled controls unless a theme chooses to fill them', () => {
+ const base = { version: 1, name: 'disabled-reference' } as const;
+
+ expect(resolveTheme({ ...base, modes: {} }, 'light').appearance.disabledStyle).toBe('dim');
+ expect(
+ resolveTheme({ ...base, modes: { dark: { appearance: { disabledStyle: 'fill' } } } }, 'dark')
+ .appearance.disabledStyle,
+ ).toBe('fill');
+ expect(
+ validateThemeDefinition({
+ ...base,
+ modes: { light: { appearance: { disabledStyle: 'fade' as 'dim' } } },
+ }),
+ ).toEqual(['Invalid appearance value for disabledStyle: fade']);
+ });
+
it('draws the focus outline in the ring of a theme that predates the role', () => {
const resolved = resolveTheme(
{
@@ -604,7 +679,7 @@ describe('theme registry', () => {
light: {
colors: {
'rgb-text-primary': '999 0 0',
- 'rgb-unknown': '1 2 3',
+ 'rgb-unknown': 'red',
},
appearance: {
controlRadius: 'url(theme.css)',
@@ -682,16 +757,39 @@ describe('theme registry', () => {
expect(() => resolveTheme(theme, 'light')).toThrow(TypeError);
});
- it('still rejects an unknown colour token', () => {
+ it('ignores a well-formed colour role it predates and paints the rest', () => {
const theme = {
version: 1,
name: 'colour',
modes: {
- light: { colors: { 'rgb-future': '1 2 3' }, appearance: { futureSpacing: '1rem' } },
+ light: {
+ colors: { 'rgb-future': '1 2 3', 'rgb-accent-primary': '4 5 6' },
+ appearance: { futureSpacing: '1rem' },
+ },
},
} as ThemeDefinition;
- expect(validateThemeDefinition(theme)).toEqual(['Unknown color token: rgb-future']);
+ expect(validateThemeDefinition(theme)).toEqual([]);
+ expect(collectThemeWarnings(theme)).toEqual([
+ 'Unknown light color token ignored: rgb-future',
+ 'Unknown light appearance token ignored: futureSpacing',
+ ]);
+ const resolved = resolveTheme(theme, 'light');
+ expect(resolved.colors['rgb-accent-primary']).toBe('4 5 6');
+ expect(resolved.colors).not.toHaveProperty('rgb-future');
+ });
+
+ it('still rejects an unknown colour token that is not a well-formed role', () => {
+ const theme = {
+ version: 1,
+ name: 'colour',
+ modes: { light: { colors: { 'rgb-future': 'red', future: '1 2 3' } } },
+ } as ThemeDefinition;
+
+ expect(validateThemeDefinition(theme)).toEqual([
+ 'Unknown color token: rgb-future',
+ 'Unknown color token: future',
+ ]);
});
it('still rejects an injection attempt carried by an unknown key', () => {
diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts
index 78e1a39cdd..c157f06d9b 100644
--- a/packages/client/src/theme/registry.ts
+++ b/packages/client/src/theme/registry.ts
@@ -59,6 +59,8 @@ export type SharedTokensMatchTypes = [
export const themeColorTokens: readonly (keyof IThemeRGB)[] = sharedColorTokens;
+const colorTokenSet: ReadonlySet<string> = new Set<string>(themeColorTokens);
+
/**
* What the verified mark is measured against: the fill it wore before it had a
* token, the check it carries, and the backgrounds `ToolCard` takes at rest and
@@ -88,6 +90,20 @@ export function controlBorderFallback(colors: IThemeRGB): string | undefined {
return colors['rgb-border-light'] ?? colors['rgb-border-medium'];
}
+/**
+ * The pressed fills for a theme that predates them. A pointer press lands on a
+ * hovered control, so the press showed the hover fill; a theme that painted a
+ * hover keeps it for the press, and one that names a pressed fill keeps it.
+ */
+export function pressedFallbacks(colors: IThemeRGB): IThemeRGB {
+ const pressed = colors['rgb-surface-pressed'] ?? colors['rgb-surface-hover'];
+ const inverted = colors['rgb-surface-inverted-pressed'] ?? colors['rgb-surface-inverted-hover'];
+ return {
+ ...(pressed !== undefined ? { 'rgb-surface-pressed': pressed } : {}),
+ ...(inverted !== undefined ? { 'rgb-surface-inverted-pressed': inverted } : {}),
+ };
+}
+
/**
* 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,
@@ -120,6 +136,7 @@ export const themeAppearanceProperties: Readonly<
controlHeight: '--theme-control-height',
spaceCompact: '--theme-space-compact',
spaceNormal: '--theme-space-normal',
+ disabledStyle: '--theme-disabled-style',
fontFamily: '--theme-font-family',
monoFontFamily: '--theme-mono-font-family',
elevationSurface: '--theme-elevation-surface',
@@ -148,6 +165,7 @@ export const defaultAppearance: IThemeAppearance = Object.freeze({
controlHeight: '2.25rem',
spaceCompact: '0.375rem',
spaceNormal: '0.75rem',
+ disabledStyle: 'dim',
fontFamily: 'Inter, sans-serif',
monoFontFamily:
"'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', 'Liberation Mono', Consolas, monospace",
@@ -233,13 +251,17 @@ export const highContrastTheme: ThemeDefinition = Object.freeze({
/** Tailwind composes `--tw-shadow` into one list with the ring layers, where `none` is invalid. */
const disabledShadow = '0 0 #0000';
-/** The appearance tokens this reader does not know, which `resolveTheme` leaves out. */
+/** The client may be older than the server whose theme it paints, so it ignores color roles it
+ * predates the way it already ignores appearance keys. */
+const clientReader = { ignoreFutureColors: true } as const;
+
+/** The color and appearance tokens this reader does not know, which `resolveTheme` leaves out. */
export function collectThemeWarnings(theme: ThemeDefinition): string[] {
- return collectThemeWarningIssues(theme).map(({ message }) => message);
+ return collectThemeWarningIssues(theme, clientReader).map(({ message }) => message);
}
export function validateThemeDefinition(theme: ThemeDefinition): string[] {
- return collectThemeIssues(theme).map(({ message }) => message);
+ return collectThemeIssues(theme, clientReader).map(({ message }) => message);
}
/**
@@ -257,6 +279,16 @@ function definedEntries<T extends object>(values?: Partial<T>): Partial<T> {
) as Partial<T>;
}
+/** A color role this reader predates passed validation as a warning; it never reaches the DOM. */
+function knownColors(colors?: IThemeRGB): IThemeRGB | undefined {
+ if (!colors) {
+ return colors;
+ }
+ return Object.fromEntries(
+ Object.entries(colors).filter(([key]) => colorTokenSet.has(key)),
+ ) as IThemeRGB;
+}
+
function knownAppearance(appearance?: Partial<IThemeAppearance>): Partial<IThemeAppearance> {
return Object.fromEntries(
Object.entries(definedEntries(appearance)).filter(([key]) => isThemeAppearanceToken(key)),
@@ -290,7 +322,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
const baseColors = mode === 'dark' ? darkTheme : defaultTheme;
const definition = theme.modes[mode];
- const customColors = definition?.colors;
+ const customColors = knownColors(definition?.colors);
const composerHoverFallback =
customColors?.['rgb-surface-composer-hover'] === undefined &&
customColors?.['rgb-surface-hover'] !== undefined
@@ -356,6 +388,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
const borderControlFallback =
borderControlSource !== undefined ? { 'rgb-border-control': borderControlSource } : {};
const focusFallback = customColors != null ? focusFallbacks(customColors) : {};
+ const pressedFallback = customColors != null ? pressedFallbacks(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
@@ -417,6 +450,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT
...chartWidgetStrokeFallback,
...borderControlFallback,
...focusFallback,
+ ...pressedFallback,
...seriesEightFallback,
...verifiedFallback,
} as Required<IThemeRGB>,
diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.ts
index a85356bf56..dfc20d8211 100644
--- a/packages/client/src/theme/semanticTokens.spec.ts
+++ b/packages/client/src/theme/semanticTokens.spec.ts
@@ -701,3 +701,36 @@ describe('focus role defaults', () => {
expect(declared).toEqual([defaultTheme['rgb-focus-control'], darkTheme['rgb-focus-control']]);
});
});
+
+describe('state role defaults', () => {
+ /** A pointer press lands on a hovered control, so the default press shows the
+ * hover fill it always did; only a theme that names a pressed fill changes it. */
+ it.each([
+ ['default light', defaultTheme],
+ ['default dark', darkTheme],
+ ['high contrast light', highContrastLightTheme],
+ ['high contrast dark', highContrastDarkTheme],
+ ])('presses %s controls in their hover fills', (_name, theme: IThemeRGB) => {
+ expect(theme['rgb-surface-pressed']).toBe(theme['rgb-surface-hover']);
+ expect(theme['rgb-surface-inverted-pressed']).toBe(theme['rgb-surface-inverted-hover']);
+ });
+
+ it('keeps the package CSS in step with the runtime themes', () => {
+ const controls = readFileSync(join(__dirname, 'controls.css'), 'utf8');
+ const roles = [
+ 'rgb-surface-pressed',
+ 'rgb-surface-inverted-pressed',
+ 'rgb-surface-disabled',
+ 'rgb-text-disabled',
+ 'rgb-border-disabled',
+ ] as const;
+
+ roles.forEach((role) => {
+ const declared = [
+ ...controls.matchAll(new RegExp(`--${role.slice(4)}:\\s*([^;]+);`, 'g')),
+ ].map((match) => match[1].trim());
+
+ expect(declared).toEqual([defaultTheme[role], darkTheme[role]]);
+ });
+ });
+});
diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts
index 704e336213..9f1c2b615c 100644
--- a/packages/client/src/theme/themes/clickhouse.ts
+++ b/packages/client/src/theme/themes/clickhouse.ts
@@ -63,6 +63,7 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-surface-active-alt': '204 207 211', // #cccfd3 (palette.slate.200)
'rgb-surface-hover': '230 231 233', // #e6e7e9 (palette.slate.100)
'rgb-surface-hover-alt': '204 207 211', // #cccfd3 (palette.slate.200)
+ 'rgb-surface-pressed': '221 222 225', // #dddee1 (button.iconButton.color.primary.background.active)
'rgb-surface-composer-hover': '230 231 233', // #e6e7e9 (palette.slate.100)
'rgb-surface-primary': '255 255 255', // #ffffff (background.default)
'rgb-chart-widget-surface': '255 255 255', // #ffffff (background.default)
@@ -84,6 +85,7 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-surface-code-body': '246 247 250', // #f6f7fa (codeblock.lightMode.color.background.default)
'rgb-surface-inverted': '21 21 21', // #151515 (palette.neutral.900)
'rgb-surface-inverted-hover': '50 50 50', // #323232 (palette.neutral.712)
+ 'rgb-surface-inverted-pressed': '22 21 23', // #161517 (button.basic.color.primary.background.active)
'rgb-text-inverted': '255 255 255', // #ffffff (palette.neutral.0)
'rgb-surface-fixed': '255 255 255', // #ffffff (palette.neutral.0, same in light and dark)
'rgb-surface-fixed-hover': '230 231 233', // #e6e7e9 (palette.slate.100, same in light and dark)
@@ -97,6 +99,9 @@ export const clickHouseLightTheme: IThemeRGB = {
'rgb-border-xheavy': '128 134 145', // #808691 (palette.slate.500, two steps past stroke.intense #b3b6bd (2.03:1 on white))
'rgb-border-destructive': '193 0 0', // #c10000 (palette.danger.600)
'rgb-border-control': '128 134 145', // #808691 (palette.slate.500, 3.42:1 on background.muted)
+ 'rgb-surface-disabled': '223 223 223', // #dfdfdf (button.basic.color.primary.background.disabled)
+ 'rgb-text-disabled': '160 160 160', // #a0a0a0 (text.disabled)
+ 'rgb-border-disabled': '223 223 223', // #dfdfdf (field.color.stroke.disabled)
// Status colors
'rgb-status-success': '0 97 8', // #006108 (palette.success.800, one step past feedback.success.foreground #008a0b (4.27:1 on its fill))
@@ -185,6 +190,7 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-surface-active-alt': '50 50 50', // #323232 (palette.neutral.712)
'rgb-surface-hover': '50 50 50', // #323232 (palette.neutral.712)
'rgb-surface-hover-alt': '65 65 65', // #414141 (palette.neutral.700)
+ 'rgb-surface-pressed': '36 36 36', // #242424 (button.iconButton.color.primary.background.active)
'rgb-surface-composer-hover': '50 50 50', // #323232 (palette.neutral.712)
'rgb-surface-primary': '31 31 28', // #1f1f1c (background.default)
'rgb-chart-widget-surface': '40 40 40', // #282828 (background.muted)
@@ -209,6 +215,7 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-surface-code-body': '40 40 40', // #282828 (codeblock.darkMode.color.background.default)
'rgb-surface-inverted': '250 255 105', // #faff69 (button.basic.color.primary.background.default)
'rgb-surface-inverted-hover': '252 255 150', // #fcff96 (button.basic.color.primary.background.hover)
+ 'rgb-surface-inverted-pressed': '231 236 97', // #e7ec61 (button.basic.color.primary.background.active)
'rgb-text-inverted': '31 31 28', // #1f1f1c (button.basic.color.primary.text.default)
'rgb-surface-fixed': '255 255 255', // #ffffff (palette.neutral.0, same in light and dark)
'rgb-surface-fixed-hover': '230 231 233', // #e6e7e9 (palette.slate.100, same in light and dark)
@@ -222,6 +229,9 @@ export const clickHouseDarkTheme: IThemeRGB = {
'rgb-border-xheavy': '128 128 128', // #808080 (palette.neutral.500, three steps past stroke.intense #414141 (1.62:1 on the canvas))
'rgb-border-destructive': '255 117 117', // #ff7575 (palette.danger.300)
'rgb-border-control': '128 128 128', // #808080 (palette.neutral.500, 3.73:1 on background.muted)
+ 'rgb-surface-disabled': '65 65 65', // #414141 (button.basic.color.primary.background.disabled)
+ 'rgb-text-disabled': '128 128 128', // #808080 (text.disabled)
+ 'rgb-border-disabled': '65 65 65', // #414141 (field.color.stroke.disabled)
// Status colors
'rgb-status-success': '204 255 208', // #ccffd0 (feedback.success.foreground)
@@ -313,6 +323,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
+ /** Click UI paints disabled controls in fixed fills (`#dfdfdf` / `#414141`) rather than fading them. */
+ disabledStyle: 'fill' as const,
motionFast: '100ms', // transition.duration.medium, the step transition.default runs at
motionNormal: '150ms', // transition.duration.smooth
};
diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json
index 77439130bd..a2cef0726a 100644
--- a/packages/client/src/theme/themes/clickui.json
+++ b/packages/client/src/theme/themes/clickui.json
@@ -11,9 +11,13 @@
"border.radii.2": "0.5rem",
"border.radii.3": "0.75rem",
"border.radii.full": "9999px",
+ "click.button.basic.color.primary.background.active": "#161517",
+ "click.button.basic.color.primary.background.disabled": "#dfdfdf",
+ "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",
"click.dialog.color.opaqueBackground.default": "lch(6.7738 0 none / 0.75)",
+ "click.field.color.stroke.disabled": "#dfdfdf",
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#c10000",
"click.global.color.text.warning": "#a33c00",
@@ -39,6 +43,7 @@
"global.color.stroke.default": "#e6e7e9",
"global.color.stroke.intense": "#b3b6bd",
"global.color.text.default": "#161517",
+ "global.color.text.disabled": "#a0a0a0",
"global.color.text.link.hover": "#104ec6",
"global.color.text.muted": "#696e79",
"palette.babyblue.600": "#008599",
@@ -78,11 +83,15 @@
"border.radii.2": "0.5rem",
"border.radii.3": "0.75rem",
"border.radii.full": "9999px",
+ "click.button.basic.color.primary.background.active": "rgb(90.686% 92.5% 38.088%)",
"click.button.basic.color.primary.background.default": "#faff69",
+ "click.button.basic.color.primary.background.disabled": "#414141",
"click.button.basic.color.primary.background.hover": "rgb(98.627% 100% 58.824%)",
"click.button.basic.color.primary.text.default": "#1f1f1c",
+ "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",
+ "click.field.color.stroke.disabled": "#414141",
"click.genericMenu.panel.size.height": "2rem",
"click.global.color.text.danger": "#ffbaba",
"click.global.color.text.warning": "#ffb88f",
@@ -114,6 +123,7 @@
"global.color.stroke.default": "#323232",
"global.color.stroke.intense": "#414141",
"global.color.text.default": "#ffffff",
+ "global.color.text.disabled": "#808080",
"global.color.text.link.default": "#faff69",
"global.color.text.link.hover": "#feffc2",
"global.color.text.muted": "#b3b6bd",
diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts
index 4debd99d6d..101ea6191b 100644
--- a/packages/client/src/theme/themes/clickui.spec.ts
+++ b/packages/client/src/theme/themes/clickui.spec.ts
@@ -44,6 +44,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-active-alt': 'palette.slate.200',
'rgb-surface-hover': 'palette.slate.100',
'rgb-surface-hover-alt': 'palette.slate.200',
+ 'rgb-surface-pressed': 'click.button.iconButton.color.primary.background.active',
'rgb-surface-composer-hover': 'palette.slate.100',
'rgb-surface-primary': 'global.color.background.default',
'rgb-chart-widget-surface': 'global.color.background.default',
@@ -65,6 +66,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-code-body': 'click.codeblock.lightMode.color.background.default',
'rgb-surface-inverted': 'palette.neutral.900',
'rgb-surface-inverted-hover': 'palette.neutral.712',
+ 'rgb-surface-inverted-pressed': 'click.button.basic.color.primary.background.active',
'rgb-text-inverted': 'palette.neutral.0',
'rgb-surface-fixed': 'palette.neutral.0',
'rgb-surface-fixed-hover': 'palette.slate.100',
@@ -76,6 +78,9 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-border-xheavy': 'palette.slate.500',
'rgb-border-destructive': 'palette.danger.600',
'rgb-border-control': 'palette.slate.500',
+ 'rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled',
+ 'rgb-text-disabled': 'global.color.text.disabled',
+ 'rgb-border-disabled': 'click.field.color.stroke.disabled',
'rgb-status-success': 'palette.success.800',
'rgb-status-success-subtle': 'global.color.feedback.success.background',
'rgb-status-success-border': 'palette.success.200',
@@ -142,6 +147,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-active-alt': 'palette.neutral.712',
'rgb-surface-hover': 'palette.neutral.712',
'rgb-surface-hover-alt': 'palette.neutral.700',
+ 'rgb-surface-pressed': 'click.button.iconButton.color.primary.background.active',
'rgb-surface-composer-hover': 'palette.neutral.712',
'rgb-surface-primary': 'global.color.background.default',
'rgb-chart-widget-surface': 'global.color.background.muted',
@@ -162,6 +168,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-surface-code-body': 'click.codeblock.darkMode.color.background.default',
'rgb-surface-inverted': 'click.button.basic.color.primary.background.default',
'rgb-surface-inverted-hover': 'click.button.basic.color.primary.background.hover',
+ 'rgb-surface-inverted-pressed': 'click.button.basic.color.primary.background.active',
'rgb-text-inverted': 'click.button.basic.color.primary.text.default',
'rgb-surface-fixed': 'palette.neutral.0',
'rgb-surface-fixed-hover': 'palette.slate.100',
@@ -173,6 +180,9 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'rgb-border-xheavy': 'palette.neutral.500',
'rgb-border-destructive': 'palette.danger.300',
'rgb-border-control': 'palette.neutral.500',
+ 'rgb-surface-disabled': 'click.button.basic.color.primary.background.disabled',
+ 'rgb-text-disabled': 'global.color.text.disabled',
+ 'rgb-border-disabled': 'click.field.color.stroke.disabled',
'rgb-status-success': 'global.color.feedback.success.foreground',
'rgb-status-success-subtle': 'global.color.feedback.success.background',
'rgb-status-success-border': 'palette.success.800',
@@ -225,6 +235,16 @@ const unsourcedColors: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>
},
};
+/**
+ * Appearance choices that are a reading of Click UI rather than one of its values, and the
+ * evidence for each. Click UI gives every disabled control a fixed fill, ink and edge
+ * (`button.basic.color.primary.*.disabled`, `field.color.*.disabled`, `global.color.text.disabled`)
+ * and never fades one, so the theme paints them instead of dimming.
+ */
+const appearanceDecisions: Partial<Record<keyof IThemeAppearance, string>> = {
+ disabledStyle: 'fill: Click UI paints disabled controls in fixed disabled tokens, never opacity',
+};
+
const appearanceSources: Partial<Record<keyof IThemeAppearance, string>> = {
controlRadius: 'border.radii.1',
radiusSm: 'border.radii.1',
@@ -362,7 +382,9 @@ describe('ClickHouse theme drift against Click UI', () => {
it.each(modes)('matches every %s shape, font and motion value to its Click UI token', (mode) => {
const appearance = clickHouseTheme.modes[mode]?.appearance ?? {};
const unsourced = Object.keys(appearance).filter(
- (key) => appearanceSources[key as keyof IThemeAppearance] === undefined,
+ (key) =>
+ appearanceSources[key as keyof IThemeAppearance] === undefined &&
+ appearanceDecisions[key as keyof IThemeAppearance] === undefined,
);
const drift = Object.entries(appearanceSources).flatMap(([name, token]) => {
const key = name as keyof IThemeAppearance;
diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts
index 56469f4548..bcf4e0a3c7 100644
--- a/packages/client/src/theme/themes/dark.ts
+++ b/packages/client/src/theme/themes/dark.ts
@@ -38,6 +38,7 @@ export const darkTheme: IThemeRGB = {
'rgb-surface-active-alt': '47 47 47', // #2f2f2f (gray-700)
'rgb-surface-hover': '57 57 57', // #393939 (gray-650)
'rgb-surface-hover-alt': '66 66 66', // #424242 (gray-600)
+ 'rgb-surface-pressed': '57 57 57', // #393939 (gray-650), the hover fill
'rgb-surface-composer-hover': '66 66 66', // #424242 (gray-600)
'rgb-surface-primary': '13 13 13', // #0d0d0d (gray-900)
'rgb-chart-widget-surface': '40 40 40', // #282828 (Click UI chart widget)
@@ -59,6 +60,7 @@ export const darkTheme: IThemeRGB = {
'rgb-surface-code-body': '23 23 23', // #171717 (gray-850)
'rgb-surface-inverted': '255 255 255', // #fff (white)
'rgb-surface-inverted-hover': '236 236 236', // #ececec (gray-100)
+ 'rgb-surface-inverted-pressed': '236 236 236', // #ececec (gray-100), the hover fill
'rgb-text-inverted': '23 23 23', // #171717 (gray-850)
'rgb-surface-fixed': '255 255 255', // #fff (white) — same in light + dark
'rgb-surface-fixed-hover': '236 236 236', // #ececec (gray-100) — same in light + dark
@@ -72,6 +74,9 @@ export const darkTheme: IThemeRGB = {
'rgb-border-xheavy': '153 150 150', // #999696 (gray-400)
'rgb-border-destructive': '239 68 68', // #ef4444 (red-500)
'rgb-border-control': '33 33 33', // #212121 (gray-800), the stock field edge
+ 'rgb-surface-disabled': '47 47 47', // #2f2f2f (gray-700)
+ 'rgb-text-disabled': '153 150 150', // #999696 (gray-400)
+ 'rgb-border-disabled': '57 57 57', // #393939 (gray-650)
// Status colors
'rgb-status-success': '110 231 183', // #6ee7b7 (green-300)
diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts
index 410a282ca5..8bccc91cc4 100644
--- a/packages/client/src/theme/themes/default.ts
+++ b/packages/client/src/theme/themes/default.ts
@@ -38,6 +38,7 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-active-alt': '227 227 227', // #e3e3e3 (gray-200)
'rgb-surface-hover': '227 227 227', // #e3e3e3 (gray-200)
'rgb-surface-hover-alt': '205 205 205', // #cdcdcd (gray-300)
+ 'rgb-surface-pressed': '227 227 227', // #e3e3e3 (gray-200), the hover fill
'rgb-surface-composer-hover': '227 227 227', // #e3e3e3 (gray-200)
'rgb-surface-primary': '255 255 255', // #fff (white)
'rgb-chart-widget-surface': '255 255 255', // #fff (Click UI chart widget)
@@ -59,6 +60,7 @@ export const defaultTheme: IThemeRGB = {
'rgb-surface-code-body': '255 255 255', // #fff (white)
'rgb-surface-inverted': '23 23 23', // #171717 (gray-850)
'rgb-surface-inverted-hover': '47 47 47', // #2f2f2f (gray-700)
+ 'rgb-surface-inverted-pressed': '47 47 47', // #2f2f2f (gray-700), the hover fill
'rgb-text-inverted': '255 255 255', // #fff (white)
'rgb-surface-fixed': '255 255 255', // #fff (white) — same in light + dark
'rgb-surface-fixed-hover': '236 236 236', // #ececec (gray-100) — same in light + dark
@@ -72,6 +74,9 @@ export const defaultTheme: IThemeRGB = {
'rgb-border-xheavy': '89 89 89', // #595959 (gray-500)
'rgb-border-destructive': '220 38 38', // #dc2626 (red-600)
'rgb-border-control': '227 227 227', // #e3e3e3 (gray-200), the stock field edge
+ 'rgb-surface-disabled': '236 236 236', // #ececec (gray-100)
+ 'rgb-text-disabled': '153 150 150', // #999696 (gray-400)
+ 'rgb-border-disabled': '227 227 227', // #e3e3e3 (gray-200)
// Status colors
'rgb-status-success': '4 120 87', // #047857 (green-700)
diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts
index 2893b71863..aac55cc18c 100644
--- a/packages/client/src/theme/themes/highContrast.ts
+++ b/packages/client/src/theme/themes/highContrast.ts
@@ -71,6 +71,7 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-surface-active-alt': '212 212 212', // #d4d4d4
'rgb-surface-hover': '212 212 212', // #d4d4d4
'rgb-surface-hover-alt': '184 184 184', // #b8b8b8
+ 'rgb-surface-pressed': '212 212 212', // #d4d4d4, the hover fill
'rgb-surface-composer-hover': '212 212 212', // #d4d4d4
'rgb-surface-primary': '255 255 255', // #ffffff
/** The chart widget canvas and its edge, which default to `surface-primary`
@@ -95,6 +96,7 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-surface-code-body': '255 255 255', // #ffffff, matching surface-chat
'rgb-surface-inverted': '0 0 0', // #000000
'rgb-surface-inverted-hover': '51 51 51', // #333333
+ 'rgb-surface-inverted-pressed': '51 51 51', // #333333, the hover fill
'rgb-text-inverted': '255 255 255', // #ffffff
'rgb-surface-fixed': '255 255 255', // #ffffff
'rgb-surface-fixed-hover': '212 212 212', // #d4d4d4
@@ -108,6 +110,9 @@ export const highContrastLightTheme: IThemeRGB = {
'rgb-border-xheavy': '0 0 0', // #000000
'rgb-border-destructive': '161 0 0', // #a10000
'rgb-border-control': '0 0 0', // #000000
+ 'rgb-surface-disabled': '255 255 255', // #ffffff
+ 'rgb-text-disabled': '87 87 87', // #575757
+ 'rgb-border-disabled': '87 87 87', // #575757
// Status colors
'rgb-status-success': '0 92 46', // #005c2e
@@ -216,6 +221,7 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-surface-active-alt': '61 61 61', // #3d3d3d
'rgb-surface-hover': '61 61 61', // #3d3d3d
'rgb-surface-hover-alt': '87 87 87', // #575757
+ 'rgb-surface-pressed': '61 61 61', // #3d3d3d, the hover fill
'rgb-surface-composer-hover': '61 61 61', // #3d3d3d
'rgb-surface-primary': '0 0 0', // #000000
/** See the light mode note: the widget takes the plain canvas and a pure-ink
@@ -239,6 +245,7 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-surface-code-body': '0 0 0', // #000000, matching surface-primary-alt
'rgb-surface-inverted': '255 255 255', // #ffffff
'rgb-surface-inverted-hover': '212 212 212', // #d4d4d4
+ 'rgb-surface-inverted-pressed': '212 212 212', // #d4d4d4, the hover fill
'rgb-text-inverted': '0 0 0', // #000000
'rgb-surface-fixed': '255 255 255', // #ffffff
'rgb-surface-fixed-hover': '212 212 212', // #d4d4d4
@@ -252,6 +259,9 @@ export const highContrastDarkTheme: IThemeRGB = {
'rgb-border-xheavy': '255 255 255', // #ffffff
'rgb-border-destructive': '255 143 143', // #ff8f8f
'rgb-border-control': '255 255 255', // #ffffff
+ 'rgb-surface-disabled': '0 0 0', // #000000
+ 'rgb-text-disabled': '184 184 184', // #b8b8b8
+ 'rgb-border-disabled': '184 184 184', // #b8b8b8
// Status colors
'rgb-status-success': '127 240 179', // #7ff0b3
diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css
index f4b46d75aa..03ee718712 100644
--- a/packages/client/src/theme/tokens.css
+++ b/packages/client/src/theme/tokens.css
@@ -30,6 +30,7 @@
--color-surface-active-alt: rgb(var(--surface-active-alt));
--color-surface-hover: rgb(var(--surface-hover));
--color-surface-hover-alt: rgb(var(--surface-hover-alt));
+ --color-surface-pressed: rgb(var(--surface-pressed));
--color-surface-composer-hover: rgb(var(--surface-composer-hover));
--color-surface-primary: rgb(var(--surface-primary));
--color-surface-primary-alt: rgb(var(--surface-primary-alt));
@@ -50,8 +51,10 @@
--color-surface-qr: rgb(var(--surface-qr));
--color-surface-inverted: rgb(var(--surface-inverted));
--color-surface-inverted-hover: rgb(var(--surface-inverted-hover));
+ --color-surface-inverted-pressed: rgb(var(--surface-inverted-pressed));
--color-surface-fixed: rgb(var(--surface-fixed));
--color-surface-fixed-hover: rgb(var(--surface-fixed-hover));
+ --color-surface-disabled: rgb(var(--surface-disabled));
/* text */
--color-text-primary: rgb(var(--text-primary));
@@ -64,6 +67,7 @@
--color-text-inverted: rgb(var(--text-inverted));
--color-text-fixed: rgb(var(--text-fixed));
--color-text-on-status: rgb(var(--text-on-status));
+ --color-text-disabled: rgb(var(--text-disabled));
/* links */
--color-link: rgb(var(--link));
@@ -78,6 +82,7 @@
--color-border-xheavy: rgb(var(--border-xheavy) / var(--border-xheavy-alpha, 1));
--color-border-destructive: rgb(var(--border-destructive));
--color-border-control: rgb(var(--border-control));
+ --color-border-disabled: rgb(var(--border-disabled));
/* status */
--color-status-success: rgb(var(--status-success));
@@ -116,3 +121,18 @@
--color-chart-widget-stroke: rgb(var(--chart-widget-stroke));
--color-switch-unchecked: rgb(var(--switch-unchecked));
}
+
+/* A theme whose `disabledStyle` is `fill` paints a disabled control in the
+ * disabled roles instead of fading it; `ThemeProvider` mirrors that choice as
+ * `data-theme-disabled` on the root. The default `dim` style keeps the
+ * `disabled:opacity-50` every primitive already carries. `:is()` carries the
+ * attribute's weight, so the fill outranks a checked or variant fill. Radix
+ * marks a disabled part that is not a form control (a slider thumb, a menu
+ * item) with `data-disabled`, and a composite widget row with `aria-disabled`;
+ * both count too. */
+@custom-variant theme-disabled (&:is([data-theme-disabled='fill'] *):is(:disabled, [data-disabled], [aria-disabled='true']));
+
+/* The same fill for a wrapper whose disabled control sits inside it, as
+ * `rc-input-number` renders its input inside the element that takes the
+ * component's classes. */
+@custom-variant theme-disabled-within (&:is([data-theme-disabled='fill'] *):has(:disabled));
diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts
index b782f3dc16..2ce980fe85 100644
--- a/packages/client/src/theme/types/index.ts
+++ b/packages/client/src/theme/types/index.ts
@@ -39,6 +39,8 @@ export interface IThemeRGB {
'rgb-surface-active-alt'?: string;
'rgb-surface-hover'?: string;
'rgb-surface-hover-alt'?: string;
+ /** Fill of a neutral control while pressed; follows `rgb-surface-hover` when a theme omits it. */
+ 'rgb-surface-pressed'?: string;
'rgb-surface-composer-hover'?: string;
'rgb-surface-primary'?: string;
'rgb-chart-widget-surface'?: string;
@@ -60,6 +62,8 @@ export interface IThemeRGB {
'rgb-surface-code-body'?: string;
'rgb-surface-inverted'?: string;
'rgb-surface-inverted-hover'?: string;
+ /** Fill of an inverted control while pressed; follows `rgb-surface-inverted-hover` when omitted. */
+ 'rgb-surface-inverted-pressed'?: string;
'rgb-text-inverted'?: string;
'rgb-surface-fixed'?: string;
'rgb-surface-fixed-hover'?: string;
@@ -76,6 +80,10 @@ export interface IThemeRGB {
* 3:1 non-text floor on every canvas, so it is kept apart from the separator
* roles above, which stay quiet. */
'rgb-border-control'?: string;
+ /** Disabled fill, ink and edge. Painted only under the `fill` disabled style. */
+ 'rgb-surface-disabled'?: string;
+ 'rgb-text-disabled'?: string;
+ 'rgb-border-disabled'?: string;
// Status colors
'rgb-status-success'?: string;
@@ -183,6 +191,7 @@ export interface IThemeVariables {
'--surface-active-alt': string;
'--surface-hover': string;
'--surface-hover-alt': string;
+ '--surface-pressed': string;
'--surface-composer-hover': string;
'--surface-primary': string;
'--chart-widget-surface': string;
@@ -204,6 +213,7 @@ export interface IThemeVariables {
'--surface-code-body': string;
'--surface-inverted': string;
'--surface-inverted-hover': string;
+ '--surface-inverted-pressed': string;
'--text-inverted': string;
'--surface-fixed': string;
'--surface-fixed-hover': string;
@@ -219,6 +229,9 @@ export interface IThemeVariables {
'--border-xheavy-alpha': string;
'--border-destructive': string;
'--border-control': string;
+ '--surface-disabled': string;
+ '--text-disabled': string;
+ '--border-disabled': string;
'--status-success': string;
'--status-success-subtle': string;
'--status-success-border': string;
@@ -291,6 +304,7 @@ export interface IThemeColors {
'surface-active-alt'?: string;
'surface-hover'?: string;
'surface-hover-alt'?: string;
+ 'surface-pressed'?: string;
'surface-composer-hover'?: string;
'surface-primary'?: string;
'chart-widget-surface'?: string;
@@ -312,6 +326,7 @@ export interface IThemeColors {
'surface-code-body'?: string;
'surface-inverted'?: string;
'surface-inverted-hover'?: string;
+ 'surface-inverted-pressed'?: string;
'text-inverted'?: string;
'surface-fixed'?: string;
'surface-fixed-hover'?: string;
@@ -323,6 +338,9 @@ export interface IThemeColors {
'border-xheavy'?: string;
'border-destructive'?: string;
'border-control'?: string;
+ 'surface-disabled'?: string;
+ 'text-disabled'?: string;
+ 'border-disabled'?: string;
'status-success'?: string;
'status-success-subtle'?: string;
'status-success-border'?: string;
@@ -385,6 +403,8 @@ export interface IThemeAppearance {
controlHeight: string;
spaceCompact: string;
spaceNormal: string;
+ /** `dim` fades a disabled control to half opacity; `fill` paints it in the disabled roles. */
+ disabledStyle: 'dim' | 'fill';
fontFamily: string;
monoFontFamily: string;
elevationSurface: string;
diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.ts
index 9ad799d4f6..2c6ef97a7f 100644
--- a/packages/client/src/theme/utils/applyTheme.spec.ts
+++ b/packages/client/src/theme/utils/applyTheme.spec.ts
@@ -3,6 +3,7 @@ import applyTheme, {
applyResolvedTheme,
clearAppliedTheme,
themeOwnedProperties,
+ THEME_DISABLED_ATTRIBUTE,
} from './applyTheme';
import { defaultAppearance, highContrastTheme, resolveTheme } from '../registry';
import { defaultTheme } from '../themes/default';
@@ -332,6 +333,38 @@ describe('applyTheme', () => {
expect(root.style.getPropertyValue('--chart-widget-stroke')).toBe('50 51 52');
});
+ it('carries a legacy hover onto the pressed fills', () => {
+ const root = document.documentElement;
+
+ applyTheme(
+ { 'rgb-surface-hover': '110 111 112', 'rgb-surface-inverted-hover': '20 21 22' },
+ root,
+ defaultTheme,
+ );
+
+ expect(root.style.getPropertyValue('--surface-pressed')).toBe('110 111 112');
+ expect(root.style.getPropertyValue('--surface-inverted-pressed')).toBe('20 21 22');
+ });
+
+ it('marks the root only for a theme that fills its disabled controls, and clears it', () => {
+ const root = document.documentElement;
+ const fill: ThemeDefinition = {
+ version: 1,
+ name: 'fill-reference',
+ modes: { light: { appearance: { disabledStyle: 'fill' } } },
+ };
+
+ applyResolvedTheme(resolveTheme(fill, 'light'), root);
+ expect(root.getAttribute(THEME_DISABLED_ATTRIBUTE)).toBe('fill');
+
+ applyResolvedTheme(resolveTheme({ ...fill, modes: {} }, 'light'), root);
+ expect(root.hasAttribute(THEME_DISABLED_ATTRIBUTE)).toBe(false);
+
+ applyResolvedTheme(resolveTheme(fill, 'light'), root);
+ clearAppliedTheme(root);
+ expect(root.hasAttribute(THEME_DISABLED_ATTRIBUTE)).toBe(false);
+ });
+
it('carries a legacy light border onto the control outline', () => {
const root = document.documentElement;
diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.ts
index 8eed809fc4..a5e6c24c53 100644
--- a/packages/client/src/theme/utils/applyTheme.ts
+++ b/packages/client/src/theme/utils/applyTheme.ts
@@ -2,6 +2,7 @@ import type { IThemeAppearance, IThemeBrands, IThemeRGB, ResolvedThemeDefinition
import {
controlBorderFallback,
focusFallbacks,
+ pressedFallbacks,
MARK_NEIGHBOURHOOD,
themeAppearanceProperties,
themeBrandTokens,
@@ -85,6 +86,17 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]>
variables.push(['--focus-control', focus['rgb-focus-control']]);
}
+ const pressed = pressedFallbacks(colors);
+ if (colors['rgb-surface-pressed'] === undefined && pressed['rgb-surface-pressed'] !== undefined) {
+ variables.push(['--surface-pressed', pressed['rgb-surface-pressed']]);
+ }
+ if (
+ colors['rgb-surface-inverted-pressed'] === undefined &&
+ pressed['rgb-surface-inverted-pressed'] !== undefined
+ ) {
+ variables.push(['--surface-inverted-pressed', pressed['rgb-surface-inverted-pressed']]);
+ }
+
/**
* 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
@@ -113,9 +125,16 @@ function mapAppearance(appearance: IThemeAppearance): Array<[string, string]> {
]);
}
+/**
+ * Mirrors the applied theme's `disabledStyle` on the root, where the
+ * `theme-disabled:` variant reads it. Absent means the default `dim` style.
+ */
+export const THEME_DISABLED_ATTRIBUTE = 'data-theme-disabled';
+
export function clearAppliedTheme(root: HTMLElement = document.documentElement): void {
themeOwnedProperties.forEach((property) => root.style.removeProperty(property));
root.removeAttribute('data-theme');
+ root.removeAttribute(THEME_DISABLED_ATTRIBUTE);
}
export function applyResolvedTheme(
@@ -132,6 +151,11 @@ export function applyResolvedTheme(
variables.forEach(([property, value]) => root.style.setProperty(property, value));
root.dataset.theme = theme.name;
+ if (theme.appearance.disabledStyle === 'fill') {
+ root.setAttribute(THEME_DISABLED_ATTRIBUTE, 'fill');
+ } else {
+ root.removeAttribute(THEME_DISABLED_ATTRIBUTE);
+ }
}
/**
diff --git a/packages/client/src/utils/composer.ts b/packages/client/src/utils/composer.ts
index 2b91b675b3..fac779d19f 100644
--- a/packages/client/src/utils/composer.ts
+++ b/packages/client/src/utils/composer.ts
@@ -1,3 +1,4 @@
+import { disabledFillClasses } from './theme';
import { cn } from './utils';
/**
@@ -38,6 +39,7 @@ export const composerSubmitClasses = (): string =>
'rounded-theme-control-round bg-text-primary p-theme-compact text-text-primary',
'outline-offset-4 transition-all duration-theme-normal',
'disabled:cursor-not-allowed disabled:text-text-secondary disabled:opacity-10',
+ disabledFillClasses,
);
/**
diff --git a/packages/client/src/utils/theme.ts b/packages/client/src/utils/theme.ts
index e84e05f45c..b0cce449f8 100644
--- a/packages/client/src/utils/theme.ts
+++ b/packages/client/src/utils/theme.ts
@@ -1,3 +1,32 @@
+/**
+ * The disabled appearance a `fill` theme paints (`disabledStyle: 'fill'`): the
+ * disabled fill, ink, placeholder and edge at full opacity. Every shared control
+ * composes it beside its own `disabled:opacity-*`, which stays the default `dim`
+ * treatment, so a theme's choice reaches every primitive at once. The hover pair
+ * outranks a control's own `disabled:hover:*` reset, and descendants that own
+ * their ink (a label, a glyph) take the disabled ink too.
+ */
+export const disabledFillClasses =
+ 'theme-disabled:border-border-disabled theme-disabled:bg-surface-disabled theme-disabled:text-text-disabled theme-disabled:placeholder:text-text-disabled theme-disabled:opacity-100 theme-disabled:hover:bg-surface-disabled theme-disabled:hover:text-text-disabled theme-disabled:[&_*]:text-text-disabled';
+
+/**
+ * The disabled ink alone, for a menu item, tab or row whose surface stays as it
+ * is while disabled (Click UI's `genericMenu.item.color.*.disabled` keeps the
+ * item's background and grays its text, icons included, since a row's icon
+ * often owns its own color), and for a label that follows its control through
+ * `peer`.
+ */
+export const disabledInkClasses =
+ 'theme-disabled:text-text-disabled theme-disabled:opacity-100 theme-disabled:[&_*]:text-text-disabled';
+export const peerDisabledInkClasses =
+ 'peer-theme-disabled:text-text-disabled peer-theme-disabled:opacity-100 peer-theme-disabled:[&_svg]:text-text-disabled';
+
+/** The same recipe for a wrapper around the disabled control rather than the control itself; the
+ * control inherits the ink and shows the fill through its transparent background, and the
+ * wrapper's own parts (OTP slots) take the disabled edge and ink. */
+export const disabledWithinFillClasses =
+ 'theme-disabled-within:border-border-disabled theme-disabled-within:bg-surface-disabled theme-disabled-within:text-text-disabled theme-disabled-within:opacity-100 theme-disabled-within:[&_*]:border-border-disabled theme-disabled-within:[&_*]:text-text-disabled';
+
export const applyFontSize = (val: string): void => {
const root = document.documentElement;
const size = val.split('-')[1]; // This will be 'xs', 'sm', 'base', 'lg', or 'xl'
diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts
index 46ea02e755..09687a1897 100644
--- a/packages/data-provider/src/theme.ts
+++ b/packages/data-provider/src/theme.ts
@@ -38,6 +38,7 @@ export const themeColorTokens = Object.freeze([
'rgb-surface-active-alt',
'rgb-surface-hover',
'rgb-surface-hover-alt',
+ 'rgb-surface-pressed',
'rgb-surface-composer-hover',
'rgb-surface-primary',
'rgb-chart-widget-surface',
@@ -59,6 +60,7 @@ export const themeColorTokens = Object.freeze([
'rgb-surface-code-body',
'rgb-surface-inverted',
'rgb-surface-inverted-hover',
+ 'rgb-surface-inverted-pressed',
'rgb-text-inverted',
'rgb-surface-fixed',
'rgb-surface-fixed-hover',
@@ -70,6 +72,9 @@ export const themeColorTokens = Object.freeze([
'rgb-border-xheavy',
'rgb-border-destructive',
'rgb-border-control',
+ 'rgb-surface-disabled',
+ 'rgb-text-disabled',
+ 'rgb-border-disabled',
'rgb-status-success',
'rgb-status-success-subtle',
'rgb-status-success-border',
@@ -268,6 +273,8 @@ const appearanceValidators = {
controlHeight: isLength,
spaceCompact: isLength,
spaceNormal: isLength,
+ /** `dim` fades a disabled control to half opacity; `fill` paints it in the disabled roles. */
+ disabledStyle: (value: unknown) => value === 'dim' || value === 'fill',
fontFamily: isFontFamily,
monoFontFamily: isFontFamily,
/** Released themes may hold `var()` here, so this role keeps its original, looser check. */
@@ -306,28 +313,59 @@ const themeModes = ['light', 'dark'] as const;
const isFutureAppearance = (key: string, value: unknown): boolean =>
/^[a-z][a-zA-Z0-9]*$/.test(key) && typeof value === 'string' && !/[;{}<>]|url\s*\(/i.test(value);
+/**
+ * The same allowance for a color role: a well-formed `rgb-` name holding an RGB triplet is one
+ * this reader predates, so it is ignored rather than rejecting a theme a newer server or build
+ * wrote. Anything else under an unknown name is still an error.
+ */
+const isFutureColor = (key: string, value: unknown): boolean =>
+ /^rgb-[a-z][a-z0-9-]*$/.test(key) && isThemeRGB(value);
+
const issue = (path: string[], message: string): ThemeIssue => ({ path, message });
-/** The appearance tokens this reader does not know, which a resolved theme leaves out. */
-export function collectThemeWarningIssues(theme: unknown): ThemeIssue[] {
+export interface ThemeReadOptions {
+ /**
+ * A reader that may be older than the definition it paints (a cached client reading a newer
+ * server's theme) ignores well-formed color roles it predates. The server reads its own config
+ * with its own token list, so there an unknown role is a typo and stays an error.
+ */
+ ignoreFutureColors?: boolean;
+}
+
+/** The color and appearance tokens this reader does not know, which a resolved theme leaves out. */
+export function collectThemeWarningIssues(
+ theme: unknown,
+ { ignoreFutureColors = false }: ThemeReadOptions = {},
+): ThemeIssue[] {
if (!isPlainThemeRecord(theme) || !isPlainThemeRecord(theme.modes)) {
return [];
}
const modes = theme.modes;
return themeModes.flatMap((mode) => {
const definition = modes[mode];
- const appearance = isPlainThemeRecord(definition) ? definition.appearance : undefined;
- if (!isPlainThemeRecord(appearance)) {
+ if (!isPlainThemeRecord(definition)) {
return [];
}
- return Object.keys(appearance)
- .filter((key) => !isThemeAppearanceToken(key))
- .map((key) =>
- issue(
- ['modes', mode, 'appearance', key],
- `Unknown ${mode} appearance token ignored: ${key}`,
- ),
- );
+ const { colors, appearance } = definition;
+ const futureColors =
+ ignoreFutureColors && isPlainThemeRecord(colors)
+ ? Object.entries(colors)
+ .filter(([key, value]) => !colorTokenSet.has(key) && isFutureColor(key, value))
+ .map(([key]) =>
+ issue(['modes', mode, 'colors', key], `Unknown ${mode} color token ignored: ${key}`),
+ )
+ : [];
+ const futureAppearance = isPlainThemeRecord(appearance)
+ ? Object.keys(appearance)
+ .filter((key) => !isThemeAppearanceToken(key))
+ .map((key) =>
+ issue(
+ ['modes', mode, 'appearance', key],
+ `Unknown ${mode} appearance token ignored: ${key}`,
+ ),
+ )
+ : [];
+ return [...futureColors, ...futureAppearance];
});
}
@@ -354,7 +392,11 @@ function collectBrandIssues(brands: unknown, path: string[]): ThemeIssue[] {
});
}
-function collectModeIssues(mode: 'light' | 'dark', definition: unknown): ThemeIssue[] {
+function collectModeIssues(
+ mode: 'light' | 'dark',
+ definition: unknown,
+ { ignoreFutureColors = false }: ThemeReadOptions,
+): ThemeIssue[] {
const base = ['modes', mode];
if (definition === undefined) {
return [];
@@ -374,7 +416,9 @@ function collectModeIssues(mode: 'light' | 'dark', definition: unknown): ThemeIs
Object.entries(colors ?? {}).forEach(([key, value]) => {
const path = [...base, 'colors', key];
if (!colorTokenSet.has(key)) {
- issues.push(issue(path, `Unknown color token: ${key}`));
+ if (!ignoreFutureColors || !isFutureColor(key, value)) {
+ issues.push(issue(path, `Unknown color token: ${key}`));
+ }
return;
}
if (value !== undefined && !isThemeRGB(value)) {
@@ -407,7 +451,7 @@ function collectModeIssues(mode: 'light' | 'dark', definition: unknown): ThemeIs
}
/** Every reason a definition cannot be painted; empty when it can. */
-export function collectThemeIssues(theme: unknown): ThemeIssue[] {
+export function collectThemeIssues(theme: unknown, options: ThemeReadOptions = {}): ThemeIssue[] {
if (!isPlainThemeRecord(theme)) {
return [issue([], 'Theme definition must be an object')];
}
@@ -432,7 +476,7 @@ export function collectThemeIssues(theme: unknown): ThemeIssue[] {
.filter((mode) => mode !== 'light' && mode !== 'dark')
.forEach((mode) => issues.push(issue(['modes', mode], `Unknown theme mode: ${mode}`)));
- themeModes.forEach((mode) => issues.push(...collectModeIssues(mode, modes[mode])));
+ themeModes.forEach((mode) => issues.push(...collectModeIssues(mode, modes[mode], options)));
if (theme.brands !== undefined && !isPlainThemeRecord(theme.brands)) {
issues.push(issue(['brands'], 'Theme brands must be an object'));