Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial mobile header pattern #18

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@ Thumbs.db
/dist/
*.asset.php

# Build images
/images/

# Release folder
/release/
4 changes: 1 addition & 3 deletions parts/header.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<!-- wp:template-part {"slug":"desktop-header","tagName":"header","className":"desktop-header", "id":"desktop-header"} /-->

<!-- wp:template-part {"slug":"mobile-header","tagName":"header","className":"mobile-header", "id":"desktop-header"} /-->

<!-- wp:template-part {"slug":"mobile-sidebar","tagName":"div","className":"mobile-sidebar", "id":"mobile-sidebar"} /-->
<!-- wp:template-part {"slug":"mobile-header","tagName":"header","className":"mobile-header", "id":"mobile-header"} /-->
24 changes: 12 additions & 12 deletions parts/mobile-header.html
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!-- wp:group {"layout":{"type":"constrained"}} -->
<div class="wp-block-group"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"bottom":"var:preset|spacing|20","top":"var:preset|spacing|20","right":"0","left":"0"}}},"layout":{"type":"flex","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--20);padding-right:0;padding-bottom:var(--wp--preset--spacing--20);padding-left:0"><!-- wp:group {"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:site-logo {"width":64} /-->
<div class="wp-block-group"><!-- wp:group {"align":"wide","style":{"spacing":{"padding":{"bottom":"var:preset|spacing|40","top":"var:preset|spacing|40","right":"0","left":"0"}}},"layout":{"type":"flex","justifyContent":"space-between"}} -->
<div class="wp-block-group alignwide" style="padding-top:var(--wp--preset--spacing--40);padding-right:0;padding-bottom:var(--wp--preset--spacing--40);padding-left:0"><!-- wp:group {"style":{"spacing":{"blockGap":"var:preset|spacing|30"}},"layout":{"type":"flex"}} -->
<div class="wp-block-group"><!-- wp:template-part {"slug":"mobile-menu","theme":"newspack-block-theme","tagName":"div","className":"mobile-menu"} /-->

<!-- wp:site-logo {"width":54} /-->

<!-- wp:group {"style":{"spacing":{"blockGap":"0px"}}} -->
<div class="wp-block-group"><!-- wp:site-title /--></div>
<div class="wp-block-group"></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"className":"mobile-menu-toggle"} -->
<div class="wp-block-button mobile-menu-toggle"><a class="wp-block-button__link wp-element-button" href="#">Menu</a></div>
<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"spacing":{"padding":{"left":"var:preset|spacing|40","right":"var:preset|spacing|40","top":"0.33rem","bottom":"0.33rem"}}},"fontSize":"small"} -->
<div class="wp-block-button has-custom-font-size has-small-font-size"><a class="wp-block-button__link wp-element-button" style="padding-top:0.33rem;padding-right:var(--wp--preset--spacing--40);padding-bottom:0.33rem;padding-left:var(--wp--preset--spacing--40)">Donate</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons --></div>
<!-- /wp:group --></div>
<!-- /wp:group -->

<!-- wp:spacer {"height":"var(\u002d\u002dwp\u002d\u002dpreset\u002d\u002dspacing\u002d\u002d80)"} -->
<div style="height:var(--wp--preset--spacing--80)" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->
<!-- /wp:group --></div>
<!-- /wp:group -->
7 changes: 7 additions & 0 deletions parts/mobile-menu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"textColor":"black","style":{"spacing":{"padding":{"left":"var:preset|spacing|30","right":"var:preset|spacing|30","top":"0","bottom":"0"}},"color":{"background":"#ffffff00"}},"className":"mobile-menu-toggle"} -->
<div class="wp-block-button mobile-menu-toggle"><a class="wp-block-button__link has-black-color has-text-color has-background wp-element-button" href="#" style="background-color:#ffffff00;padding-top:0;padding-right:var(--wp--preset--spacing--30);padding-bottom:0;padding-left:var(--wp--preset--spacing--30)"><span>Menu</span></a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

<!-- wp:template-part {"slug":"mobile-sidebar","theme":"newspack-block-theme","tagName":"div","className":"mobile-sidebar"} /-->
36 changes: 29 additions & 7 deletions parts/mobile-sidebar.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
<!-- wp:group {"layout":{"type":"default"}} -->
<div class="wp-block-group"><!-- wp:buttons {"layout":{"type":"flex","justifyContent":"right"}} -->
<div class="wp-block-buttons"><!-- wp:button {"className":"mobile-menu-toggle"} -->
<div class="wp-block-button mobile-menu-toggle"><a class="wp-block-button__link wp-element-button" href="#">Close</a></div>
<!-- wp:group {"backgroundColor":"contrast","textColor":"base"} -->
<div class="wp-block-group has-base-color has-contrast-background-color has-text-color has-background"><!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"color":{"background":"#00000000"},"spacing":{"padding":{"left":"var:preset|spacing|30","right":"var:preset|spacing|30","top":"0","bottom":"0"}}},"className":"mobile-menu-toggle"} -->
<div class="wp-block-button mobile-menu-toggle"><a class="wp-block-button__link has-background wp-element-button" href="#" style="background-color:#00000000;padding-top:0;padding-right:var(--wp--preset--spacing--30);padding-bottom:0;padding-left:var(--wp--preset--spacing--30)"><span>Close</span></a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->

