From d9fdfddce98304453f97b5ffecafebb405e3eb2c Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Thu, 1 Oct 2026 17:44:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=82=EF=B8=8F=20feat:=20Give=20File-Typ?= =?UTF-8?q?e=20Tiles=20Their=20Own=20Theme=20Roles=20(#16603)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Give File-Type Tiles Their Own Theme Roles The file chips in the composer, the file table and message attachments drew their tile in one of seven hard-coded hex fills from utils/files.ts and their glyph in raw white, so a theme could recolour neither. Each kind of file now has a file-* fill role and the glyph reads file-ink; every LibreChat theme keeps today's colours, and ClickHouse draws the tiles from Click UI palette steps that keep the white glyph legible. The tile fill travels as a fill utility, the way the trace kinds already pass theirs. * test: Pin the File Tile Roles in the Composer Tray * test: Attach File Tile Captures to the Report * fix: Keep FileIcon's Colour Fill and Take the Role Through fillClassName * fix: Hold High Contrast File Tiles to AA Against Their Glyph * fix: Ink the File Upload Spinner With the Tile Glyph Role --- .../Chat/Input/Files/FilePreview.tsx | 12 +-- client/src/utils/files.ts | 16 +-- .../mock/scenarios/file-tile-theme.spec.ts | 99 +++++++++++++++++++ eslint-suppressions.json | 30 ------ packages/client/src/svgs/AudioPaths.tsx | 10 +- packages/client/src/svgs/CodePaths.tsx | 4 +- packages/client/src/svgs/FileIcon.spec.tsx | 24 +++++ packages/client/src/svgs/FileIcon.tsx | 7 +- packages/client/src/svgs/FilePaths.tsx | 4 +- packages/client/src/svgs/SheetPaths.tsx | 2 +- packages/client/src/svgs/TextPaths.tsx | 10 +- packages/client/src/svgs/VideoPaths.tsx | 13 ++- packages/client/src/theme/README.md | 1 + packages/client/src/theme/allowlist.md | 2 +- packages/client/src/theme/defaults.css | 16 +++ packages/client/src/theme/defaults.spec.ts | 2 +- .../client/src/theme/themes/clickhouse.ts | 16 +++ packages/client/src/theme/themes/clickui.json | 9 ++ .../client/src/theme/themes/clickui.spec.ts | 16 +++ packages/client/src/theme/themes/dark.ts | 8 ++ packages/client/src/theme/themes/default.ts | 8 ++ .../src/theme/themes/highContrast.spec.ts | 18 ++++ .../client/src/theme/themes/highContrast.ts | 18 ++++ packages/client/src/theme/tokens.css | 8 ++ packages/client/src/theme/types/index.ts | 25 +++++ packages/data-provider/src/theme.ts | 8 ++ 26 files changed, 321 insertions(+), 65 deletions(-) create mode 100644 e2e/specs/mock/scenarios/file-tile-theme.spec.ts create mode 100644 packages/client/src/svgs/FileIcon.spec.tsx diff --git a/client/src/components/Chat/Input/Files/FilePreview.tsx b/client/src/components/Chat/Input/Files/FilePreview.tsx index ec9c26a77b..b33a8415b9 100644 --- a/client/src/components/Chat/Input/Files/FilePreview.tsx +++ b/client/src/components/Chat/Input/Files/FilePreview.tsx @@ -12,7 +12,7 @@ const FilePreview = ({ file?: Partial; fileType: { paths: React.FC; - fill: string; + fillClassName: string; title: string; }; className?: string; @@ -22,11 +22,11 @@ const FilePreview = ({ {typeof file?.['progress'] === 'number' && file?.['progress'] < 1 && ( - + /* The spinner strokes in currentColor, so it takes the glyph's ink: white on the stock + * tiles, black on the light high-contrast dark tiles. */ + + + )} ); diff --git a/client/src/utils/files.ts b/client/src/utils/files.ts index 08ca380094..4d4488dca4 100644 --- a/client/src/utils/files.ts +++ b/client/src/utils/files.ts @@ -87,38 +87,38 @@ export function hasIncompleteFiles(files: Map): boolean { const textDocument = { paths: TextPaths, - fill: '#FF5588', + fillClassName: 'fill-file-document', title: 'Document', }; const spreadsheet = { paths: SheetPaths, - fill: '#10A37F', + fillClassName: 'fill-file-sheet', title: 'Spreadsheet', }; const codeFile = { paths: CodePaths, - fill: '#FF6E3C', + fillClassName: 'fill-file-code', // TODO: make this dynamic to the language title: 'Code', }; const artifact = { paths: CodePaths, - fill: '#2D305C', + fillClassName: 'fill-file-artifact', title: 'Code', }; const audioFile = { paths: AudioPaths, - fill: '#FF6B35', + fillClassName: 'fill-file-audio', title: 'Audio', }; const videoFile = { paths: VideoPaths, - fill: '#8B5CF6', + fillClassName: 'fill-file-video', title: 'Video', }; @@ -126,7 +126,7 @@ export const fileTypes = { /* Category matches */ file: { paths: FilePaths, - fill: '#0000FF', + fillClassName: 'fill-file-generic', title: 'File', }, text: textDocument, @@ -174,7 +174,7 @@ export const getFileType = ( type = '', ): { paths: React.FC; - fill: string; + fillClassName: string; title: string; } => { // Direct match check diff --git a/e2e/specs/mock/scenarios/file-tile-theme.spec.ts b/e2e/specs/mock/scenarios/file-tile-theme.spec.ts new file mode 100644 index 0000000000..dd0832fd29 --- /dev/null +++ b/e2e/specs/mock/scenarios/file-tile-theme.spec.ts @@ -0,0 +1,99 @@ +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, uniqueName, uploadViaUnifiedButton } from '../helpers'; + +/** + * A file chip's tile reads its kind's `file-*` role and its glyph `file-ink`. Without a theme a + * text document keeps the pink tile and white glyph it always had; the ClickHouse definition + * draws the tile from Click UI's palette. + */ + +type Mode = 'light' | 'dark'; + +const MODES: Mode[] = ['light', 'dark']; +const THEME_PARAM = 'e2eThemeMode'; + +test.use({ viewport: { width: 1280, height: 800 } }); + +async function installThemeBridge(page: Page, definition: unknown) { + await page.addInitScript((stored) => { + const mode = new URL(location.href).searchParams.get('e2eThemeMode'); + if (mode) { + localStorage.setItem('color-theme', mode); + } + 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'); + } + }, definition ?? null); +} + +const rgbCss = (triplet: string | undefined) => `rgb(${(triplet ?? '').split(' ').join(', ')})`; + +/** Attaches a text file and reads its chip's tile fill and glyph stroke. */ +async function tilePaint(page: Page, mode: Mode, theme: string) { + await page.goto(`${NEW_CHAT_PATH}?${THEME_PARAM}=${mode}`); + await expect(page.getByRole('textbox', { name: 'Message input' })).toBeVisible({ + timeout: 20000, + }); + const name = `${uniqueName('tile')}.txt`; + const upload = await uploadViaUnifiedButton(page, { + name, + mimeType: 'text/plain', + content: 'A short note.', + }); + expect(upload.ok()).toBeTruthy(); + + const tray = page.getByTestId('composer-tray'); + const tile = tray.locator('svg rect[width="36"][height="36"]').first(); + await expect(tile).toBeVisible({ timeout: 20000 }); + const glyph = tray.locator('svg path[stroke-width], svg path.stroke-file-ink').first(); + await expect(glyph).toBeVisible(); + await test.info().attach(`file-tile-${theme}-${mode}`, { + body: await tray.screenshot(), + contentType: 'image/png', + }); + return { + fill: await tile.evaluate((node) => getComputedStyle(node).fill), + ink: await glyph.evaluate((node) => getComputedStyle(node).stroke), + }; +} + +test.describe('file-type tile roles', () => { + test('a text file keeps its pink tile and white glyph without a theme @scenario:file-tile-keeps-its-colours', async ({ + page, + }) => { + test.setTimeout(90000); + await installThemeBridge(page, null); + + for (const mode of MODES) { + expect(await tilePaint(page, mode, 'default')).toEqual({ + fill: 'rgb(255, 85, 136)', + ink: 'rgb(255, 255, 255)', + }); + } + }); + + test('the ClickHouse definition draws the tile from Click UI @scenario:clickhouse-file-tile-follows-click-ui', async ({ + page, + }) => { + test.setTimeout(90000); + await installThemeBridge(page, clickHouseTheme); + + for (const mode of MODES) { + const colors = clickHouseTheme.modes[mode]?.colors ?? {}; + const paint = await tilePaint(page, mode, 'clickhouse'); + await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse'); + expect(paint).toEqual({ + fill: rgbCss(colors['rgb-file-document']), + ink: rgbCss(colors['rgb-file-ink']), + }); + } + }); +}); diff --git a/eslint-suppressions.json b/eslint-suppressions.json index 3c31bf15f3..07cbcd1899 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -2224,21 +2224,11 @@ "count": 2 } }, - "packages/client/src/svgs/AudioPaths.tsx": { - "shadcn/no-raw-colors": { - "count": 5 - } - }, "packages/client/src/svgs/BirthdayIcon.tsx": { "shadcn/no-raw-colors": { "count": 10 } }, - "packages/client/src/svgs/CodePaths.tsx": { - "shadcn/no-raw-colors": { - "count": 2 - } - }, "packages/client/src/svgs/DiscordIcon.tsx": { "shadcn/no-raw-colors": { "count": 2 @@ -2249,11 +2239,6 @@ "count": 3 } }, - "packages/client/src/svgs/FilePaths.tsx": { - "shadcn/no-raw-colors": { - "count": 2 - } - }, "packages/client/src/svgs/GeminiIcon.tsx": { "shadcn/no-raw-colors": { "count": 2 @@ -2273,20 +2258,5 @@ "shadcn/no-inline-styles": { "count": 1 } - }, - "packages/client/src/svgs/SheetPaths.tsx": { - "shadcn/no-raw-colors": { - "count": 1 - } - }, - "packages/client/src/svgs/TextPaths.tsx": { - "shadcn/no-raw-colors": { - "count": 5 - } - }, - "packages/client/src/svgs/VideoPaths.tsx": { - "shadcn/no-raw-colors": { - "count": 2 - } } } diff --git a/packages/client/src/svgs/AudioPaths.tsx b/packages/client/src/svgs/AudioPaths.tsx index 51d2569efc..257ff12b5f 100644 --- a/packages/client/src/svgs/AudioPaths.tsx +++ b/packages/client/src/svgs/AudioPaths.tsx @@ -5,35 +5,35 @@ export default function AudioPaths(): JSX.Element { <> ; + +const tile = (container: HTMLElement) => container.querySelector('rect'); + +describe('FileIcon', () => { + it('paints the tile with a theme role through fillClassName', () => { + const { container } = render( + , + ); + expect(tile(container)?.getAttribute('class')).toBe('fill-file-document'); + expect(tile(container)?.hasAttribute('fill')).toBe(false); + }); + + it('keeps a colour passed as fill, as callers did before the roles', () => { + const { container } = render( + , + ); + expect(tile(container)?.getAttribute('fill')).toBe('#FF5588'); + expect(tile(container)?.hasAttribute('class')).toBe(false); + }); +}); diff --git a/packages/client/src/svgs/FileIcon.tsx b/packages/client/src/svgs/FileIcon.tsx index 1daafe401f..5e3935d7e3 100644 --- a/packages/client/src/svgs/FileIcon.tsx +++ b/packages/client/src/svgs/FileIcon.tsx @@ -7,7 +7,10 @@ export default function FileIcon({ }: { file?: Partial & { progress?: number }; fileType: { - fill: string; + /** A CSS colour for the tile; `fillClassName` takes precedence when both are set. */ + fill?: string; + /** The tile's fill utility, such as `fill-file-document`, so a theme role paints it. */ + fillClassName?: string; paths: React.FC; title: string; }; @@ -22,7 +25,7 @@ export default function FileIcon({ height="36" aria-hidden="true" > - + {(file?.['progress'] ?? 1) >= 1 && <>{}} ); diff --git a/packages/client/src/svgs/FilePaths.tsx b/packages/client/src/svgs/FilePaths.tsx index 94de953a58..7712ee6b04 100644 --- a/packages/client/src/svgs/FilePaths.tsx +++ b/packages/client/src/svgs/FilePaths.tsx @@ -5,14 +5,14 @@ export default function FilePaths(): JSX.Element { <> {/* Video container - rounded rectangle (not filled) */} - + {/* Play button - centered and pointing right */} - + ); } diff --git a/packages/client/src/theme/README.md b/packages/client/src/theme/README.md index 130948ac3f..c3112de94e 100644 --- a/packages/client/src/theme/README.md +++ b/packages/client/src/theme/README.md @@ -301,6 +301,7 @@ function MyComponent() { - `bg-surface-code` - Code block chrome: toolbar, output and result switcher - `bg-surface-code-body` - Code block pane behind the highlighted code - `fill-illustration-subtle`, `fill-illustration`, `fill-illustration-strong` - The three tones of in-app artwork, such as the file drop zone's illustration +- `fill-file-document`, `fill-file-sheet`, `fill-file-code`, `fill-file-artifact`, `fill-file-audio`, `fill-file-video`, `fill-file-generic` - File-type tile fills; `stroke-file-ink` and `fill-file-ink` draw the glyph on them - `bg-surface-qr` - Backdrop behind a QR code, kept light in every mode so it scans ### Border Colors diff --git a/packages/client/src/theme/allowlist.md b/packages/client/src/theme/allowlist.md index 3386a775a8..28b253e016 100644 --- a/packages/client/src/theme/allowlist.md +++ b/packages/client/src/theme/allowlist.md @@ -1,6 +1,6 @@ # Colours outside the theme -Every colour in `client/src` and `packages/client/src` comes from a semantic theme role, except the entries below. Each entry is one kind of colour that must not follow the theme, with the files that hold it and why the theme does not own it. Scrims, chips and progress drawn over the user's own media are not exceptions: they read `surface-media-overlay` and `text-on-media`, which every bundled theme keeps black and white. The drop zone's artwork reads the `illustration` roles, the default avatar's hairline `avatar-edge`, and a dragged badge's lift `elevationDrag`. +Every colour in `client/src` and `packages/client/src` comes from a semantic theme role, except the entries below. Each entry is one kind of colour that must not follow the theme, with the files that hold it and why the theme does not own it. Scrims, chips and progress drawn over the user's own media are not exceptions: they read `surface-media-overlay` and `text-on-media`, which every bundled theme keeps black and white. The drop zone's artwork reads the `illustration` roles, file-type tiles the `file-*` roles, the default avatar's hairline `avatar-edge`, and a dragged badge's lift `elevationDrag`. Files an open pull request was editing when this list was last swept, with their counts, are listed in berry-13/LibreChat#195. Until those land, a file absent from this list is not evidence that it holds no literal colour. diff --git a/packages/client/src/theme/defaults.css b/packages/client/src/theme/defaults.css index 57170cd16c..7c64438df0 100644 --- a/packages/client/src/theme/defaults.css +++ b/packages/client/src/theme/defaults.css @@ -83,6 +83,14 @@ html { --illustration-subtle: 175 193 255; --illustration: 121 137 255; --illustration-strong: 60 70 255; + --file-document: 255 85 136; + --file-sheet: 16 163 127; + --file-code: 255 110 60; + --file-artifact: 45 48 92; + --file-audio: 255 107 53; + --file-video: 139 92 246; + --file-generic: 0 0 255; + --file-ink: 255 255 255; --presentation: var(--white); --text-primary: var(--gray-800); --text-secondary: var(--gray-600); @@ -307,6 +315,14 @@ html { --illustration-subtle: 175 193 255; --illustration: 121 137 255; --illustration-strong: 60 70 255; + --file-document: 255 85 136; + --file-sheet: 16 163 127; + --file-code: 255 110 60; + --file-artifact: 45 48 92; + --file-audio: 255 107 53; + --file-video: 139 92 246; + --file-generic: 0 0 255; + --file-ink: 255 255 255; --presentation: var(--gray-800); --text-primary: var(--gray-100); --focus-outline: 255 255 255; diff --git a/packages/client/src/theme/defaults.spec.ts b/packages/client/src/theme/defaults.spec.ts index 427bd7d835..f9fcbdd02f 100644 --- a/packages/client/src/theme/defaults.spec.ts +++ b/packages/client/src/theme/defaults.spec.ts @@ -68,7 +68,7 @@ describe.each([ const tokens = Object.keys(theme) as Array; it('covers every registry color', () => { - expect(tokens).toHaveLength(120); + expect(tokens).toHaveLength(128); }); it('resolves every registry color to the runtime theme value', () => { diff --git a/packages/client/src/theme/themes/clickhouse.ts b/packages/client/src/theme/themes/clickhouse.ts index 77d7219efc..38c9155329 100644 --- a/packages/client/src/theme/themes/clickhouse.ts +++ b/packages/client/src/theme/themes/clickhouse.ts @@ -145,6 +145,14 @@ export const clickHouseLightTheme: IThemeRGB = { 'rgb-illustration-subtle': '161 190 247', // #a1bef7 (palette.info.200) 'rgb-illustration': '67 126 239', // #437eef (palette.info.400) 'rgb-illustration-strong': '16 78 198', // #104ec6 (palette.info.600) + 'rgb-file-document': '204 0 153', // #cc0099 (palette.fuchsia.600) + 'rgb-file-sheet': '0 138 11', // #008a0b (palette.success.700) + 'rgb-file-code': '214 79 0', // #d64f00 (palette.warning.600) + 'rgb-file-artifact': '48 46 50', // #302e32 (palette.slate.800) + 'rgb-file-audio': '138 105 0', // #8a6900 (palette.sunrise.700) + 'rgb-file-video': '136 0 204', // #8800cc (palette.violet.600) + 'rgb-file-generic': '16 78 198', // #104ec6 (palette.info.600) + 'rgb-file-ink': '255 255 255', // #ffffff (palette.neutral.0) // Code syntax 'rgb-syntax-text': '40 40 40', // #282828 (codeblock.lightMode.color.text.default) @@ -296,6 +304,14 @@ export const clickHouseDarkTheme: IThemeRGB = { 'rgb-illustration-subtle': '161 190 247', // #a1bef7 (palette.info.200) 'rgb-illustration': '67 126 239', // #437eef (palette.info.400) 'rgb-illustration-strong': '16 78 198', // #104ec6 (palette.info.600) + 'rgb-file-document': '204 0 153', // #cc0099 (palette.fuchsia.600) + 'rgb-file-sheet': '0 138 11', // #008a0b (palette.success.700) + 'rgb-file-code': '214 79 0', // #d64f00 (palette.warning.600) + 'rgb-file-artifact': '48 46 50', // #302e32 (palette.slate.800) + 'rgb-file-audio': '138 105 0', // #8a6900 (palette.sunrise.700) + 'rgb-file-video': '136 0 204', // #8800cc (palette.violet.600) + 'rgb-file-generic': '16 78 198', // #104ec6 (palette.info.600) + 'rgb-file-ink': '255 255 255', // #ffffff (palette.neutral.0) // Code syntax 'rgb-syntax-text': '255 255 255', // #ffffff (codeblock.darkMode.color.text.default) diff --git a/packages/client/src/theme/themes/clickui.json b/packages/client/src/theme/themes/clickui.json index 592242a30f..bbe6731ebc 100644 --- a/packages/client/src/theme/themes/clickui.json +++ b/packages/client/src/theme/themes/clickui.json @@ -99,6 +99,7 @@ "palette.danger.200": "#ff9898", "palette.danger.600": "#c10000", "palette.danger.700": "#910000", + "palette.fuchsia.600": "#cc0099", "palette.fuchsia.700": "#990073", "palette.info.200": "#a1bef7", "palette.info.400": "#437eef", @@ -111,6 +112,7 @@ "palette.slate.200": "#cccfd3", "palette.slate.500": "#808691", "palette.slate.700": "#53575f", + "palette.slate.800": "#302e32", "palette.slate.900": "#161517", "palette.success.200": "#99ffa1", "palette.success.700": "#008a0b", @@ -120,6 +122,7 @@ "palette.violet.600": "#8800cc", "palette.warning.200": "#ffb88f", "palette.warning.500": "#f55a00", + "palette.warning.600": "#d64f00", "palette.warning.700": "#a33c00", "shadow.1": "0 4px 6px -1px lch(6.7738 0 none / 0.15), 0 2px 4px -1px lch(6.7738 0 none / 0.15)", "shadow.5": "0 2px 2px 0 rgba(0, 0, 0, 0.03)", @@ -230,6 +233,7 @@ "palette.danger.200": "#ff9898", "palette.danger.300": "#ff7575", "palette.danger.700": "#910000", + "palette.fuchsia.600": "#cc0099", "palette.info.200": "#a1bef7", "palette.info.300": "#6d9bf3", "palette.info.400": "#437eef", @@ -240,12 +244,17 @@ "palette.neutral.712": "#323232", "palette.slate.100": "#e6e7e9", "palette.slate.400": "#9a9ea7", + "palette.slate.800": "#302e32", "palette.slate.900": "#161517", "palette.success.300": "#66ff73", "palette.success.500": "#00e513", + "palette.success.700": "#008a0b", "palette.success.800": "#006108", + "palette.sunrise.700": "#8a6900", "palette.violet.300": "#cc66ff", + "palette.violet.600": "#8800cc", "palette.warning.300": "#ff9457", + "palette.warning.600": "#d64f00", "palette.warning.700": "#a33c00", "shadow.1": "0 4px 6px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6), 0 2px 4px -1px rgb(8.2353% 8.2353% 8.2353% / 0.6)", "shadow.5": "0 2px 2px 0 rgba(0, 0, 0, 0.03)", diff --git a/packages/client/src/theme/themes/clickui.spec.ts b/packages/client/src/theme/themes/clickui.spec.ts index fbab605d5f..1e94df675b 100644 --- a/packages/client/src/theme/themes/clickui.spec.ts +++ b/packages/client/src/theme/themes/clickui.spec.ts @@ -152,6 +152,14 @@ const colorSources: Record>> 'rgb-illustration-subtle': 'palette.info.200', 'rgb-illustration': 'palette.info.400', 'rgb-illustration-strong': 'palette.info.600', + 'rgb-file-document': 'palette.fuchsia.600', + 'rgb-file-sheet': 'palette.success.700', + 'rgb-file-code': 'palette.warning.600', + 'rgb-file-artifact': 'palette.slate.800', + 'rgb-file-audio': 'palette.sunrise.700', + 'rgb-file-video': 'palette.violet.600', + 'rgb-file-generic': 'palette.info.600', + 'rgb-file-ink': 'palette.neutral.0', 'rgb-syntax-text': 'click.codeblock.lightMode.color.text.default', 'rgb-syntax-comment': 'global.color.text.muted', 'rgb-syntax-meta': 'palette.slate.700', @@ -271,6 +279,14 @@ const colorSources: Record>> 'rgb-illustration-subtle': 'palette.info.200', 'rgb-illustration': 'palette.info.400', 'rgb-illustration-strong': 'palette.info.600', + 'rgb-file-document': 'palette.fuchsia.600', + 'rgb-file-sheet': 'palette.success.700', + 'rgb-file-code': 'palette.warning.600', + 'rgb-file-artifact': 'palette.slate.800', + 'rgb-file-audio': 'palette.sunrise.700', + 'rgb-file-video': 'palette.violet.600', + 'rgb-file-generic': 'palette.info.600', + 'rgb-file-ink': 'palette.neutral.0', 'rgb-syntax-text': 'click.codeblock.darkMode.color.text.default', 'rgb-syntax-comment': 'global.color.text.muted', 'rgb-syntax-meta': 'palette.slate.400', diff --git a/packages/client/src/theme/themes/dark.ts b/packages/client/src/theme/themes/dark.ts index b0a1be1dd6..6eedabd5ec 100644 --- a/packages/client/src/theme/themes/dark.ts +++ b/packages/client/src/theme/themes/dark.ts @@ -132,6 +132,14 @@ export const darkTheme: IThemeRGB = { 'rgb-illustration-subtle': '175 193 255', // #afc1ff 'rgb-illustration': '121 137 255', // #7989ff 'rgb-illustration-strong': '60 70 255', // #3c46ff + 'rgb-file-document': '255 85 136', // #ff5588 + 'rgb-file-sheet': '16 163 127', // #10a37f + 'rgb-file-code': '255 110 60', // #ff6e3c + 'rgb-file-artifact': '45 48 92', // #2d305c + 'rgb-file-audio': '255 107 53', // #ff6b35 + 'rgb-file-video': '139 92 246', // #8b5cf6 + 'rgb-file-generic': '0 0 255', // #0000ff + 'rgb-file-ink': '255 255 255', // #ffffff /** Code syntax highlighting, measured against the `surface-code` fill. The * comment and meta values are the flattened equivalents of the alpha-blended diff --git a/packages/client/src/theme/themes/default.ts b/packages/client/src/theme/themes/default.ts index ed4d60f3d0..9243f50eb4 100644 --- a/packages/client/src/theme/themes/default.ts +++ b/packages/client/src/theme/themes/default.ts @@ -122,6 +122,14 @@ export const defaultTheme: IThemeRGB = { 'rgb-illustration-subtle': '175 193 255', // #afc1ff 'rgb-illustration': '121 137 255', // #7989ff 'rgb-illustration-strong': '60 70 255', // #3c46ff + 'rgb-file-document': '255 85 136', // #ff5588 + 'rgb-file-sheet': '16 163 127', // #10a37f + 'rgb-file-code': '255 110 60', // #ff6e3c + 'rgb-file-artifact': '45 48 92', // #2d305c + 'rgb-file-audio': '255 107 53', // #ff6b35 + 'rgb-file-video': '139 92 246', // #8b5cf6 + 'rgb-file-generic': '0 0 255', // #0000ff + 'rgb-file-ink': '255 255 255', // #ffffff /** Code syntax highlighting, measured against the `surface-code` and `surface-code-body` fills. */ 'rgb-syntax-text': '33 33 33', // #212121 (gray-800) diff --git a/packages/client/src/theme/themes/highContrast.spec.ts b/packages/client/src/theme/themes/highContrast.spec.ts index 136166e459..f2a0c61875 100644 --- a/packages/client/src/theme/themes/highContrast.spec.ts +++ b/packages/client/src/theme/themes/highContrast.spec.ts @@ -29,6 +29,8 @@ function hexToRgb(value: string): Rgb { ]; } +/** WCAG 1.4.3 contrast, the floor the file-type tiles hold their glyph to. */ +const WCAG_AA_NORMAL = 4.5; /** WCAG 1.4.6 enhanced contrast, the reason these modes exist. */ const WCAG_AAA_NORMAL = 7; /** WCAG 1.4.11 non-text contrast, for borders, rings, marks and fills. */ @@ -274,6 +276,22 @@ describe.each([ expect(below(theme, WCAG_AAA_NORMAL, solidFills, ['rgb-surface-primary'])).toEqual([]); }); + /** File-type tiles carry a glyph in `file-ink`; the legacy hues let the spreadsheet tile fall + * to 2.95:1 under a white glyph, so each mode steps every hue to the far side of its ink. */ + it('keeps every file-type tile at WCAG AA against its glyph and the page', () => { + const tiles: Array = [ + 'rgb-file-document', + 'rgb-file-sheet', + 'rgb-file-code', + 'rgb-file-artifact', + 'rgb-file-audio', + 'rgb-file-video', + 'rgb-file-generic', + ]; + expect(below(theme, WCAG_AA_NORMAL, ['rgb-file-ink'], tiles)).toEqual([]); + expect(below(theme, WCAG_AA_NORMAL, tiles, ['rgb-surface-primary'])).toEqual([]); + }); + it('paints its status labels in the ink of the opposing canvas', () => { expect(theme['rgb-text-on-status']).toBe( theme === highContrastDarkTheme ? '0 0 0' : '255 255 255', diff --git a/packages/client/src/theme/themes/highContrast.ts b/packages/client/src/theme/themes/highContrast.ts index 7ee379aa5c..32acb4bf06 100644 --- a/packages/client/src/theme/themes/highContrast.ts +++ b/packages/client/src/theme/themes/highContrast.ts @@ -157,6 +157,15 @@ export const highContrastLightTheme: IThemeRGB = { 'rgb-illustration-subtle': '175 193 255', // #afc1ff 'rgb-illustration': '121 137 255', // #7989ff 'rgb-illustration-strong': '60 70 255', // #3c46ff + /** File-type tiles: each hue stepped so the glyph clears 6.5:1 on it (white glyph). */ + 'rgb-file-document': '176 0 78', // #b0004e + 'rgb-file-sheet': '0 107 79', // #006b4f + 'rgb-file-code': '163 60 0', // #a33c00 + 'rgb-file-artifact': '45 48 92', // #2d305c + 'rgb-file-audio': '138 69 0', // #8a4500 + 'rgb-file-video': '109 40 217', // #6d28d9 + 'rgb-file-generic': '0 0 255', // #0000ff + 'rgb-file-ink': '255 255 255', // #ffffff /** Code syntax highlighting at AAA on the white code surface. */ 'rgb-syntax-text': '0 0 0', // #000000 @@ -325,6 +334,15 @@ export const highContrastDarkTheme: IThemeRGB = { 'rgb-illustration-subtle': '175 193 255', // #afc1ff 'rgb-illustration': '121 137 255', // #7989ff 'rgb-illustration-strong': '60 70 255', // #3c46ff + /** File-type tiles: each hue stepped so the glyph clears 6.5:1 on it (black glyph, light tiles on the black canvas). */ + 'rgb-file-document': '255 158 194', // #ff9ec2 + 'rgb-file-sheet': '95 224 184', // #5fe0b8 + 'rgb-file-code': '255 164 126', // #ffa47e + 'rgb-file-artifact': '184 187 232', // #b8bbe8 + 'rgb-file-audio': '255 179 138', // #ffb38a + 'rgb-file-video': '201 179 255', // #c9b3ff + 'rgb-file-generic': '159 180 255', // #9fb4ff + 'rgb-file-ink': '0 0 0', // #000000 /** Code syntax highlighting at AAA on the black code surface. */ 'rgb-syntax-text': '255 255 255', // #ffffff diff --git a/packages/client/src/theme/tokens.css b/packages/client/src/theme/tokens.css index 927b5af8b5..72cf284ddb 100644 --- a/packages/client/src/theme/tokens.css +++ b/packages/client/src/theme/tokens.css @@ -29,6 +29,14 @@ --color-illustration-subtle: rgb(var(--illustration-subtle)); --color-illustration: rgb(var(--illustration)); --color-illustration-strong: rgb(var(--illustration-strong)); + --color-file-document: rgb(var(--file-document)); + --color-file-sheet: rgb(var(--file-sheet)); + --color-file-code: rgb(var(--file-code)); + --color-file-artifact: rgb(var(--file-artifact)); + --color-file-audio: rgb(var(--file-audio)); + --color-file-video: rgb(var(--file-video)); + --color-file-generic: rgb(var(--file-generic)); + --color-file-ink: rgb(var(--file-ink)); --color-presentation: rgb(var(--presentation)); --color-accent-primary: rgb(var(--accent-primary)); --color-accent-primary-hover: rgb(var(--accent-primary-hover)); diff --git a/packages/client/src/theme/types/index.ts b/packages/client/src/theme/types/index.ts index e85074e826..3c9636afc2 100644 --- a/packages/client/src/theme/types/index.ts +++ b/packages/client/src/theme/types/index.ts @@ -156,6 +156,15 @@ export interface IThemeRGB { 'rgb-illustration-subtle'?: string; 'rgb-illustration'?: string; 'rgb-illustration-strong'?: string; + /** File-type tiles: one fill per kind of file and the ink of the glyph drawn on them. */ + 'rgb-file-document'?: string; + 'rgb-file-sheet'?: string; + 'rgb-file-code'?: string; + 'rgb-file-artifact'?: string; + 'rgb-file-audio'?: string; + 'rgb-file-video'?: string; + 'rgb-file-generic'?: string; + 'rgb-file-ink'?: string; /** * Code syntax highlighting. Declared here rather than left as literals in the @@ -310,6 +319,14 @@ export interface IThemeVariables { '--illustration-subtle': string; '--illustration': string; '--illustration-strong': string; + '--file-document': string; + '--file-sheet': string; + '--file-code': string; + '--file-artifact': string; + '--file-audio': string; + '--file-video': string; + '--file-generic': string; + '--file-ink': string; '--syntax-text': string; '--syntax-comment': string; @@ -438,6 +455,14 @@ export interface IThemeColors { 'illustration-subtle'?: string; illustration?: string; 'illustration-strong'?: string; + 'file-document'?: string; + 'file-sheet'?: string; + 'file-code'?: string; + 'file-artifact'?: string; + 'file-audio'?: string; + 'file-video'?: string; + 'file-generic'?: string; + 'file-ink'?: string; 'series-1'?: string; 'series-2'?: string; diff --git a/packages/data-provider/src/theme.ts b/packages/data-provider/src/theme.ts index 9bafc741f5..2cee637fff 100644 --- a/packages/data-provider/src/theme.ts +++ b/packages/data-provider/src/theme.ts @@ -113,6 +113,14 @@ export const themeColorTokens = Object.freeze([ 'rgb-illustration-subtle', 'rgb-illustration', 'rgb-illustration-strong', + 'rgb-file-document', + 'rgb-file-sheet', + 'rgb-file-code', + 'rgb-file-artifact', + 'rgb-file-audio', + 'rgb-file-video', + 'rgb-file-generic', + 'rgb-file-ink', 'rgb-syntax-text', 'rgb-syntax-comment', 'rgb-syntax-meta',