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

+49 -7
View File
@@ -119,13 +119,13 @@ class BlockRenderingTest extends WP_UnitTestCase {
$this->assertNotEmpty( $theme_control[1] );
$this->assertSame( 1, substr_count( $output, 'id="' . $theme_control[1] . '"' ) );
$this->assertMatchesRegularExpression(
'/<fieldset[^>]+id="' . preg_quote( $theme_control[1], '/' ) . '"[^>]+data-chrnx-theme-toggle[^>]+data-chrnx-theme-panel/',
'/<div[^>]+id="' . preg_quote( $theme_control[1], '/' ) . '"[^>]+role="group"[^>]+data-chrnx-theme-toggle[^>]+data-chrnx-theme-panel/s',
$output
);
$this->assertSame( 3, substr_count( $output, 'type="radio"' ) );
$this->assertSame( 3, substr_count( $output, 'data-chrnx-theme-value="' ) );
foreach ( array( 'light', 'dark', 'system' ) as $value ) {
$this->assertMatchesRegularExpression(
'/<input[^>]+type="radio"[^>]+value="' . $value . '"/',
'/<button[^>]+data-chrnx-theme-value="' . $value . '"[^>]+aria-pressed="(?:true|false)"/s',
$output
);
}
@@ -358,6 +358,41 @@ class BlockRenderingTest extends WP_UnitTestCase {
$this->assertStringContainsString( 'href="#chrnx-main"', $output );
}
/** Navigation falls back to the built-in pages and prefers an assigned menu. */
public function test_navigation_links_prefer_an_assigned_menu_over_the_builtin_fallback() {
$this->assertTrue( function_exists( 'chrnx_get_navigation_links' ) );
$fallback = chrnx_get_navigation_links( 'chrnx-primary' );
$this->assertCount( 5, $fallback );
$this->assertSame( 'Journal', $fallback[0]['label'] );
$this->assertSame( home_url( '/journal/' ), $fallback[0]['url'] );
$menu_id = wp_create_nav_menu( 'Prod nav ' . wp_unique_id() );
$this->assertIsInt( $menu_id );
wp_update_nav_menu_item(
$menu_id,
0,
array(
'menu-item-title' => 'Notas',
'menu-item-url' => home_url( '/notas/' ),
'menu-item-status' => 'publish',
)
);
$locations = get_nav_menu_locations();
$locations['chrnx-primary'] = $menu_id;
set_theme_mod( 'nav_menu_locations', $locations );
$assigned = chrnx_get_navigation_links( 'chrnx-primary' );
$this->assertCount( 1, $assigned );
$this->assertSame( 'Notas', $assigned[0]['label'] );
$this->assertSame( home_url( '/notas/' ), $assigned[0]['url'] );
// An empty location must not leave the header without navigation.
$locations['chrnx-primary'] = 0;
set_theme_mod( 'nav_menu_locations', $locations );
$this->assertCount( 5, chrnx_get_navigation_links( 'chrnx-primary' ) );
}
/** Topic art is an exact fixed mapping and rejects arbitrary paths. */
public function test_topic_art_uses_only_the_fixed_mapping() {
$expected = array(
@@ -722,7 +757,7 @@ class BlockRenderingTest extends WP_UnitTestCase {
);
$this->assertStringContainsString( '>Silicon Ranch</h2>', $output );
$this->assertStringContainsString( 'alter-ego-podcasts.png', $output );
$this->assertStringContainsString( 'alter-ego-podcasts-768.webp', $output );
$this->assertStringNotContainsString( '>Podcasts</h2>', $output );
$this->assertSame( 1, substr_count( $output, 'class="chrnx-character-stage"' ) );
}
@@ -771,7 +806,11 @@ class BlockRenderingTest extends WP_UnitTestCase {
$this->assertSame( 1, substr_count( $output, '<article' ) );
$this->assertStringContainsString( 'Only Story', $output );
$this->assertStringContainsString( 'aria-hidden="true"', $output );
$this->assertStringNotContainsString( 'placeholder', strtolower( $output ) );
// A card without media now shows the shared placeholder, which must stay
// decorative and keep its topic class so the accent still varies.
$this->assertStringContainsString( 'placeholder-post', $output );
$this->assertMatchesRegularExpression( '/<picture[^>]*aria-hidden="true"/', $output );
$this->assertStringContainsString( 'is-topic-code', $output );
}
/** Primed editorial cards reuse relationship caches instead of querying once per fallback. */
@@ -871,8 +910,11 @@ class BlockRenderingTest extends WP_UnitTestCase {
$output = $this->render_for_post( 'chrnx/related-posts', $current );
$this->assertStringContainsString( 'chrnx-related-card__fallback', $output );
$this->assertMatchesRegularExpression( '/class="[^"]*chrnx-related-card__fallback[^"]*" aria-hidden="true"/', $output );
$this->assertStringNotContainsString( '<img', $output );
// The fallback is the shared placeholder image now, still decorative and
// still carrying its topic class for the accent underneath it.
$this->assertMatchesRegularExpression( '/<picture[^>]*aria-hidden="true"/', $output );
$this->assertMatchesRegularExpression( '/<img[^>]*class="[^"]*chrnx-related-card__fallback[^"]*is-topic-research/', $output );
$this->assertStringContainsString( 'placeholder-post', $output );
}
/** Provide strict Related Stories limit inputs and their expected card counts. */