-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Header: Use different templates based on page heirarchy (#500)
* Update homepage header * New block: Add a page title block which can be used for single, archive, and search page titles. * Add the "Level 2 B" header variation as "header-alt" * Block Hooks: Update template part depending on the current page. * Unhide breadcrumbs on small screens * Fade in page title on scroll * Fix spacing of Table of Contents sidebar * Update space over search box to match other pages * Fix sidebar alignment on landing & inner handbook pages
- Loading branch information
Showing
15 changed files
with
181 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
source/wp-content/themes/wporg-developer-2023/parts/header-alt.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- wp:wporg/global-header {"style":{"border":{"bottom":{"color":"var:preset|color|white-opacity-15","style":"solid","width":"1px"}}}} /--> | ||
|
||
<!-- wp:wporg/local-navigation-bar {"className":"has-display-contents","backgroundColor":"charcoal-2","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"},":hover":{"color":{"text":"var:preset|color|white"}}}}},"textColor":"white","fontSize":"small"} --> | ||
|
||
<!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"textColor":"light-grey-1","layout":{"type":"flex","flexWrap":"nowrap"}} --> | ||
<div class="wp-block-group has-light-grey-1-color has-text-color"> | ||
<!-- wp:site-title {"level":0,"fontSize":"small","textColor":"white"} /--> | ||
|
||
<!-- wp:wporg/page-title {"level":0,"fontSize":"small","fontFamily":"inter","className":"wporg-local-navigation-bar__fade-in-scroll"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:navigation {"icon":"menu","overlayBackgroundColor":"charcoal-2","overlayTextColor":"white","layout":{"type":"flex","orientation":"horizontal"},"fontSize":"small","menuSlug":"developer"} /--> | ||
|
||
<!-- /wp:wporg/local-navigation-bar --> |
28 changes: 28 additions & 0 deletions
28
source/wp-content/themes/wporg-developer-2023/parts/header-third.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- | ||
This template part is not called directly from any templates, it's swapped out automatically by `modify_header_template_part`. | ||
It should be used on "Level 3+" pages, pages with at least 2 ancestors (for example, Home > Handbook home > Article). | ||
--> | ||
|
||
<!-- wp:wporg/global-header {"style":{"border":{"bottom":{"color":"var:preset|color|white-opacity-15","style":"solid","width":"1px"}}}} /--> | ||
|
||
<!-- wp:wporg/local-navigation-bar {"className":"has-display-contents","backgroundColor":"charcoal-2","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"},":hover":{"color":{"text":"var:preset|color|white"}}}}},"textColor":"white","fontSize":"small"} --> | ||
|
||
<!-- wp:group {"style":{"spacing":{"blockGap":"0"}},"textColor":"light-grey-1","layout":{"type":"flex","flexWrap":"nowrap"}} --> | ||
<div class="wp-block-group has-light-grey-1-color has-text-color"> | ||
<!-- wp:site-title {"level":0,"fontSize":"small","textColor":"white"} /--> | ||
|
||
<!-- wp:wporg/page-title {"level":0,"fontSize":"small","fontFamily":"inter","className":"wporg-local-navigation-bar__fade-in-scroll"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:navigation {"icon":"menu","overlayBackgroundColor":"charcoal-2","overlayTextColor":"white","layout":{"type":"flex","orientation":"horizontal"},"fontSize":"small","menuSlug":"developer"} /--> | ||
|
||
<!-- /wp:wporg/local-navigation-bar --> | ||
|
||
<!-- wp:group {"className":"wporg-breadcrumbs","align":"full","style":{"spacing":{"padding":{"top":"18px","bottom":"18px","left":"var:preset|spacing|edge-space","right":"var:preset|spacing|edge-space"}}},"backgroundColor":"white","layout":{"type":"flex","flexWrap":"wrap","justifyContent":"space-between"}} --> | ||
<div class="wporg-breadcrumbs wp-block-group alignfull has-white-background-color has-background" style="padding-top:18px;padding-right:var(--wp--preset--spacing--edge-space);padding-bottom:18px;padding-left:var(--wp--preset--spacing--edge-space)"> | ||
|
||
<!-- wp:wporg/site-breadcrumbs {"fontSize":"small"} /--> | ||
|
||
</div> | ||
<!-- /wp:group --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
source/wp-content/themes/wporg-developer-2023/src/page-title/block.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "wporg/page-title", | ||
"version": "0.1.0", | ||
"title": "Page Title", | ||
"category": "widgets", | ||
"description": "Page Title", | ||
"attributes": { | ||
"level": { | ||
"type": "integer", | ||
"default": 1 | ||
} | ||
}, | ||
"supports": { | ||
"html": false, | ||
"spacing": { | ||
"margin": true, | ||
"padding": true | ||
}, | ||
"typography": { | ||
"fontSize": true, | ||
"lineHeight": true | ||
} | ||
}, | ||
"textdomain": "wporg", | ||
"editorScript": "file:./index.js" | ||
} |
17 changes: 17 additions & 0 deletions
17
source/wp-content/themes/wporg-developer-2023/src/page-title/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Edit from '../shared/dynamic-edit'; | ||
import metadata from './block.json'; | ||
|
||
registerBlockType( metadata.name, { | ||
/** | ||
* @see ./edit.js | ||
*/ | ||
edit: Edit, | ||
} ); |
50 changes: 50 additions & 0 deletions
50
source/wp-content/themes/wporg-developer-2023/src/page-title/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
namespace WordPressdotorg\Theme\Developer_2023\Page_Title; | ||
|
||
add_action( 'init', __NAMESPACE__ . '\init' ); | ||
|
||
/** | ||
* Registers the block using the metadata loaded from the `block.json` file. | ||
* Behind the scenes, it registers also all assets so they can be enqueued | ||
* through the block editor in the corresponding context. | ||
* | ||
* @see https://developer.wordpress.org/reference/functions/register_block_type/ | ||
*/ | ||
function init() { | ||
register_block_type( | ||
dirname( dirname( __DIR__ ) ) . '/build/page-title', | ||
array( | ||
'render_callback' => __NAMESPACE__ . '\render', | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Render the block content. | ||
* | ||
* @return string Returns the block markup. | ||
*/ | ||
function render( $attributes, $content, $block ) { | ||
$tag_name = 'h1'; | ||
if ( isset( $attributes['level'] ) ) { | ||
$tag_name = 0 === $attributes['level'] ? 'p' : 'h' . (int) $attributes['level']; | ||
} | ||
|
||
$title = get_the_title(); | ||
|
||
if ( is_search() ) { | ||
$title = __( 'Search results', 'wporg' ); | ||
} elseif ( is_archive() ) { | ||
$title = get_the_archive_title(); | ||
} elseif ( in_array( get_post_type(), array( 'wp-parser-function', 'wp-parser-method' ) ) ) { | ||
$title .= '()'; | ||
} | ||
|
||
$wrapper_attributes = get_block_wrapper_attributes(); | ||
return sprintf( | ||
'<%1$s %2$s>%3$s</section>', | ||
$tag_name, | ||
$wrapper_attributes, | ||
$title, | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/wp-content/themes/wporg-developer-2023/templates/archive.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/wp-content/themes/wporg-developer-2023/templates/page-dashicons.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/wp-content/themes/wporg-developer-2023/templates/search.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
source/wp-content/themes/wporg-developer-2023/templates/single-handbook.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters