-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduces the "Blue Bar" or, more accurately, a local header beneath the global header. It includes a simple taxonomy-based breadcrumb on the left and a CSS-based dropdown menu of categories on the right. The color scheme changes ("The Not Blue Bar") for certain categories. The layout responsively handles mobile, tablet, and desktop views. This also makes the entire site header (including the global header) fixed to the top when not in a narrow mobile viewport, as called for in the design. Fixes #32
- Loading branch information
1 parent
bb4e3ff
commit ef84d32
Showing
15 changed files
with
352 additions
and
25 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...ce/wp-content/themes/wporg-news-2021/assets/svg/brush-stroke-nav-bar-blue-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
...wp-content/themes/wporg-news-2021/assets/svg/brush-stroke-nav-bar-coral-red.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
...wp-content/themes/wporg-news-2021/assets/svg/brush-stroke-nav-bar-dark-grey.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
source/wp-content/themes/wporg-news-2021/assets/svg/brush-stroke-nav-bar-green.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
source/wp-content/themes/wporg-news-2021/assets/svg/brush-stroke-nav-bar-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions
32
source/wp-content/themes/wporg-news-2021/block-template-parts/header-navigation.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,32 @@ | ||
<!-- wp:group {"align":"wide","className":"local-header__navigation"} --> | ||
<div class="wp-block-group alignwide local-header__navigation"> | ||
<!-- wp:group {"className":"local-header__breadcrumb"} --> | ||
<div class="wp-block-group local-header__breadcrumb"> | ||
<!-- wp:navigation {"orientation":"horizontal"} --> | ||
<!-- wp:home-link {"label":"News"} /--> | ||
<!-- /wp:navigation --> | ||
<!-- wp:query-title {"type":"archive","className":"local-header__breadcrumb-current"} /--> | ||
</div> | ||
<!-- /wp:group --> | ||
|
||
<!-- wp:group {"className":"local-header__categories"} --> | ||
<div class="wp-block-group local-header__categories"> | ||
<!-- | ||
The checkbox allows us to have a toggleable state for the categories dropdown that will persist when | ||
not in focus. This way we can manage the dropdown with CSS only, and not have to bring in JS. | ||
Inspired by https://codepen.io/Sidstumple/pen/RwNZYBe | ||
--> | ||
<!-- wp:html --> | ||
<input type="checkbox" id="local-header__categories-toggle" class="local-header__categories-toggle" aria-label="Show categories list" /> | ||
<label for="local-header__categories-toggle" class="local-header__categories-label"> | ||
<span>Categories</span> | ||
<svg width="10" height="7" viewBox="0 0 10 7" fill="none" stroke="white" stroke-width="1.2" xmlns="http://www.w3.org/2000/svg"> | ||
<path d="M0.416667 1.33325L5 5.49992L9.58331 1.33325" /> | ||
</svg> | ||
</label> | ||
<!-- /wp:html --> | ||
<!-- wp:categories /--> | ||
</div> | ||
<!-- /wp:group --> | ||
</div> | ||
<!-- /wp:group --> |
2 changes: 2 additions & 0 deletions
2
source/wp-content/themes/wporg-news-2021/block-template-parts/header.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,2 @@ | ||
<!-- wp:wporg/global-header /--> | ||
<!-- wp:template-part {"slug":"header-navigation","tagName":"nav","className":"local-header","layout":{"inherit":true}} /--> |
12 changes: 3 additions & 9 deletions
12
source/wp-content/themes/wporg-news-2021/block-templates/index.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
4 changes: 3 additions & 1 deletion
4
source/wp-content/themes/wporg-news-2021/block-templates/single.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
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
241 changes: 241 additions & 0 deletions
241
source/wp-content/themes/wporg-news-2021/sass/components/_header.scss
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,241 @@ | ||
.site-header { | ||
&-container { | ||
width: 100%; | ||
|
||
// Don't fix the header on mobile, because screen real estate is limited. | ||
// Matches the breakpoint for the admin bar. | ||
@include break-small { | ||
position: fixed; | ||
} | ||
} | ||
|
||
// Since the site header has a dynamic height, depending on the viewport width, this allows us to | ||
// offset the content by the same amount so it isn't covered by the visible fixed header. | ||
// See https://stackoverflow.com/a/59853252 | ||
&-offset { | ||
display: none; | ||
|
||
@include break-small { | ||
display: block; | ||
visibility: hidden; // This removes the element and descendents from the accessibility tree. | ||
} | ||
} | ||
} | ||
|
||
.local-header { | ||
// Evidently strings for custom properties can't be concatenated inside a `url()`, which is why each of the | ||
// color variations has to define its own version of the SVG. | ||
--bar-background-image: url("assets/svg/brush-stroke-nav-bar-blue-1.svg"), | ||
url("data:image/svg+xml,%3Csvg height='1000' width='1' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' height='1000' width='1' r='0' rx='0' ry='0' fill='%233e58e1'%3E%3C/rect%3E%3C/svg%3E"); | ||
--bar-text-color: var(--wp--preset--color--white); | ||
--bar-link-color: var(--wp--preset--color--white); | ||
|
||
min-height: 56px; | ||
background-image: var(--bar-background-image); | ||
background-position: 5% bottom, left calc( 100% - 56px ); | ||
background-repeat: repeat-x; | ||
color: var(--bar-text-color); | ||
|
||
.wp-site-blocks & { | ||
margin-top: 0; | ||
} | ||
|
||
svg { | ||
stroke: var(--bar-text-color); | ||
} | ||
|
||
// Color variations | ||
.category-development & { | ||
--bar-background-image: url("assets/svg/brush-stroke-nav-bar-green.svg"), | ||
url("data:image/svg+xml,%3Csvg height='1000' width='1' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' height='1000' width='1' r='0' rx='0' ry='0' fill='%2372d1a7'%3E%3C/rect%3E%3C/svg%3E"); | ||
--bar-text-color: var(--wp--preset--color--black); | ||
--bar-link-color: var(--wp--preset--color--black); | ||
} | ||
|
||
.category-events & { | ||
--bar-background-image: url("assets/svg/brush-stroke-nav-bar-white.svg"), | ||
url("data:image/svg+xml,%3Csvg height='1000' width='1' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' height='1000' width='1' r='0' rx='0' ry='0' fill='%23ffffff'%3E%3C/rect%3E%3C/svg%3E"); | ||
--bar-text-color: var(--wp--preset--color--black); | ||
--bar-link-color: var(--wp--preset--color--blue-1); | ||
} | ||
|
||
.category-month-in-wordpress & { | ||
--bar-background-image: url("assets/svg/brush-stroke-nav-bar-dark-grey.svg"), | ||
url("data:image/svg+xml,%3Csvg height='1000' width='1' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' height='1000' width='1' r='0' rx='0' ry='0' fill='%2323282d'%3E%3C/rect%3E%3C/svg%3E"); | ||
--bar-text-color: var(--wp--preset--color--white); | ||
--bar-link-color: var(--wp--preset--color--white); | ||
} | ||
|
||
.category-security & { | ||
--bar-background-image: url("assets/svg/brush-stroke-nav-bar-coral-red.svg"), | ||
url("data:image/svg+xml,%3Csvg height='1000' width='1' version='1.1' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' height='1000' width='1' r='0' rx='0' ry='0' fill='%23f86368'%3E%3C/rect%3E%3C/svg%3E"); | ||
--bar-text-color: var(--wp--preset--color--black); | ||
--bar-link-color: var(--wp--preset--color--black); | ||
} | ||
|
||
&__navigation { | ||
position: relative; | ||
|
||
@include break-mobile { | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: space-between; | ||
} | ||
|
||
[class*="wp-container-"] & { | ||
padding: 15px 0.5em; | ||
|
||
@include break-mobile { | ||
padding: 0 0.5em; | ||
} | ||
|
||
@include break-xlarge { | ||
padding: 0; | ||
} | ||
} | ||
} | ||
|
||
&__breadcrumb { | ||
color: var(--bar-text-color); | ||
|
||
@include break-mobile { | ||
line-height: 50px; | ||
} | ||
|
||
&-current { | ||
display: inline-block; | ||
font-family: var(--wp--preset--font-family--inter); | ||
font-size: 1rem; | ||
font-weight: 700; | ||
|
||
[class*="wp-container-"] & { | ||
margin-top: 0; | ||
} | ||
|
||
&:before { | ||
content: "\0020\00B7\0020"; | ||
} | ||
} | ||
|
||
.wp-block-navigation { | ||
display: inline-block; | ||
} | ||
|
||
a { | ||
color: var(--bar-link-color); | ||
} | ||
} | ||
|
||
&__categories { | ||
--flex-items-per-column: 8; | ||
|
||
@include break-medium { | ||
--flex-items-per-column: 4; | ||
} | ||
|
||
[class*="wp-container-"] & { | ||
margin-top: 0; | ||
} | ||
|
||
// This selector overcomes the overly generic `input[type=checkbox] + label` rule in the reset. | ||
label#{&}-label { | ||
display: block; | ||
color: var(--bar-text-color); | ||
margin: 0; | ||
padding: 15px 0; | ||
cursor: pointer; | ||
|
||
@include break-mobile { | ||
line-height: 50px; | ||
padding: 0; | ||
text-align: right; | ||
} | ||
|
||
span { | ||
padding: 0 3px 0 0; | ||
} | ||
|
||
svg { | ||
vertical-align: middle; | ||
} | ||
} | ||
|
||
&-toggle { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
appearance: none; | ||
position: fixed; | ||
|
||
&:checked { | ||
& + label { | ||
@include break-mobile { | ||
height: calc( 1rem * var(--wp--custom--body--typography--line-height) * var(--flex-items-per-column) + 125px ); | ||
} | ||
|
||
span { | ||
text-decoration: underline; | ||
} | ||
|
||
svg { | ||
transform: rotate( 180deg ); | ||
} | ||
} | ||
|
||
& ~ .wp-block-categories { | ||
display: flex; | ||
opacity: 1; | ||
animation-duration: 400ms; | ||
animation-name: categories-fade-in; | ||
|
||
@at-root { | ||
@keyframes categories-fade-in { | ||
from { | ||
opacity: 0; | ||
} | ||
|
||
to { | ||
opacity: 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
.wp-block-categories { | ||
display: none; | ||
opacity: 0; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
width: calc( min( 100%, var(--wp--custom--layout--wide-size) ) ); | ||
color: var(--bar-text-color); | ||
list-style: none; | ||
padding: 0 0 2em 0; | ||
|
||
@include break-mobile { | ||
padding: 0 0.5em 0; | ||
position: absolute; | ||
left: 0; | ||
top: 75px; | ||
max-height: calc( 1rem * var(--wp--custom--body--typography--line-height) * var(--flex-items-per-column) ); | ||
} | ||
|
||
[class*="wp-container-"] & { | ||
margin-top: 0; | ||
} | ||
|
||
a { | ||
color: var(--bar-link-color); | ||
} | ||
|
||
.current-cat { | ||
font-weight: 700; | ||
|
||
&:before { | ||
content: "\0020\00B7\0020"; | ||
} | ||
} | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
source/wp-content/themes/wporg-news-2021/sass/components/_style.scss
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 @@ | ||
@import "header"; |
11 changes: 0 additions & 11 deletions
11
source/wp-content/themes/wporg-news-2021/sass/post/_header.scss
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