🗂️ feat: Give File-Type Tiles Their Own Theme Roles (#16603)

* 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
This commit is contained in:
Marco Beretta 2026-10-01 17:44:29 +02:00 • committed by GitHub
parent 99015144e4
commit d9fdfddce9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 321 additions and 65 deletions

View file

@ -12,7 +12,7 @@ const FilePreview = ({
file?: Partial<ExtendedFile | TFile>;
fileType: {
paths: React.FC;
fill: string;
fillClassName: string;
title: string;
};
className?: string;
@ -22,11 +22,11 @@ const FilePreview = ({
<FileIcon file={file} fileType={fileType} />
<SourceIcon source={file?.source} isCodeFile={!!file?.['metadata']?.fileIdentifier} />
{typeof file?.['progress'] === 'number' && file?.['progress'] < 1 && (
<Spinner
bgOpacity={0.2}
color="white"
className="absolute inset-0 m-2.5 flex items-center justify-center"
/>
/* 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. */
<span className="text-file-ink absolute inset-0 m-2.5 flex items-center justify-center">
<Spinner bgOpacity={0.2} />
</span>
)}
</div>
);

View file

@ -87,38 +87,38 @@ export function hasIncompleteFiles(files: Map<string, ExtendedFile>): 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

View file

@ -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']),
});
}
});
});

View file

@ -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
}
}
}

View file

@ -5,35 +5,35 @@ export default function AudioPaths(): JSX.Element {
<>
<path
d="M8 15v6"
stroke="white"
className="stroke-file-ink"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M13 8v20"
stroke="white"
className="stroke-file-ink"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M18 10v16"
stroke="white"
className="stroke-file-ink"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M23 6v24"
stroke="white"
className="stroke-file-ink"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M28 12v12"
stroke="white"
className="stroke-file-ink"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"

View file

@ -5,14 +5,14 @@ export default function CodePaths(): JSX.Element {
<>
<path
d="M21.333 23L26.333 18L21.333 13"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M14.667 13L9.66699 18L14.667 23"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"

View file

@ -0,0 +1,24 @@
import { render } from '@testing-library/react';
import FileIcon from './FileIcon';
const Paths = () => <path d="M0 0h1v1z" />;
const tile = (container: HTMLElement) => container.querySelector('rect');
describe('FileIcon', () => {
it('paints the tile with a theme role through fillClassName', () => {
const { container } = render(
<FileIcon fileType={{ paths: Paths, fillClassName: 'fill-file-document', title: 'Doc' }} />,
);
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(
<FileIcon fileType={{ paths: Paths, fill: '#FF5588', title: 'Doc' }} />,
);
expect(tile(container)?.getAttribute('fill')).toBe('#FF5588');
expect(tile(container)?.hasAttribute('class')).toBe(false);
});
});

View file

@ -7,7 +7,10 @@ export default function FileIcon({
}: {
file?: Partial<TFile> & { 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"
>
<rect width="36" height="36" rx="6" fill={fileType.fill} />
<rect width="36" height="36" rx="6" fill={fileType.fill} className={fileType.fillClassName} />
{(file?.['progress'] ?? 1) >= 1 && <>{<fileType.paths />}</>}
</svg>
);

View file

@ -5,14 +5,14 @@ export default function FilePaths(): JSX.Element {
<>
<path
d="M18.833 9.66663H12.9997C12.5576 9.66663 12.1337 9.84222 11.8212 10.1548C11.5086 10.4673 11.333 10.8913 11.333 11.3333V24.6666C11.333 25.1087 11.5086 25.5326 11.8212 25.8451C12.1337 26.1577 12.5576 26.3333 12.9997 26.3333H22.9997C23.4417 26.3333 23.8656 26.1577 24.1782 25.8451C24.4907 25.5326 24.6663 25.1087 24.6663 24.6666V15.5L18.833 9.66663Z"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M18.833 9.66663V15.5H24.6663"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"

View file

@ -5,7 +5,7 @@ export default function SheetPaths(): JSX.Element {
<>
<path
d="M15.5 10.5H12.1667C11.2462 10.5 10.5 11.2462 10.5 12.1667V13.5V18M15.5 10.5H23.8333C24.7538 10.5 25.5 11.2462 25.5 12.1667V13.5V18M15.5 10.5V25.5M15.5 25.5H18H23.8333C24.7538 25.5 25.5 24.7538 25.5 23.8333V18M15.5 25.5H12.1667C11.2462 25.5 10.5 24.7538 10.5 23.8333V18M10.5 18H25.5"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"

View file

@ -5,35 +5,35 @@ export default function TextPaths(): JSX.Element {
<>
<path
d="M19.6663 9.66663H12.9997C12.5576 9.66663 12.1337 9.84222 11.8212 10.1548C11.5086 10.4673 11.333 10.8913 11.333 11.3333V24.6666C11.333 25.1087 11.5086 25.5326 11.8212 25.8451C12.1337 26.1577 12.5576 26.3333 12.9997 26.3333H22.9997C23.4417 26.3333 23.8656 26.1577 24.1782 25.8451C24.4907 25.5326 24.6663 25.1087 24.6663 24.6666V14.6666L19.6663 9.66663Z"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M19.667 9.66663V14.6666H24.667"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M21.3337 18.8334H14.667"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M21.3337 22.1666H14.667"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M16.3337 15.5H15.5003H14.667"
stroke="white"
className="stroke-file-ink"
strokeWidth="1.66667"
strokeLinecap="round"
strokeLinejoin="round"

View file

@ -4,9 +4,18 @@ export default function VideoPaths(): JSX.Element {
return (
<>
{/* Video container - rounded rectangle (not filled) */}
<rect x="8" y="10" width="20" height="16" rx="3" stroke="white" strokeWidth="2" fill="none" />
<rect
x="8"
y="10"
width="20"
height="16"
rx="3"
className="stroke-file-ink"
strokeWidth="2"
fill="none"
/>
{/* Play button - centered and pointing right */}
<path d="M22 18l-6 4v-8L22 18z" fill="white" />
<path d="M22 18l-6 4v-8L22 18z" className="fill-file-ink" />
</>
);
}

View file

@ -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

View file

@ -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.

View file

@ -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;

View file

@ -68,7 +68,7 @@ describe.each([
const tokens = Object.keys(theme) as Array<keyof IThemeRGB>;
it('covers every registry color', () => {
expect(tokens).toHaveLength(120);
expect(tokens).toHaveLength(128);
});
it('resolves every registry color to the runtime theme value', () => {

View file

@ -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)

View file

@ -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)",

View file

@ -152,6 +152,14 @@ const colorSources: Record<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'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<ThemeMode, Partial<Record<keyof IThemeRGB, string>>>
'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',

View file

@ -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

View file

@ -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)

View file

@ -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<keyof IThemeRGB> = [
'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',

View file

@ -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

View file

@ -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));

View file

@ -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;

View file

@ -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',