Skip to content

Commit

Permalink
Try/header template part wrapped (#3714)
Browse files Browse the repository at this point in the history
* Modified site-title styles to match comps

* Added a navigation rendering function to render the navigation block based on a classic data source, wrap the output in an HTML block to be inserted anywhere blocks are do_block()'ed

* Added a header template part that leverages the rendered navigation block markup

* Replaced usage of navigation block template with new template-part

* Added styles for header for proper layout unachievable with blocks.
  • Loading branch information
pbking committed Apr 27, 2021
1 parent 92ad37d commit 4c9ca9d
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 37 deletions.
4 changes: 2 additions & 2 deletions quadrat/404.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
get_header();

// the header
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/header.html' ) );
get_template_part( 'template-parts/header' );

echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/404.html' ) );

// the footer
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/footer.html' ) );

get_footer();
get_footer();
6 changes: 6 additions & 0 deletions quadrat/assets/theme.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions quadrat/child-experimental-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@
"lineHeight": "var(--wp--custom--line-height--body)"
}
},
"core/site-title": {
"typography": {
"fontWeight": 800,
"fontSize": "20px"
},
"color": {
"link": "var(--wp--custom--color--primary)"
}
},
"core/button": {
"color": {
"text": "var(--wp--custom--button--color--text)",
Expand Down
6 changes: 3 additions & 3 deletions quadrat/experimental-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,11 @@
},
"core/site-title": {
"typography": {
"fontSize": "60px",
"fontWeight": 700
"fontSize": "20px",
"fontWeight": 800
},
"color": {
"link": "black"
"link": "var(--wp--custom--color--primary)"
}
},
"core/navigation": {
Expand Down
25 changes: 25 additions & 0 deletions quadrat/inc/render-navigation-block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
if ( ! function_exists( 'render_navigation_block' ) ) :

function render_navigation_block( $menu_location ) {
if ( ! has_nav_menu( $menu_location ) ) {
return;
}

$nav_items = wp_nav_menu(
array(
'echo' => false,
'theme_location' => $menu_location,
'container' => '',
'items_wrap' => '%3$s',
'fallback_cb' => false,
)
);

if ( ! $nav_items ) {
return;
}

return '<!-- wp:html -->' . $nav_items . '<!-- /wp:html -->';
}
endif;
2 changes: 1 addition & 1 deletion quadrat/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
get_header();

// the header
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/header.html' ) );
get_template_part( 'template-parts/header' );

// the query
echo do_blocks( '<!-- wp:post-content {"layout":{"inherit":true}} /-->' );
Expand Down
7 changes: 7 additions & 0 deletions quadrat/sass/_header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.site-header {
.wp-block-group {
display: flex;
justify-content: space-between;
align-items: center;
}
}
1 change: 1 addition & 0 deletions quadrat/sass/theme.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import "../../blank-canvas-blocks/sass/base/breakpoints"; // Get the mobile-only media query and make it available to this theme's styles
@import "blocks/media-text";
@import "blocks/list";
@import "header";
@import "utility";
4 changes: 2 additions & 2 deletions quadrat/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
get_header();

// the header
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/header.html' ) );
get_template_part( 'template-parts/header' );

echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/search.html' ) );

// the footer
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/footer.html' ) );

get_footer();
get_footer();
4 changes: 2 additions & 2 deletions quadrat/singular.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
get_header();

// the header
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/header.html' ) );
get_template_part( 'template-parts/header' );

echo do_blocks( '<!-- wp:post-content {"layout":{"inherit":true}} /-->' );

// the footer
echo do_blocks( file_get_contents( get_stylesheet_directory() . '/templates/footer.html' ) );

get_footer();
get_footer();
23 changes: 23 additions & 0 deletions quadrat/template-parts/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* Displays the header.
* Needed until we have a consistent mechanism to render a navigation between FSE and classic menus.
*
* @package Quadrat
* @since 1.0.0
*
*/

require get_stylesheet_directory() . '/inc/render-navigation-block.php';
?>

<header class="site-header" role="banner">
<?php
echo do_blocks(
'<!-- wp:group {"style":{"spacing":{"padding":{"right":"35px","left":"35px"}}}} --><div class="wp-block-group" style="padding-right:35px;padding-left:35px">
<!-- wp:site-title /-->' .
render_navigation_block( 'primary' ) .
'</div><!-- /wp:group -->'
);
?>
</header>
27 changes: 0 additions & 27 deletions quadrat/templates/header.html

This file was deleted.

Empty file removed quadrat/templates/navigation.html
Empty file.

0 comments on commit 4c9ca9d

Please sign in to comment.