mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 13:33:45 +00:00
🏷️ feat: Give the Badge Label Its Own Ink and Let the Legacy Dialog Spinner Inherit (#16554)
* 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
This commit is contained in:
parent
02a70e9c58
commit
ef1aa66812
21 changed files with 241 additions and 37 deletions
85
e2e/specs/mock/scenarios/badge-label.spec.ts
Normal file
85
e2e/specs/mock/scenarios/badge-label.spec.ts
Normal file
|
|
@ -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<Mode>;
|
||||
|
||||
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)');
|
||||
});
|
||||
});
|
||||
|
|
@ -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(<Badge label="Tools" isAvailable={true} />);
|
||||
expect(screen.getByRole('button', { name: 'Tools' })).toHaveClass(
|
||||
'text-badge-label',
|
||||
'hover:text-text-primary',
|
||||
);
|
||||
|
||||
rerender(<Badge label="Tools" isAvailable={true} isActive />);
|
||||
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(<Badge id="1" label="Tools" isAvailable={true} isInChat />);
|
||||
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(<Badge id="1" label="Tools" isAvailable={true} isInChat isActive />);
|
||||
const badge = screen.getByRole('button', { name: 'Tools' });
|
||||
|
||||
expect(badge).toHaveClass('text-text-primary');
|
||||
expect(badge).not.toHaveClass('hover:text-badge-label');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<OGDialog open={true}>
|
||||
<OGDialogTemplate
|
||||
title="Delete"
|
||||
selection={{ selectHandler: jest.fn(), selectText: 'Delete', isLoading: true }}
|
||||
/>
|
||||
</OGDialog>,
|
||||
);
|
||||
|
||||
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'));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 ? (
|
||||
<Spinner className="text-text-primary size-4" />
|
||||
) : (
|
||||
(selectText as React.JSX.Element)
|
||||
)}
|
||||
{isLoading === true ? <Spinner className="size-4" /> : (selectText as React.JSX.Element)}
|
||||
</OGDialogClose>
|
||||
);
|
||||
} else if (selection) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ describe.each([
|
|||
const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
|
||||
|
||||
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'],
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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<keyof IThemeRGB> = [
|
||||
'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<IThemeRGB>,
|
||||
|
|
|
|||
|
|
@ -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<keyof IThemeRGB> = ['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([
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
|
|||
'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<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
|
|||
'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<string, NotExpressible> = {
|
|||
'the field is transparent and inks with text-primary; a color role is an opaque triplet, so no role can default to no fill, and no role holds field ink apart from body copy',
|
||||
issue: 'https://github.com/berry-13/LibreChat/issues/206',
|
||||
},
|
||||
'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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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', () => {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue