Settings -> Venue -> accent "The venue's identity" (venue.theme = identity): bootstrap carries the identity's first colour and logos; @xenia/ui applyVenueTheme makes the accent tokens (light and dark, readable foregrounds) from it. A display look's "Colours and logo" can be the venue's identity. Plan 6R.20, F-117. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
1.2 KiB
JavaScript
20 lines
1.2 KiB
JavaScript
// The accent from the venue's identity colour (6R.20).
|
|
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { accentCss, accentTokens } from '../src/venueAccent.js'
|
|
|
|
const lum = s => { const [r, g, b] = s.split(' ').map(Number).map(v => { const x = v / 255; return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4 }); return 0.2126 * r + 0.7152 * g + 0.0722 * b }
|
|
const contrast = (a, b) => { const [x, y] = [lum(a), lum(b)].sort((m, n) => n - m); return (x + 0.05) / (y + 0.05) }
|
|
|
|
test('tokens from a colour: text on the accent reads, light and dark', () => {
|
|
for (const hex of ['#1e3a8a', '#f59e0b', '#ffffff', '#000000', '#22c55e', '#e63946']) {
|
|
const t = accentTokens(hex)
|
|
assert.ok(contrast(t.light.accent, t.light['accent-fg']) >= 3, `${hex} light ${JSON.stringify(t.light)}`)
|
|
assert.ok(contrast(t.dark.accent, t.dark['accent-fg']) >= 3, `${hex} dark ${JSON.stringify(t.dark)}`)
|
|
assert.ok(contrast(t.light['accent-ink'], '255 255 255') >= 3, `${hex} ink on white`)
|
|
}
|
|
assert.equal(accentTokens('red'), null)
|
|
assert.equal(accentCss('nope'), '')
|
|
assert.match(accentCss('#1e3a8a'), /\[data-venue-theme="identity"\] \{ --x-accent-rgb: 30 58 138;/)
|
|
})
|