diff --git a/packages/client/ui-primitives/src/CodeFileIcon.tsx b/packages/client/ui-primitives/src/CodeFileIcon.tsx index 2e32bee8b0..a6f5608153 100644 --- a/packages/client/ui-primitives/src/CodeFileIcon.tsx +++ b/packages/client/ui-primitives/src/CodeFileIcon.tsx @@ -3,6 +3,26 @@ import type { ReactNode } from 'react' import type { IconProps } from './icons/props.ts' import type { CodeFileType } from './code-file-types.ts' +/** Non-localizable letterforms that are part of the source-format artwork. */ +const CODE_MARKS = { + c: 'C', + cpp: 'C', + csharp: 'C', + css: 'CSS', + env: 'ENV', + erlang: 'E', + ini: 'INI', + javascript: 'JS', + objectiveC: 'OC', + perl: 'PL', + php: 'PHP', + r: 'R', + toml: 'TOML', + typescript: 'TS', + yaml: 'YAML', + zig: 'ZIG', +} as const + /** * Render one full-color square code-file glyph from the embedded icon set. * @param props - Detailed code type, optional size, and optional CSS class. @@ -33,7 +53,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'C'} + {CODE_MARKS.c} ) @@ -63,7 +83,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'C'} + {CODE_MARKS.cpp} @@ -74,7 +94,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'C'} + {CODE_MARKS.csharp} @@ -84,7 +104,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'CSS'} + {CODE_MARKS.css} ) @@ -125,7 +145,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'ENV'} + {CODE_MARKS.env} ) @@ -135,7 +155,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'E'} + {CODE_MARKS.erlang} ) @@ -192,7 +212,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'INI'} + {CODE_MARKS.ini} ) @@ -209,7 +229,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'JS'} + {CODE_MARKS.javascript} ) @@ -266,7 +286,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'OC'} + {CODE_MARKS.objectiveC} ) @@ -275,7 +295,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'PL'} + {CODE_MARKS.perl} ) @@ -285,7 +305,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'PHP'} + {CODE_MARKS.php} ) @@ -351,7 +371,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'R'} + {CODE_MARKS.r} ) @@ -405,7 +425,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'TOML'} + {CODE_MARKS.toml} ) @@ -414,7 +434,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'TS'} + {CODE_MARKS.typescript} ) @@ -445,7 +465,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { <> - {'YAML'} + {CODE_MARKS.yaml} ) @@ -455,7 +475,7 @@ function codeFileArtwork(type: CodeFileType, gradientId: string): ReactNode { - {'ZIG'} + {CODE_MARKS.zig} ) diff --git a/packages/client/ui-primitives/tests/icons.client.spec.tsx b/packages/client/ui-primitives/tests/icons.client.spec.tsx index 1b9a9c7773..62cced1199 100644 --- a/packages/client/ui-primitives/tests/icons.client.spec.tsx +++ b/packages/client/ui-primitives/tests/icons.client.spec.tsx @@ -3,7 +3,7 @@ import { cleanup, render } from '@testing-library/react' import { afterEach, describe, expect, it } from 'vitest' import * as primitives from '@deepseek-ai/dsh-client-ui-primitives' import { - IconAlarmClockOutline16, IconApiOutline14, IconArchiveOutline20, IconFolderClose16, + DocumentFileIcon, IconAlarmClockOutline16, IconApiOutline14, IconArchiveOutline20, IconFolderClose16, IconGoalOutline16, IconSendOutline16, } from '@deepseek-ai/dsh-client-ui-primitives' @@ -70,6 +70,19 @@ describe('FishLogo', () => { }) }) +describe('DocumentFileIcon', () => { + it('renders the generic document artwork with instance-safe gradients and its class', () => { + const { container } = render(<>) + const svgs = [...container.querySelectorAll('svg')] + const ids = [...container.querySelectorAll('linearGradient')].map(gradient => gradient.id) + expect(svgs).toHaveLength(2) + expect(svgs[0]?.classList.contains('document')).toBe(true) + expect(new Set(ids).size).toBe(2) + expect([...container.querySelectorAll('svg > path:first-child')].map(path => path.getAttribute('fill'))) + .toEqual(ids.map(id => `url(#${id})`)) + }) +}) + describe('BrandWordmark', () => { it('can render the name artwork with or without its leading mark', () => { const view = render()