fix: make CHRNX header fully progressive
This commit is contained in:
13 files changed
+414
-36
No files matched your search
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/header-tools",
|
||||
"version": "0.1.0",
|
||||
"title": "CHRNX Header Tools",
|
||||
"category": "theme",
|
||||
"description": "Display translated primary navigation and progressive site search.",
|
||||
"textdomain": "chrnx",
|
||||
"supports": { "html": false },
|
||||
"viewScript": "file:../../assets/js/search.js",
|
||||
"render": "file:./render.php"
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* Render translated primary navigation and progressive site search.
|
||||
*
|
||||
* @package CHRNX
|
||||
*/
|
||||
|
||||
$chrnx_header_links = array(
|
||||
array(
|
||||
'label' => __( 'Journal', 'chrnx' ),
|
||||
'url' => home_url( '/journal/' ),
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Projects', 'chrnx' ),
|
||||
'url' => home_url( '/projects/' ),
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Music', 'chrnx' ),
|
||||
'url' => home_url( '/music/' ),
|
||||
),
|
||||
array(
|
||||
'label' => __( 'Podcasts', 'chrnx' ),
|
||||
'url' => home_url( '/podcasts/' ),
|
||||
),
|
||||
array(
|
||||
'label' => __( 'About', 'chrnx' ),
|
||||
'url' => home_url( '/about/' ),
|
||||
),
|
||||
);
|
||||
$chrnx_search_label = __( 'Search', 'chrnx' );
|
||||
$chrnx_search_id = wp_unique_id( 'chrnx-search-' );
|
||||
?>
|
||||
<nav id="chrnx-primary-navigation" class="chrnx-primary-navigation" aria-label="<?php echo esc_attr__( 'Primary navigation', 'chrnx' ); ?>">
|
||||
<ul>
|
||||
<?php foreach ( $chrnx_header_links as $chrnx_link ) : ?>
|
||||
<li><a href="<?php echo esc_url( $chrnx_link['url'] ); ?>"><?php echo esc_html( $chrnx_link['label'] ); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</nav>
|
||||
<form class="chrnx-header-search" role="search" method="get" action="<?php echo esc_url( home_url( '/' ) ); ?>" data-chrnx-search data-expanded="false">
|
||||
<label class="chrnx-screen-reader-text" for="<?php echo esc_attr( $chrnx_search_id ); ?>"><?php echo esc_html( $chrnx_search_label ); ?></label>
|
||||
<input id="<?php echo esc_attr( $chrnx_search_id ); ?>" type="search" name="s" autocomplete="off">
|
||||
<button
|
||||
type="submit"
|
||||
data-chrnx-search-button
|
||||
data-label-open="<?php echo esc_attr__( 'Open search', 'chrnx' ); ?>"
|
||||
data-label-submit="<?php echo esc_attr( $chrnx_search_label ); ?>"
|
||||
>
|
||||
<span aria-hidden="true">⌕</span>
|
||||
<span class="chrnx-screen-reader-text"><?php echo esc_html( $chrnx_search_label ); ?></span>
|
||||
</button>
|
||||
</form>
|
||||
Reference in new issue
Block a user