fix(web): home shelves fill the window and their text stays readable on any cover
release / web (push) Failing after 11s
release / go (push) Successful in 1m52s
release / govulncheck (push) Successful in 23s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / android (push) Canceled after 4m3s
release / Build signed APK (push) Canceled after 2m3s
release / web (push) Failing after 11s
release / go (push) Successful in 1m52s
release / govulncheck (push) Successful in 23s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / integration (push) Canceled after 4m12s
release / android (push) Canceled after 4m3s
release / Build signed APK (push) Canceled after 2m3s
A wide card or genre band's wash keeps its cover's hue but caps its lightness and saturation, so a pale or loud cover no longer washes the card too light for its text; the faintest text on it is 80% parchment, and a test checks 4.5:1 against the lightest wash allowed. A genre's name keeps clear of its fan of covers. Shelves size their tiles to the window: each shows a whole number of tiles that fill its width, a short shelf grows its tiles up to a cap, and the arrows page by whole tiles. On a very wide screen the page stops at 140rem and centres. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -96,3 +96,56 @@ test('songsLikeArtist drops the shelf-wide prefix', () => {
|
||||
expect(songsLikeArtist(pl({ name: 'Songs like Low Tide Choir' }))).toBe('Low Tide Choir');
|
||||
expect(songsLikeArtist(pl({ name: 'Something else' }))).toBe('Something else');
|
||||
});
|
||||
|
||||
describe('washTone', () => {
|
||||
// WCAG relative luminance and contrast, to check the promise in the doc.
|
||||
const lum = ({ r, g, b }: { r: number; g: number; b: number }) => {
|
||||
const c = (v: number) => {
|
||||
const s = v / 255;
|
||||
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
||||
};
|
||||
return 0.2126 * c(r) + 0.7152 * c(g) + 0.0722 * c(b);
|
||||
};
|
||||
// The card mixes the tone 62% toward #0e1013 at its lightest end, and its
|
||||
// faintest text is parchment at 80% over that.
|
||||
const mix = (a: { r: number; g: number; b: number }, t: number, b = { r: 14, g: 16, b: 19 }) => ({
|
||||
r: a.r * t + b.r * (1 - t),
|
||||
g: a.g * t + b.g * (1 - t),
|
||||
b: a.b * t + b.b * (1 - t)
|
||||
});
|
||||
const parchment = { r: 232, g: 228, b: 216 };
|
||||
|
||||
test.each([
|
||||
['beige', { r: 200, g: 190, b: 160 }],
|
||||
['near white', { r: 245, g: 245, b: 245 }],
|
||||
['acid yellow', { r: 240, g: 240, b: 20 }],
|
||||
['light grey', { r: 170, g: 175, b: 180 }]
|
||||
])('a %s cover still leaves the faintest text at 4.5:1', (_, cover) => {
|
||||
const ground = mix(washTone(cover), 0.62);
|
||||
const text = mix(parchment, 0.8, ground);
|
||||
const ratio = (lum(text) + 0.05) / (lum(ground) + 0.05);
|
||||
expect(ratio).toBeGreaterThanOrEqual(4.5);
|
||||
});
|
||||
|
||||
test('a dark cover keeps its own colour', () => {
|
||||
expect(washTone({ r: 30, g: 60, b: 90 })).toEqual({ r: 30, g: 60, b: 90 });
|
||||
});
|
||||
});
|
||||
|
||||
describe('shelfTileWidth', () => {
|
||||
test('a long shelf shows whole tiles that fill its width', () => {
|
||||
const w = shelfTileWidth(1000, 20, 150, 200, 16);
|
||||
const cols = Math.floor((1000 + 16) / (150 + 16));
|
||||
expect(cols * w + (cols - 1) * 16).toBeLessThanOrEqual(1000);
|
||||
expect(cols * w + (cols - 1) * 16).toBeGreaterThan(1000 - cols);
|
||||
});
|
||||
|
||||
test('a short shelf grows its tiles up to the max', () => {
|
||||
expect(shelfTileWidth(1000, 2, 150, 200, 16)).toBe(200);
|
||||
expect(shelfTileWidth(400, 2, 150, 300, 16)).toBe(192);
|
||||
});
|
||||
|
||||
test('a narrow window still gets one tile at the min', () => {
|
||||
expect(shelfTileWidth(100, 5, 150, 200, 16)).toBe(150);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user