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

+8 -7
View File
@@ -48,7 +48,7 @@ class ThemePreferenceTest extends WP_UnitTestCase {
$this->assertStringContainsString( 'document.documentElement.dataset.theme=t', $output );
}
/** Toggle uses a labeled native radio group with a live status. */
/** Toggle uses a labeled group of native toggle buttons with a live status. */
public function test_toggle_renders_accessible_native_controls() {
do_action( 'init' );
$output = render_block(
@@ -61,12 +61,13 @@ class ThemePreferenceTest extends WP_UnitTestCase {
)
);
$this->assertStringContainsString( '<fieldset', $output );
$this->assertStringContainsString( '<legend', $output );
$this->assertSame( 3, substr_count( $output, 'type="radio"' ) );
$this->assertStringContainsString( 'value="light"', $output );
$this->assertStringContainsString( 'value="dark"', $output );
$this->assertStringContainsString( 'value="system"', $output );
$this->assertStringContainsString( 'role="group"', $output );
$this->assertStringContainsString( 'aria-labelledby="chrnx-theme-legend-', $output );
$this->assertSame( 3, substr_count( $output, 'data-chrnx-theme-value="' ) );
$this->assertSame( 1, substr_count( $output, 'aria-pressed="true"' ) );
$this->assertStringContainsString( 'data-chrnx-theme-value="light"', $output );
$this->assertStringContainsString( 'data-chrnx-theme-value="dark"', $output );
$this->assertStringContainsString( 'data-chrnx-theme-value="system"', $output );
$this->assertStringContainsString( 'aria-live="polite"', $output );
$this->assertStringContainsString( 'data-status-system-light="Light theme active, following system preference"', $output );
$this->assertStringContainsString( 'data-status-system-dark="Dark theme active, following system preference"', $output );