From ef1aa668126d1d7604519d21aa31b098bb24407d Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Wed, 30 Sep 2026 18:58:25 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20feat:=20Give=20the=20Ba?= =?UTF-8?q?dge=20Label=20Its=20Own=20Ink=20and=20Let=20the=20Legacy=20Dial?= =?UTF-8?q?og=20Spinner=20Inherit=20(#16554)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Give the Badge Label Its Own Ink and Let the Legacy Dialog Spinner Inherit The shared Badge inherited the primary ink, so a theme could not label it in Click UI's muted badge ink without dimming body copy. It now reads a badge-label color role that defaults to the primary ink and follows it for a theme that names only that; a hovered or selected badge keeps the primary ink, which holds AA on those fills. The ClickHouse theme takes Click UI's badge.opaque.color.text.default, and the Badge label leaves the drift guard's not-expressible list. The template's legacy selection spinner painted in text-primary on the primary fill, dark on dark. It now takes the action's own foreground. * refactor: Fold the Avatar Glyph Into the Shared Primary Ink Fallback The default avatar's glyph, the dialog title and the badge label all split out of the primary ink and follow it for a theme that names only that, so the avatar keeps one fallback with the others instead of its own copy in resolveTheme and applyTheme. * fix: Keep a Disabled Badge in Its Resting Ink on Hover * fix: Keep a Disabled Selected Badge in the Primary Ink on Hover --- e2e/specs/mock/scenarios/badge-label.spec.ts | 85 +++++++++++++++++++ packages/client/src/components/Badge.spec.tsx | 31 +++++++ packages/client/src/components/Badge.tsx | 9 +- .../client/src/components/Button.spec.tsx | 21 +++++ .../src/components/OGDialogTemplate.tsx | 6 +- packages/client/src/theme/README.md | 2 + packages/client/src/theme/defaults.css | 2 + packages/client/src/theme/defaults.spec.ts | 3 +- packages/client/src/theme/registry.spec.ts | 23 +++++ packages/client/src/theme/registry.ts | 32 ++++--- .../client/src/theme/semanticTokens.spec.ts | 23 ++++- .../client/src/theme/themes/clickhouse.ts | 2 + .../client/src/theme/themes/clickui.spec.ts | 9 +- packages/client/src/theme/themes/dark.ts | 1 + packages/client/src/theme/themes/default.ts | 1 + .../client/src/theme/themes/highContrast.ts | 2 + packages/client/src/theme/tokens.css | 2 + packages/client/src/theme/types/index.ts | 4 + .../client/src/theme/utils/applyTheme.spec.ts | 1 + packages/client/src/theme/utils/applyTheme.ts | 18 ++-- packages/data-provider/src/theme.ts | 1 + 21 files changed, 241 insertions(+), 37 deletions(-) create mode 100644 e2e/specs/mock/scenarios/badge-label.spec.ts diff --git a/e2e/specs/mock/scenarios/badge-label.spec.ts b/e2e/specs/mock/scenarios/badge-label.spec.ts new file mode 100644 index 0000000000..932898b653 --- /dev/null +++ b/e2e/specs/mock/scenarios/badge-label.spec.ts @@ -0,0 +1,85 @@ +import { expect, test } from '@playwright/test'; +import type { Page } from '@playwright/test'; +import type { ThemeDefinition } from '../../../../packages/client/src/theme/types'; +import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse'; +import { NEW_CHAT_PATH } from '../helpers'; +import { probeStyle } from './style.helpers'; + +/** + * The shared Badge labels itself in the `badge-label` role, which no app surface renders yet, so + * each scenario resolves the role through the stylesheet the app shipped, under the theme the + * app applied, the same way a Badge in a consumer would. + */ +test.describe.configure({ timeout: 120_000 }); + +type Mode = 'light' | 'dark'; + +/** A definition from before the badge label role, which repainted only the primary ink. */ +const legacyInkTheme: ThemeDefinition = { + version: 1, + name: 'legacy-ink-reference', + modes: { + light: { colors: { 'rgb-text-primary': '10 20 30' } }, + dark: { colors: { 'rgb-text-primary': '10 20 30' } }, + }, +}; + +async function openWith(page: Page, definition: ThemeDefinition | null) { + await page.addInitScript((stored) => { + localStorage.removeItem('theme-colors'); + localStorage.removeItem('theme-name'); + if (stored === null) { + localStorage.removeItem('theme-definition'); + localStorage.removeItem('theme-source'); + return; + } + localStorage.setItem('theme-definition', JSON.stringify(stored)); + localStorage.setItem('theme-source', 'definition'); + }, definition); + await page.goto(NEW_CHAT_PATH, { timeout: 15000 }); + await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({ + timeout: 15000, + }); +} + +const resolvedMode = (page: Page) => + page.evaluate(() => + document.documentElement.classList.contains('dark') ? 'dark' : 'light', + ) as Promise; + +test.describe('theme badge label', () => { + test('badges keep the primary ink without a theme @scenario:badge-label-keeps-primary-ink-by-default', async ({ + page, + }) => { + await openWith(page, null); + + expect(await probeStyle(page, 'text-badge-label', 'color')).toBe( + await probeStyle(page, 'text-text-primary', 'color'), + ); + }); + + test('ClickHouse badges take Click UI badge label ink @scenario:clickhouse-badge-label-follows-click-ui', async ({ + page, + }) => { + await openWith(page, clickHouseTheme); + await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse'); + const mode = await resolvedMode(page); + + /** `badge.opaque.color.text.default`. */ + expect(await probeStyle(page, 'text-badge-label', 'color')).toBe( + mode === 'light' ? 'rgb(105, 110, 121)' : 'rgb(179, 182, 189)', + ); + expect(await probeStyle(page, 'text-badge-label', 'color')).not.toBe( + await probeStyle(page, 'text-text-primary', 'color'), + ); + }); + + test('a theme that repaints only the primary ink keeps its badge labels on it @scenario:legacy-ink-theme-keeps-badge-label', async ({ + page, + }) => { + await openWith(page, legacyInkTheme); + await expect(page.locator('html')).toHaveAttribute('data-theme', 'legacy-ink-reference'); + + expect(await probeStyle(page, 'text-badge-label', 'color')).toBe('rgb(10, 20, 30)'); + }); +}); diff --git a/packages/client/src/components/Badge.spec.tsx b/packages/client/src/components/Badge.spec.tsx index 97774a7592..b9c69ce9a0 100644 --- a/packages/client/src/components/Badge.spec.tsx +++ b/packages/client/src/components/Badge.spec.tsx @@ -35,4 +35,35 @@ describe('Badge', () => { fireEvent.mouseDown(badge); expect(onMouseDown).toHaveBeenCalledTimes(1); }); + + /** The label reads its own ink role, which a theme can set apart from body copy. */ + it('labels a resting badge in the badge label ink and a hovered or selected one in the primary ink', () => { + const { rerender } = render(); + expect(screen.getByRole('button', { name: 'Tools' })).toHaveClass( + 'text-badge-label', + 'hover:text-text-primary', + ); + + rerender(); + const selected = screen.getByRole('button', { name: 'Tools' }); + expect(selected).toHaveClass('text-text-primary'); + expect(selected).not.toHaveClass('text-badge-label'); + }); + + /** A disabled badge keeps its resting ink on hover, as it keeps its resting shadow. */ + it('keeps a disabled badge in its resting ink on hover', () => { + render(); + const badge = screen.getByRole('button', { name: 'Tools' }); + + expect(badge).toHaveClass('hover:text-badge-label'); + expect(badge).not.toHaveClass('hover:text-text-primary'); + }); + + it('keeps a disabled selected badge in the primary ink on hover', () => { + render(); + const badge = screen.getByRole('button', { name: 'Tools' }); + + expect(badge).toHaveClass('text-text-primary'); + expect(badge).not.toHaveClass('hover:text-badge-label'); + }); }); diff --git a/packages/client/src/components/Badge.tsx b/packages/client/src/components/Badge.tsx index 1be1aca918..bf7c74f105 100644 --- a/packages/client/src/components/Badge.tsx +++ b/packages/client/src/components/Badge.tsx @@ -73,12 +73,17 @@ export default function Badge({ 'group relative inline-flex items-center gap-1.5 rounded-full px-4 py-1.5', 'border border-border-medium text-sm font-medium transition-shadow', '@container-[600px]:w-full size-9 p-2', + /** A resting badge takes the badge label ink; a hovered or selected one moves to the primary + * ink, which holds AA on the hover and active fills where a muted label may not. */ isActive - ? 'bg-surface-active shadow-md' - : 'bg-surface-chat shadow-xs hover:bg-surface-hover hover:shadow-md', + ? 'bg-surface-active text-text-primary shadow-md' + : 'bg-surface-chat text-badge-label shadow-xs hover:bg-surface-hover hover:text-text-primary hover:shadow-md', 'active:scale-95 active:shadow-inner', isMoveable && 'cursor-move', isDisabled && 'cursor-not-allowed opacity-50 hover:shadow-xs', + /** A disabled badge keeps its resting ink on hover; a selected one already rests in the + * primary ink. */ + isDisabled && !isActive && 'hover:text-badge-label', className, ); const badgeContent = ( diff --git a/packages/client/src/components/Button.spec.tsx b/packages/client/src/components/Button.spec.tsx index da6042c129..d5abb3208b 100644 --- a/packages/client/src/components/Button.spec.tsx +++ b/packages/client/src/components/Button.spec.tsx @@ -227,4 +227,25 @@ describe('Button', () => { ); expect(confirm).not.toHaveClass('h-10'); }); + + /** The spinner stood in text-primary on the primary fill, dark on dark; it now paints in the + * action's own foreground, whatever fill the caller gives it. */ + it('draws a templated dialog’s legacy loading spinner in the action’s own ink', () => { + render( + + + , + ); + + const spinner = document.querySelector('svg.spinner'); + expect(spinner).not.toBeNull(); + expect(spinner?.getAttribute('class')).not.toMatch(/\btext-/); + expect(spinner?.closest('button')).toHaveClass('text-text-inverted'); + spinner + ?.querySelectorAll('circle') + .forEach((circle) => expect(circle).toHaveAttribute('stroke', 'currentColor')); + }); }); diff --git a/packages/client/src/components/OGDialogTemplate.tsx b/packages/client/src/components/OGDialogTemplate.tsx index 633a303385..02d278ac88 100644 --- a/packages/client/src/components/OGDialogTemplate.tsx +++ b/packages/client/src/components/OGDialogTemplate.tsx @@ -116,11 +116,7 @@ const OGDialogTemplate: ForwardRefExoticComponent< selectClasses ?? defaultSelect } h-theme-button flex items-center justify-center rounded-lg border-none px-4 py-2 text-sm disabled:opacity-80 max-sm:order-first max-sm:w-full sm:order-none`} > - {isLoading === true ? ( - - ) : ( - (selectText as React.JSX.Element) - )} + {isLoading === true ? : (selectText as React.JSX.Element)} ); } else if (selection) { diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md index 89b5c00635..183ee5f39f 100644 --- a/packages/client/src/theme/README.md +++ b/packages/client/src/theme/README.md @@ -351,6 +351,8 @@ Each status family has a foreground, a `-subtle` background, a `-border`, and a `theme-field-border:` variant `applyTheme` enables with `data-theme-field-focus`. `Label` reads `labelSize` (follows `textSm`), `labelLeading` and `labelFontWeight` (`inherit` by default, so a label keeps the weight around it). +- `text-badge-label` - The shared `Badge`'s resting label ink; a hovered or selected + badge moves to `text-primary`. Follows `text-primary` when a theme names only that. - `text-dialog-title` - An OGDialog title's ink. Follows `text-primary` when a theme names only that. - OGDialog chrome - `border-(length:--theme-dialog-stroke)` (`dialogStroke`, painted in diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css index acce45f520..3bb5874db3 100644 --- a/packages/client/src/theme/defaults.css +++ b/packages/client/src/theme/defaults.css @@ -85,6 +85,7 @@ html { --text-secondary-alt: var(--gray-500); --text-tertiary: var(--gray-500); --text-muted: 105 110 121; /* Click UI global.color.text.muted #696e79 */ + --badge-label: var(--text-primary); --shimmer-dip: 129 130 134; --shimmer-dip-alpha: 0.18; --text-warning: var(--amber-700); @@ -290,6 +291,7 @@ html { --text-secondary-alt: var(--gray-400); --text-tertiary: var(--gray-400); --text-muted: 179 182 189; /* Click UI global.color.text.muted #b3b6bd */ + --badge-label: var(--text-primary); --shimmer-base: 255 255 255; --shimmer-base-alpha: 0.8; --shimmer-dip: 179 179 179; diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts index 78dc0bd6b3..dc7b21afb3 100644 --- a/packages/client/src/theme/defaults.spec.ts +++ b/packages/client/src/theme/defaults.spec.ts @@ -63,7 +63,7 @@ describe.each([ const tokens = Object.keys(theme) as Array; it('covers every registry color', () => { - expect(tokens).toHaveLength(113); + expect(tokens).toHaveLength(114); }); it('resolves every registry color to the runtime theme value', () => { @@ -95,6 +95,7 @@ const colorAliases: Array<[string, string]> = [ ['--button-primary', '--surface-inverted'], ['--button-primary-hover', '--surface-inverted-hover'], ['--dialog-title', '--text-primary'], + ['--badge-label', '--text-primary'], ['--border-field-focus', '--focus-control'], ]; diff --git a/packages/client/src/theme/registry.spec.ts b/packages/client/src/theme/registry.spec.ts index 9762241dab..4132a22c49 100644 --- a/packages/client/src/theme/registry.spec.ts +++ b/packages/client/src/theme/registry.spec.ts @@ -762,6 +762,29 @@ describe('theme registry', () => { ); }); + it('keeps badge labels on the primary ink of a theme that predates the role', () => { + const light = resolveTheme( + { + version: 1, + name: 'ink-reference', + modes: { light: { colors: { 'rgb-text-primary': '10 20 30' } } }, + }, + 'light', + ); + const own = resolveTheme( + { + version: 1, + name: 'badge-ink-reference', + modes: { light: { colors: { 'rgb-badge-label': '200 30 90' } } }, + }, + 'light', + ); + + expect(light.colors['rgb-badge-label']).toBe('10 20 30'); + expect(own.colors['rgb-badge-label']).toBe('200 30 90'); + expect(own.colors['rgb-text-primary']).toBe(defaultTheme['rgb-text-primary']); + }); + it('keeps LibreChat’s dialog chrome by default', () => { expect(defaultAppearance).toMatchObject({ dialogStroke: '0px', diff --git a/packages/client/src/theme/registry.ts b/packages/client/src/theme/registry.ts index 8614a5910f..d7875ca8ec 100644 --- a/packages/client/src/theme/registry.ts +++ b/packages/client/src/theme/registry.ts @@ -118,10 +118,23 @@ export function primaryButtonFallbacks(colors: IThemeRGB): IThemeRGB { }; } -/** Dialog titles were set in the primary ink, so a theme that repaints it keeps its titles on it. */ -export function dialogTitleFallback(colors: IThemeRGB): IThemeRGB { - const title = colors['rgb-dialog-title'] ?? colors['rgb-text-primary']; - return title !== undefined ? { 'rgb-dialog-title': title } : {}; +/** Inks split out of the primary one: dialog titles, badge labels and the default avatar's glyph + * were all set in it. */ +export const primaryInkRoles: ReadonlyArray = [ + 'rgb-dialog-title', + 'rgb-badge-label', + 'rgb-avatar-text', +]; + +/** A theme that repaints the primary ink keeps the inks split out of it on it, unless it names them. */ +export function primaryInkFallbacks(colors: IThemeRGB): IThemeRGB { + const primary = colors['rgb-text-primary']; + return Object.fromEntries( + primaryInkRoles.flatMap((role) => { + const ink = colors[role] ?? primary; + return ink === undefined ? [] : [[role, ink]]; + }), + ); } /** @@ -518,12 +531,6 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT customColors?.['rgb-avatar-placeholder'] === undefined && avatarPlaceholderSource !== undefined ? { 'rgb-avatar-placeholder': avatarPlaceholderSource } : {}; - /** The default avatar's glyph inked in `text-primary` before it had a role. */ - const avatarTextFallback = - customColors?.['rgb-avatar-text'] === undefined && - customColors?.['rgb-text-primary'] !== undefined - ? { 'rgb-avatar-text': customColors['rgb-text-primary'] } - : {}; const chartWidgetSurfaceFallback = customColors?.['rgb-chart-widget-surface'] === undefined && customColors?.['rgb-surface-primary'] !== undefined @@ -562,7 +569,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT const focusFallback = customColors != null ? focusFallbacks(customColors) : {}; const pressedFallback = customColors != null ? pressedFallbacks(customColors) : {}; const primaryButtonFallback = customColors != null ? primaryButtonFallbacks(customColors) : {}; - const dialogTitleColor = customColors != null ? dialogTitleFallback(customColors) : {}; + const primaryInks = customColors != null ? primaryInkFallbacks(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 @@ -622,7 +629,6 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT ...textMutedFallback, ...proseLinkFallback, ...avatarPlaceholderFallback, - ...avatarTextFallback, ...chartWidgetSurfaceFallback, ...chartWidgetStrokeFallback, ...switchThumbFallback, @@ -632,7 +638,7 @@ export function resolveTheme(theme: ThemeDefinition, mode: ThemeMode): ResolvedT ...focusFallback, ...pressedFallback, ...primaryButtonFallback, - ...dialogTitleColor, + ...primaryInks, ...seriesEightFallback, ...verifiedFallback, } as Required, diff --git a/packages/client/src/theme/semanticTokens.spec.ts b/packages/client/src/theme/semanticTokens.spec.ts index 6a023a603a..f3eaf4c2c0 100644 --- a/packages/client/src/theme/semanticTokens.spec.ts +++ b/packages/client/src/theme/semanticTokens.spec.ts @@ -788,8 +788,29 @@ describe('state role defaults', () => { ['default dark', darkTheme], ['high contrast light', highContrastLightTheme], ['high contrast dark', highContrastDarkTheme], - ])('sets %s dialog titles in the primary ink', (_name, theme: IThemeRGB) => { + ])('sets %s dialog titles and badge labels in the primary ink', (_name, theme: IThemeRGB) => { expect(theme['rgb-dialog-title']).toBe(theme['rgb-text-primary']); + expect(theme['rgb-badge-label']).toBe(theme['rgb-text-primary']); + }); + + it.each([ + ['default light', defaultTheme], + ['default dark', darkTheme], + ['high contrast light', highContrastLightTheme], + ['high contrast dark', highContrastDarkTheme], + ['clickhouse light', clickHouseLightTheme], + ['clickhouse dark', clickHouseDarkTheme], + ])('keeps %s badge labels at AA on the resting badge fill', (_name, theme: IThemeRGB) => { + const ink = toRgb(theme, 'rgb-badge-label'); + /** A hovered or selected badge is labeled in the primary ink, so only the resting fill counts. */ + const fills: Array = ['rgb-surface-chat']; + + const failures = fills.flatMap((fill) => { + const ratio = contrast(ink, toRgb(theme, fill)); + return ratio < 4.5 ? [`${fill}: ${ratio.toFixed(2)}:1`] : []; + }); + + expect(failures).toEqual([]); }); it.each([ diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts index a91486878b..23b31c7b75 100644 --- a/packages/client/src/theme/themes/clickhouse.ts +++ b/packages/client/src/theme/themes/clickhouse.ts @@ -36,6 +36,7 @@ export const clickHouseLightTheme: IThemeRGB = { 'rgb-text-secondary-alt': '83 87 95', // #53575f (palette.slate.700) 'rgb-text-tertiary': '83 87 95', // #53575f (palette.slate.700) 'rgb-text-muted': '105 110 121', // #696e79 (text.muted) + 'rgb-badge-label': '105 110 121', // #696e79 (badge.opaque.color.text.default) 'rgb-text-warning': '163 60 0', // #a33c00 (text.warning) 'rgb-text-destructive': '193 0 0', // #c10000 (text.danger) 'rgb-shimmer-base': '22 21 23', // #161517 (text.default, matching text-primary) @@ -178,6 +179,7 @@ export const clickHouseDarkTheme: IThemeRGB = { 'rgb-text-secondary-alt': '179 182 189', // #b3b6bd (text.muted) 'rgb-text-tertiary': '179 182 189', // #b3b6bd (text.muted) 'rgb-text-muted': '179 182 189', // #b3b6bd (text.muted) + 'rgb-badge-label': '179 182 189', // #b3b6bd (badge.opaque.color.text.default) 'rgb-text-warning': '255 184 143', // #ffb88f (text.warning) 'rgb-text-destructive': '255 186 186', // #ffbaba (text.danger) 'rgb-shimmer-base': '255 255 255', // #ffffff (text.default, matching text-primary) diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts index 0e87691c38..e262e2988f 100644 --- a/packages/client/src/theme/themes/clickui.spec.ts +++ b/packages/client/src/theme/themes/clickui.spec.ts @@ -92,6 +92,7 @@ const colorSources: Record>> 'rgb-surface-tertiary-alt': 'global.color.background.default', 'rgb-surface-dialog': 'global.color.background.default', 'rgb-dialog-title': 'click.dialog.color.title.default', + 'rgb-badge-label': 'click.badge.opaque.color.text.default', 'rgb-surface-overlay': 'click.dialog.color.opaqueBackground.default', 'rgb-surface-submit': 'global.color.accent.default', 'rgb-surface-submit-hover': 'palette.neutral.712', @@ -207,6 +208,7 @@ const colorSources: Record>> 'rgb-surface-tertiary-alt': 'palette.neutral.712', 'rgb-surface-dialog': 'global.color.background.default', 'rgb-dialog-title': 'click.dialog.color.title.default', + 'rgb-badge-label': 'click.badge.opaque.color.text.default', 'rgb-surface-submit': 'global.color.accent.default', 'rgb-surface-submit-hover': 'palette.brand.200', 'rgb-surface-destructive': 'palette.danger.300', @@ -1127,12 +1129,7 @@ const notExpressible: Record = { 'the field is transparent and inks with text-primary; a color role is an opaque triplet, so no role can default to no fill, and no role holds field ink apart from body copy', issue: 'https://github.com/berry-13/LibreChat/issues/206', }, - 'Badge label': { - decisions: { light: ['Badge label'], dark: ['Badge label'] }, - reason: - 'Badge inks with text-primary; Click UI labels badges in text.muted, and no role holds badge ink apart from body copy', - issue: 'https://github.com/berry-13/LibreChat/issues/143', - }, + 'Dropdown menu corner': { decisions: { light: ['Dropdown menu corner'], dark: ['Dropdown menu corner'] }, reason: diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts index 888a581358..950fd5c328 100644 --- a/packages/client/src/theme/themes/dark.ts +++ b/packages/client/src/theme/themes/dark.ts @@ -11,6 +11,7 @@ export const darkTheme: IThemeRGB = { 'rgb-text-secondary-alt': '153 150 150', // #999696 (gray-400) 'rgb-text-tertiary': '153 150 150', // #999696 (gray-400) 'rgb-text-muted': '179 182 189', // #b3b6bd (Click UI text.muted) + 'rgb-badge-label': '236 236 236', // #ececec (gray-100, matching text-primary) 'rgb-text-warning': '245 158 11', // #f59e0b (amber-500) 'rgb-text-destructive': '248 113 113', // #f87171 (red-400) 'rgb-shimmer-base': '255 255 255', // #ffffff, carried at 0.8 alpha diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts index c6ff6f12b6..870b1a6475 100644 --- a/packages/client/src/theme/themes/default.ts +++ b/packages/client/src/theme/themes/default.ts @@ -11,6 +11,7 @@ export const defaultTheme: IThemeRGB = { 'rgb-text-secondary-alt': '89 89 89', // #595959 (gray-500) 'rgb-text-tertiary': '89 89 89', // #595959 (gray-500) 'rgb-text-muted': '105 110 121', // #696e79 (Click UI text.muted) + 'rgb-badge-label': '33 33 33', // #212121 (gray-800, matching text-primary) 'rgb-text-warning': '180 83 9', // #b45309 (amber-700) 'rgb-text-destructive': '220 38 38', // #dc2626 (red-600) 'rgb-shimmer-base': '33 33 33', // #212121 (gray-800), matching text-primary diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts index a0dda4e597..e78734e4a1 100644 --- a/packages/client/src/theme/themes/highContrast.ts +++ b/packages/client/src/theme/themes/highContrast.ts @@ -37,6 +37,7 @@ export const highContrastLightTheme: IThemeRGB = { 'rgb-text-secondary-alt': '0 0 0', // #000000 'rgb-text-tertiary': '0 0 0', // #000000 'rgb-text-muted': '0 0 0', // #000000 + 'rgb-badge-label': '0 0 0', // #000000 (matching text-primary) 'rgb-text-warning': '122 61 0', // #7a3d00 'rgb-text-destructive': '161 0 0', // #a10000 'rgb-shimmer-base': '0 0 0', // #000000, 21:1 on white @@ -202,6 +203,7 @@ export const highContrastDarkTheme: IThemeRGB = { 'rgb-text-secondary-alt': '255 255 255', // #ffffff 'rgb-text-tertiary': '255 255 255', // #ffffff 'rgb-text-muted': '255 255 255', // #ffffff + 'rgb-badge-label': '255 255 255', // #ffffff (matching text-primary) 'rgb-text-warning': '255 201 77', // #ffc94d 'rgb-text-destructive': '255 143 143', // #ff8f8f 'rgb-shimmer-base': '255 255 255', // #ffffff, 21:1 on black diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css index 87caa4f7ab..a89fbd434d 100644 --- a/packages/client/src/theme/tokens.css +++ b/packages/client/src/theme/tokens.css @@ -81,6 +81,8 @@ --color-text-secondary-alt: rgb(var(--text-secondary-alt)); --color-text-tertiary: rgb(var(--text-tertiary)); --color-text-muted: rgb(var(--text-muted)); + /* Falls back to the ink badges were labeled in, for a stylesheet that predates it. */ + --color-badge-label: rgb(var(--badge-label, var(--text-primary))); --color-text-warning: rgb(var(--text-warning)); --color-text-destructive: rgb(var(--text-destructive)); --color-text-inverted: rgb(var(--text-inverted)); diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts index eaa58eb75c..7324181a75 100644 --- a/packages/client/src/theme/types/index.ts +++ b/packages/client/src/theme/types/index.ts @@ -9,6 +9,8 @@ export interface IThemeRGB { 'rgb-text-secondary-alt'?: string; 'rgb-text-tertiary'?: string; 'rgb-text-muted'?: string; + /** The shared Badge's label ink; follows `rgb-text-primary` when a theme omits it. */ + 'rgb-badge-label'?: string; 'rgb-text-warning'?: string; 'rgb-text-destructive'?: string; /** Bright and dipped stops of the in-flight label sweep (`.shimmer`). Their @@ -199,6 +201,7 @@ export interface IThemeVariables { '--text-secondary-alt': string; '--text-tertiary': string; '--text-muted': string; + '--badge-label': string; '--text-warning': string; '--text-destructive': string; '--shimmer-base': string; @@ -326,6 +329,7 @@ export interface IThemeColors { 'text-secondary-alt'?: string; 'text-tertiary'?: string; 'text-muted'?: string; + 'badge-label'?: string; 'text-warning'?: string; 'text-destructive'?: string; link?: string; diff --git a/packages/client/src/theme/utils/applyTheme.spec.ts b/packages/client/src/theme/utils/applyTheme.spec.ts index 1a3cf3f970..f838a500ae 100644 --- a/packages/client/src/theme/utils/applyTheme.spec.ts +++ b/packages/client/src/theme/utils/applyTheme.spec.ts @@ -359,6 +359,7 @@ describe('applyTheme', () => { applyTheme({ 'rgb-text-primary': '30 31 32' }, root, defaultTheme); expect(root.style.getPropertyValue('--dialog-title')).toBe('30 31 32'); + expect(root.style.getPropertyValue('--badge-label')).toBe('30 31 32'); }); it('fills the primary button with the inverted surface of a theme that predates the role', () => { diff --git a/packages/client/src/theme/utils/applyTheme.ts b/packages/client/src/theme/utils/applyTheme.ts index 974a00839f..dc8b562cc2 100644 --- a/packages/client/src/theme/utils/applyTheme.ts +++ b/packages/client/src/theme/utils/applyTheme.ts @@ -4,7 +4,8 @@ import { focusFallbacks, pressedFallbacks, primaryButtonFallbacks, - dialogTitleFallback, + primaryInkFallbacks, + primaryInkRoles, MARK_NEIGHBOURHOOD, themeAppearanceProperties, themeBrandTokens, @@ -64,10 +65,6 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]> variables.push(['--text-muted', colors['rgb-text-tertiary']]); } - if (colors['rgb-avatar-text'] === undefined && colors['rgb-text-primary'] !== undefined) { - variables.push(['--avatar-text', colors['rgb-text-primary']]); - } - if ( colors['rgb-chart-widget-surface'] === undefined && colors['rgb-surface-primary'] !== undefined @@ -133,10 +130,13 @@ function mapColors(colors: IThemeRGB, base?: IThemeRGB): Array<[string, string]> variables.push(['--button-primary-hover', primary['rgb-button-primary-hover']]); } - const title = dialogTitleFallback(colors)['rgb-dialog-title']; - if (colors['rgb-dialog-title'] === undefined && title !== undefined) { - variables.push(['--dialog-title', title]); - } + const inks = primaryInkFallbacks(colors); + primaryInkRoles.forEach((role) => { + const ink = inks[role]; + if (colors[role] === undefined && ink !== undefined) { + variables.push([`--${role.slice(4)}`, ink]); + } + }); /** * Same rule as `resolveTheme`: a theme that paints what the mark is measured diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts index 7edac1cb3a..7ed20c48ab 100644 --- a/packages/data-provider/src/theme.ts +++ b/packages/data-provider/src/theme.ts @@ -19,6 +19,7 @@ export const themeColorTokens = Object.freeze([ 'rgb-text-secondary-alt', 'rgb-text-tertiary', 'rgb-text-muted', + 'rgb-badge-label', 'rgb-text-warning', 'rgb-text-destructive', 'rgb-shimmer-base',