Skip to content

Commit 8b9f4f6

Browse files
Improve mobile hamburger menu color (#23)
1 parent 91e2dfd commit 8b9f4f6

2 files changed

Lines changed: 60 additions & 1 deletion

File tree

‎app/globals.css‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
--card-bg: #ffffff;
2929
--border-color: #dde4ea;
3030
--input-border: #c6d2dc;
31+
/* Hamburger glyph + 1px border on the menu surface: mvp.css paints every
32+
button in --color-bg (the page background), which is invisible here, so
33+
the toggle re-drives from this accent (7.8:1 on --surface-color). */
34+
--menu-toggle-color: #1f5273;
3135
/* vizdom WASM graph edges bake black stroke/fill attributes into the SVG;
3236
palette-driven so the dark theme can swap them to a readable tint. */
3337
--graph-line: #000000;
@@ -94,6 +98,8 @@ html:root {
9498
--card-bg: #1a2330;
9599
--border-color: #2c3a4d;
96100
--input-border: #5b7396;
101+
/* Hamburger glyph + 1px border on the dark menu surface (6.8:1). */
102+
--menu-toggle-color: #6fb1d9;
97103
--graph-line: #9fb0c0;
98104
--error-color: #f0928c;
99105
--success-color: #5bbd8b;
@@ -136,6 +142,8 @@ html:root {
136142
--card-bg: #1a2330;
137143
--border-color: #2c3a4d;
138144
--input-border: #5b7396;
145+
/* Hamburger glyph + 1px border on the dark menu surface (6.8:1). */
146+
--menu-toggle-color: #6fb1d9;
139147
--graph-line: #9fb0c0;
140148
--error-color: #f0928c;
141149
--success-color: #5bbd8b;
@@ -326,7 +334,11 @@ pre {
326334
.menu-toggle {
327335
display: none;
328336
background: none;
329-
border: 1px solid var(--input-border);
337+
/* mvp.css paints every button in var(--color-bg) — the page background —
338+
which is invisible on the menu surface; re-drive glyph and border from
339+
the palette so the control stays perceivable in both themes. */
340+
color: var(--menu-toggle-color);
341+
border: 1px solid var(--menu-toggle-color);
330342
border-radius: var(--radius);
331343
font-size: 1.1rem;
332344
padding: 0.25rem 0.6rem;

‎tests/unit/theme-css.test.js‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,53 @@ describe('table filter accessibility', () => {
408408
}
409409
});
410410

411+
// Hamburger toggle (mobile view): mvp.css paints every button's text in
412+
// var(--color-bg), and .menu-toggle only overrode background/border, so the
413+
// ☰ glyph rendered in the page background color and the 1px --input-border
414+
// edge fell below 3:1 on the menu surface. Both must be re-driven from a
415+
// per-palette variable.
416+
describe('menu toggle contrast', () => {
417+
/**
418+
* Concatenates every declaration block for a selector: the rules map keeps
419+
* only the last occurrence (the responsive block) for repeated selectors,
420+
* so assertions must run against all of them together.
421+
*
422+
* @param {string} selector - CSS selector to collect.
423+
* @returns {string} Combined declarations.
424+
*/
425+
function combinedRule(selector) {
426+
const bodies = [];
427+
const ruleRe = /([^{}]+)\{([^{}]*)\}/g;
428+
let match;
429+
while ((match = ruleRe.exec(noComments)) !== null) {
430+
if (match[1].trim() === selector) bodies.push(match[2]);
431+
}
432+
return bodies.join(';');
433+
}
434+
435+
it('re-drives the glyph and border from the palette', () => {
436+
const toggle = combinedRule('.menu-toggle');
437+
expect(toggle).toMatch(/(?:^|;)\s*color:\s*var\(--menu-toggle-color\)/);
438+
expect(toggle).toMatch(/border:\s*1px solid var\(--menu-toggle-color\)/);
439+
});
440+
441+
for (const [name, palette] of [['light', lightPalette], ['dark', darkPalette]]) {
442+
it(`declares a ${name} palette color for the toggle`, () => {
443+
expect(palette.get('--menu-toggle-color')).toBeTruthy();
444+
});
445+
446+
it(`the glyph keeps AA text contrast on the menu surface (${name}, SC 1.4.3)`, () => {
447+
expect(contrastOf(palette, '--surface-color', '--menu-toggle-color'))
448+
.toBeGreaterThanOrEqual(4.5);
449+
});
450+
451+
it(`the border is perceivable on the menu surface (${name}, SC 1.4.11)`, () => {
452+
expect(contrastOf(palette, '--surface-color', '--menu-toggle-color'))
453+
.toBeGreaterThanOrEqual(3);
454+
});
455+
}
456+
});
457+
411458
describe('report CSS selector boundaries', () => {
412459
it('themes only graph edges and arrowheads, preserving red cycles and node glyphs', () => {
413460
const fixture = document.createElement('div');

0 commit comments

Comments
 (0)