<!-- wp:paragraph -->
<p>Add mobile menu content here.</p>
<!-- /wp:paragraph --></div>
<!-- wp:search {"label":"","placeholder":"Search...","buttonText":"Search","buttonPosition":"button-inside","buttonUseIcon":true} /-->

<!-- wp:separator {"backgroundColor":"tertiary"} -->
<hr class="wp-block-separator has-text-color has-tertiary-color has-alpha-channel-opacity has-tertiary-background-color has-background"/>
<!-- /wp:separator -->

<!-- wp:separator -->
<hr class="wp-block-separator has-alpha-channel-opacity"/>
<!-- /wp:separator -->

<!-- wp:navigation {"ref":146,"openSubmenusOnClick":true,"overlayMenu":"never","layout":{"type":"flex","setCascadingProperties":true,"orientation":"vertical"},"style":{"spacing":{"margin":{"top":"0"}}}} /-->

<!-- wp:separator {"backgroundColor":"tertiary"} -->
<hr class="wp-block-separator has-text-color has-tertiary-color has-alpha-channel-opacity has-tertiary-background-color has-background"/>
<!-- /wp:separator -->

<!-- wp:social-links {"iconBackgroundColor":"tertiary","iconBackgroundColorValue":"#757575"} -->
<ul class="wp-block-social-links has-icon-background-color"><!-- wp:social-link {"url":"#","service":"facebook"} /-->

<!-- wp:social-link {"url":"#","service":"instagram"} /-->

<!-- wp:social-link {"url":"#","service":"twitter"} /-->

<!-- wp:social-link {"url":"#","service":"youtube"} /--></ul>
<!-- /wp:social-links --></div>
<!-- /wp:group -->
3 changes: 3 additions & 0 deletions src/images/close.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/images/menu.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 39 additions & 8 deletions src/scss/_header.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use 'sass-utils';

/**
* Mobile Header and Menu proof of concept
* Mobile Header and Menu
*/
.desktop-header {
display: none;
Expand All @@ -19,13 +19,23 @@

.mobile-sidebar {
background: var( --wp--custom--background--mobile-menu );
color: var( --wp--custom--color--mobile-menu );
inset: 0 -100% 0 auto;
opacity: 0;
overflow: auto;
padding: 2rem;
padding: var(--wp--preset--spacing--50) var(--wp--preset--spacing--40);
position: fixed;
transition: right 0.2s;
width: 90%;
transition: opacity 0.2s;
width: 100%;
z-index: 999999;

> * {
visibility: hidden;
}

a {
color: inherit;
}
}

@include sass-utils.media( medium ) {
Expand All @@ -34,10 +44,6 @@
}
}

.mobile-sidebar > * {
visibility: hidden;
}

.overlay-mask {
background: var( --wp--custom--background--mobile-menu-overlay );
content: '';
Expand All @@ -48,6 +54,7 @@
}

.menu-open--mobile-menu .mobile-sidebar {
opacity: 1;
right: 0;
}

Expand All @@ -58,3 +65,27 @@
.menu-open--mobile-menu .overlay-mask {
display: block;
}

.mobile-menu-toggle {
span {
display: inline-block;
text-indent: -99999em;
}

.wp-block-button__link::after {
background-color: currentcolor;
content: "";
display: inline-block;
height: 14px;
mask: url("../../src/images/menu.svg") 0 0 no-repeat;
mask-size: 14px;
width: 14px;
}
}

.mobile-sidebar .mobile-menu-toggle {
.wp-block-button__link::after {
mask: url("../../src/images/close.svg") 0 0 no-repeat;
}
}

19 changes: 15 additions & 4 deletions theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@
"useRootPaddingAwareAlignments": true,
"custom": {
"background": {
"mobile-menu": "var( --wp--preset--color--white )",
"mobile-menu": "#1E1E1E",
"mobile-menu-overlay": "rgba( 0, 0, 0, 0.5 )"
},
"color": {
"mobile-menu": "var( --wp--preset--color--white )"
},
"line-height": {
"x-small": "1.5",
"small": "1.5",
Expand Down Expand Up @@ -330,6 +333,14 @@
"text": "var(--wp--preset--color--contrast)"
}
},
"core/social-links": {
"spacing": {
"blockGap": {
"left": "var(--wp--preset--spacing--20)",
"top": "var(--wp--preset--spacing--20)"
}
}
},
"core/site-tagline": {
"typography": {
"fontSize": "var(--wp--preset--font-size--small)"
Expand Down Expand Up @@ -372,7 +383,7 @@
"text": "var(--wp--preset--color--base)"
},
"outline": {
"color": "var(--wp--preset--color--primary)",
"color": "currentcolor",
"offset": "2px",
"style": "dotted",
"width": "1px"
Expand Down Expand Up @@ -464,8 +475,8 @@
"blockGap": "1.5rem",
"padding": {
"bottom": "var(--wp--preset--spacing--50)",
"left": "var(--wp--preset--spacing--50)",
"right": "var(--wp--preset--spacing--50)",
"left": "var(--wp--preset--spacing--40)",
"right": "var(--wp--preset--spacing--40)",
"top": "0"
}
},
Expand Down