feat: rebuild the header controls as icon buttons

The theme switch was three labelled radios that wrapped the header onto
a second line with long translations. It is three SVG buttons now, with
search and menu sharing the same language: no resting outline, a filled
chip for the active choice.

Radios gave arrow-key roving for free, so the group reimplements it
rather than losing it. The first chip colour put accent on accent and
failed WCAG AA; the label carries full contrast instead. Mobile targets
sit at 45px because a floor of exactly 44 rounds to 43.99997 in Firefox.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
chrnxandClaude Opus 5 committed 2026-08-13 19:41:24 -05:00
1 parent f55d9d9b45
commit a142ece51d
16 files changed
+316 -156

No files matched your search

+25 -16
View File
@@ -547,12 +547,12 @@ test.describe( 'site navigation shell', () => {
expect( themeBox.x ).toBeGreaterThanOrEqual( 0 );
expect( themeBox.x + themeBox.width ).toBeLessThanOrEqual( width );
for ( const name of [ 'Light', 'Dark', 'System' ] ) {
const radio = header.getByRole( 'radio', { name, exact: true } );
const radio = header.getByRole( 'button', { name, exact: true } );
await expect( radio ).toBeVisible();
const radioBox = await getBox( radio );
expect( radioBox.width ).toBeGreaterThan( 0 );
expect( radioBox.height ).toBeGreaterThan( 0 );
await expectContainedTarget( radio.locator( '..' ), width );
await expectContainedTarget( radio, width );
}
await expectNoHorizontalOverflow( page, header );
} );
@@ -566,17 +566,20 @@ test.describe( 'site navigation shell', () => {
await page.setViewportSize( { width, height: 844 } );
await page.goto( '/' );
if ( scenario === 'long translated labels' ) {
await page.locator( '[data-chrnx-theme-panel] label' ).evaluateAll( ( labels ) => {
const translations = [
'Helles Erscheinungsbild verwenden',
'Dunkles Erscheinungsbild verwenden',
'Automatisch dem Farbschema des Betriebssystems folgen',
];
labels.forEach( ( label, index ) => {
const text = Array.from( label.childNodes ).find( ( node ) => node.nodeType === 3 );
text.nodeValue = ` ${ translations[ index ] }`;
await page
.locator( '[data-chrnx-theme-panel] [data-chrnx-theme-value]' )
.evaluateAll( ( buttons ) => {
const translations = [
'Helles Erscheinungsbild verwenden',
'Dunkles Erscheinungsbild verwenden',
'Automatisch dem Farbschema des Betriebssystems folgen',
];
// The label is the accessible name only; icons carry the layout.
buttons.forEach( ( button, index ) => {
button.querySelector( '.chrnx-screen-reader-text' ).textContent =
translations[ index ];
} );
} );
} );
} else {
await page.evaluate( () => {
document.documentElement.style.fontSize = '200%';
@@ -650,7 +653,7 @@ test.describe( 'site navigation shell', () => {
const themePanel = header.locator( '[data-chrnx-theme-panel]' );
await expect( nav ).toBeVisible();
await expect( themePanel ).toBeVisible();
await expect( header.getByRole( 'radio', { name: 'System', exact: true } ) ).toBeVisible();
await expect( header.getByRole( 'button', { name: 'System', exact: true } ) ).toBeVisible();
await expect( header.locator( '[data-chrnx-menu-toggle]' ) ).toBeHidden();
await expect( header.locator( '[data-chrnx-theme-button]' ) ).toBeHidden();
await expect( header.getByRole( 'button', { name: 'Open search' } ) ).toBeVisible();
@@ -791,7 +794,9 @@ test.describe( 'site navigation shell', () => {
await page.goto( '/' );
header = page.getByRole( 'banner' );
let themeButton = header.locator( '[data-chrnx-theme-button]' );
let checkedTheme = header.locator( '[data-chrnx-theme-panel] input:checked' );
let checkedTheme = header.locator(
'[data-chrnx-theme-panel] [data-chrnx-theme-value][aria-pressed="true"]',
);
await expect( themeButton ).toBeVisible();
await themeButton.focus();
await page.setViewportSize( { width: 600, height: 844 } );
@@ -818,7 +823,9 @@ test.describe( 'site navigation shell', () => {
await page.setViewportSize( { width: 600, height: 844 } );
await page.goto( '/' );
header = page.getByRole( 'banner' );
checkedTheme = header.locator( '[data-chrnx-theme-panel] input:checked' );
checkedTheme = header.locator(
'[data-chrnx-theme-panel] [data-chrnx-theme-value][aria-pressed="true"]',
);
themeButton = header.locator( '[data-chrnx-theme-button]' );
await checkedTheme.focus();
await page.setViewportSize( { width: 390, height: 844 } );
@@ -832,7 +839,9 @@ test.describe( 'site navigation shell', () => {
const menuButton = header.locator( '[data-chrnx-menu-toggle]' );
const themeButton = header.locator( '[data-chrnx-theme-button]' );
const journal = header.getByRole( 'link', { name: 'Journal', exact: true } );
const checkedTheme = header.locator( '[data-chrnx-theme-panel] input:checked' );
const checkedTheme = header.locator(
'[data-chrnx-theme-panel] [data-chrnx-theme-value][aria-pressed="true"]',
);
await menuButton.click();
await journal.focus();