feat(design): switch to IMS Admin tokens, Geist and the 1px-rule gate

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 09:26:08 +08:00
co-authored by Claude Haiku 4.5
parent 9ed8c97c24
commit 01343d732e
18 changed files with 220 additions and 179 deletions
+66 -43
View File
@@ -4,59 +4,82 @@ import path from 'path'
const css = readFileSync(path.resolve(__dirname, '../../app/globals.css'), 'utf8')
describe('Modernist tokens in globals.css', () => {
describe('IMS Admin tokens in globals.css', () => {
it.each([
['--color-bg', '#f3f2f2'],
['--color-surface', '#eae9e9'],
['--color-text', '#201e1d'],
['--color-accent', '#ec3013'],
['--color-accent-700', '#ae1800'],
['--color-neutral-900', '#2d2b2b'],
['--color-ink', '#1f1f1f'],
['--color-ink-2', '#303030'],
['--color-ink-3', '#4a4a4a'],
['--color-muted', '#616161'],
['--color-faint', '#8a8a8a'],
['--color-rule', '#ebebeb'],
['--color-rule-2', '#e3e3e3'],
['--color-ring', '#d4d4d4'],
['--color-surface', '#ffffff'],
['--color-surface-2', '#f7f7f7'],
['--color-ground', '#f1f1f1'],
['--color-accent', '#0f766e'],
['--color-accent-tint', '#f2f7f6'],
['--color-accent-tint-2', '#e6f4f1'],
['--color-danger', '#b3261e'],
['--color-topbar', '#1a1a1a'],
])('declares %s as %s', (name, value) => {
expect(css).toMatch(new RegExp(`${name}:\\s*${value}`, 'i'))
expect(css).toMatch(new RegExp(`${name}:\\s*${value}\\b`, 'i'))
})
it.each(['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl'])('zeroes --radius-%s', size => {
expect(css).toMatch(new RegExp(`--radius-${size}:\\s*0px`))
it.each([
['amber', '#fff1c2', '#6b4a00'],
['blue', '#e0efff', '#00527c'],
['violet', '#ede7ff', '#4b2e99'],
['orange', '#ffe6cf', '#7a3a00'],
['indigo', '#e3e8ff', '#2c3e8f'],
['green', '#d7f4e3', '#0c5132'],
['grey', '#ebebeb', '#4a4a4a'],
['red', '#fee3e0', '#8e1f0b'],
])('declares the %s status pair', (hue, bg, fg) => {
expect(css).toMatch(new RegExp(`--color-st-${hue}-bg:\\s*${bg}`, 'i'))
expect(css).toMatch(new RegExp(`--color-st-${hue}-fg:\\s*${fg}`, 'i'))
})
it('zeroes the bare --radius used by the plain rounded class', () => {
expect(css).toMatch(/--radius:\s*0px/)
it('sets the radius scale: md 8, xl 12', () => {
expect(css).toMatch(/--radius-md:\s*8px/)
expect(css).toMatch(/--radius-xl:\s*12px/)
})
it('declares the card and floating shadows', () => {
expect(css).toMatch(/--shadow-card:\s*0 0 0 1px rgba\(0, ?0, ?0, ?\.08\), 0 1px 2px rgba\(0, ?0, ?0, ?\.06\)/)
expect(css).toMatch(/--shadow-float:\s*0 0 0 1px rgba\(0, ?0, ?0, ?\.1\), 0 12px 32px rgba\(0, ?0, ?0, ?\.18\)/)
})
it('declares the component shadows', () => {
for (const name of ['drawer', 'primary', 'secondary', 'input', 'chip', 'chip-set']) {
expect(css).toMatch(new RegExp(`--shadow-${name}:`))
}
})
it('uses Geist through the next/font variables', () => {
expect(css).toMatch(/--font-sans:\s*var\(--font-geist\)/)
expect(css).toMatch(/--font-mono:\s*var\(--font-geist-mono\)/)
})
it('keeps the legacy remaps so unmigrated pages still render', () => {
expect(css).toMatch(/--color-gray-100:\s*var\(--color-neutral-200\)/)
expect(css).toMatch(/--color-blue-600:\s*var\(--color-accent\)/)
expect(css).toMatch(/--color-red-600:\s*var\(--color-danger\)/)
expect(css).toMatch(/--color-divider:/)
})
it('styles keyboard focus with the 2px accent ring', () => {
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\)/)
})
it('has no dark mode block and no Modernist leftovers', () => {
expect(css).not.toContain('prefers-color-scheme')
expect(css).not.toMatch(/ec3013/i)
expect(css).not.toMatch(/archivo/i)
})
it('has no stray comment terminator before @theme', () => {
const head = css.slice(0, css.indexOf('@theme'))
expect(head.match(/\*\//g)?.length).toBe(head.match(/\/\*/g)?.length)
})
it('remaps the gray ramp onto the neutral ramp', () => {
expect(css).toMatch(/--color-gray-100:\s*var\(--color-neutral-200\)/)
expect(css).toMatch(/--color-gray-900:\s*var\(--color-text\)/)
})
it('remaps the blue ramp onto the accent ramp', () => {
expect(css).toMatch(/--color-blue-600:\s*var\(--color-accent\)/)
expect(css).toMatch(/--color-blue-700:\s*var\(--color-accent-700\)/)
})
it('remaps the red ramp onto the accent ramp, with body-size steps on accent-700', () => {
expect(css).toMatch(/--color-red-600:\s*var\(--color-accent-700\)/)
expect(css).toMatch(/--color-red-50:\s*var\(--color-accent-100\)/)
})
it('maps shadows onto the Modernist elevation tokens', () => {
expect(css).toMatch(/--shadow-2xl:\s*var\(--shadow-lg\)/)
})
it('uses Archivo through the next/font variable', () => {
expect(css).toMatch(/--font-sans:\s*var\(--font-archivo\)/)
})
it('has no dark mode block', () => {
expect(css).not.toContain('prefers-color-scheme')
})
it('styles keyboard focus with the 2px accent ring', () => {
expect(css).toMatch(/:focus-visible\s*\{[^}]*outline:\s*2px solid var\(--color-accent\)/)
})
})