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

Skatepark: add the header #4354

Merged
merged 13 commits into from
Aug 11, 2021
Merged

Skatepark: add the header #4354

merged 13 commits into from
Aug 11, 2021

Conversation

jffng
Copy link
Contributor

@jffng jffng commented Aug 2, 2021

Changes proposed in this Pull Request:

This PR adds a header template part and styles per the design for Skatepark. It applies some ideas from the every-layout.dev book. It was pretty interesting to explore and grok the concept of truly flexible layouts not tied to breakpoints.

Looking at Skatepark's header design and the components involved, there are three states to consider:

A. Not wrapped B. Wrapped C. Wrapped w/ responsive navigation
Screen Shot 2021-08-03 at 12 32 10 PM Screen Shot 2021-08-03 at 12 32 03 PM Screen Shot 2021-08-03 at 12 31 54 PM

B is the interesting scenario. Before, I would have tried to write a media query that tells the header to break onto two lines at a specific pixel value. But this is not a great approach because we don't know for certain the content width / number of menu items, thus making it impossible to write a media query that solves for all the situations.

I could not get around using a media query for the navigation + social links, which I think is acceptable because the navigation block's responsive behavior is tied to the same media query.

The spacing needs some tightening to match the comps, but I wanted to get your feedback in the meantime.

Related issue(s):

#4313

@jffng jffng added the [Theme] Skatepark Automatically generated label for Skatepark. label Aug 2, 2021
@jffng jffng linked an issue Aug 3, 2021 that may be closed by this pull request
@jffng jffng marked this pull request as ready for review August 3, 2021 16:51
@jffng jffng requested review from a team and melchoyce and removed request for melchoyce August 3, 2021 16:51
@jffng jffng changed the title Create the scaffolding for header template part. Skatepark: add the header Aug 3, 2021

<!-- wp:group -->
<div class="wp-block-group nav-links"><!-- wp:navigation {"orientation":"horizontal","itemsJustification":"right","isResponsive":true,"style":{"typography":{"fontStyle":"normal","fontWeight":"900","textTransform":"uppercase"}},"fontSize":"small"} -->
<!-- wp:navigation-link {"label":"Home","type":"custom","url":"http://skateparkdev.local/","kind":"custom","isTopLevelLink":true} /-->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not suggesting we ship the theme with these links baked in, but I included them so it's maybe easier to test.

align-items: center;

&::after {
content: "Menu";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't translate this :(

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the lang attribute on the html tag to translate this? Something like:

html[lang="en-US"] {
	.nav-links {
		.wp-block-navigation__responsive-container-open {
			&::after {
				content: "Menu";
			}
		}
	}
}

I guess this would need to be added via a PHP template in an inline style.. Or is this horrible and hacky?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could add this line of CSS as inline inside functions.php and wrap the string around the PHP translation function directly, no need to target the lang attribute. It's not much better, but it's another option

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice ok! Well, we have options 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally there is an option in the nav block itself to provide this label next to the responsive hamburger. I wonder if it's planned

@MaggieCabrera
Copy link
Contributor

I love how this looks! And it's very simple, great job!

This is what I see:

Screenshot 2021-08-04 at 10 09 47

The social icons could have the same treatment as the footer block so that they align with the menu. In this particular case, I'd add a class to the block, since the users may want to re build the header or use another theme's and we don't want the css to break that.

This is what the footer is doing:

	.wp-block-social-links.is-style-logos-only {
		margin-left: calc( -1 * ( 8px + 0.25em ) );
	}

If either the navigation or the social links are not present, this happens. The scenario with no social links is worth considering.

Screenshot 2021-08-04 at 10 13 22

Screenshot 2021-08-04 at 10 15 13

And right now Skatepark doesn't support a site logo, should we add support for it, @melchoyce If so, should we copy Quadrat's behavior for it?

Copy link
Member

@mikachan mikachan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ace! Agree with @MaggieCabrera's comments. Looking good in all browsers and resolutions. I agree with needing to use the media query for the navigation and social links, I can't think of another way we could do this.

Comment on lines +6 to +10
> * { // Apply a stack layout (page 69 of the every-layout.dev PDF)
margin-top: 20px;
margin-bottom: 20px;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cool, I love the idea of styling the context rather than the element itself.

align-items: center;

&::after {
content: "Menu";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use the lang attribute on the html tag to translate this? Something like:

html[lang="en-US"] {
	.nav-links {
		.wp-block-navigation__responsive-container-open {
			&::after {
				content: "Menu";
			}
		}
	}
}

I guess this would need to be added via a PHP template in an inline style.. Or is this horrible and hacky?

@melchoyce
Copy link
Contributor

melchoyce commented Aug 4, 2021

Whoo 🎉

Minor notes:

  • The last icon in the social block has a right margin. Can we remove that margin for the last item in the menu?
  • The tagline's font-weight should be medium
  • Navigation items are missing some letter spacing (0.1em)

And right now Skatepark doesn't support a site logo, should we add support for it, @melchoyce If so, should we copy Quadrat's behavior for it?

Yes and yes, though I think I'll want to test once we have Quadrat's behavior in Skatepark.

@jffng jffng force-pushed the add/skatepark-header branch from dfe8214 to f3b4de4 Compare August 4, 2021 18:14
@@ -40,5 +40,13 @@ function skatepark_support() {
function skatepark_scripts() {
// Enqueue front-end styles.
wp_enqueue_style( 'skatepark-styles', get_stylesheet_directory_uri() . '/assets/theme.css', array( 'blockbase-ponyfill' ), wp_get_theme()->get( 'Version' ) );

// Allow the responsive menu label to be translated.
$menu_label_css = '
Copy link
Contributor Author

@jffng jffng Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very messy, which makes me think it should go in the block.

In the meantime, maybe it should live in blockbase.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but blockbase doesn't have the Menu text. I think this is probably planned for the navigation block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'm going to remove it from the theme for now and open an issue for it in Gutenberg.

@@ -381,7 +381,8 @@
},
"core/navigation": {
"typography": {
"fontSize": "var(--wp--preset--font-size--normal)"
"fontSize": "var(--wp--preset--font-size--normal)",
"letterSpacing": "0.05em"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@melchoyce I added the letter spacing for all navigation blocks — is that okay, or do you think it should be targeted to the navigation block in the header only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also 0.1em for letter spacing looked like a lot compared to the comps, so I used 0.05 but let me know if you think it should be 0.1em.

@jffng
Copy link
Contributor Author

jffng commented Aug 4, 2021

Thanks for the reviews and comments!

I made the following changes:

  • Removed right margin from social links
  • Changed the flex alignment to handle the case when either no menu or social links are present
  • Made it so the menu label can be translated
  • Added a placeholder for the site logo in the template.

I think this is ready for another review, be sure to test out adding a logo.

@MaggieCabrera
Copy link
Contributor

The logo has a few differences comparing to Quadrat:

Screenshot 2021-08-05 at 18 14 16

Screenshot 2021-08-05 at 18 14 07

Screenshot 2021-08-05 at 18 13 07

Screenshot 2021-08-05 at 18 13 00

@melchoyce
Copy link
Contributor

Can we swap out the menu icon for a slightly thicker, three-bar version?

image

And if possible, open the menu underneath instead of overlaying the header:

image

If that's not possible, we can keep as-is — just feels especially annoying to open the menu on the left side and then close it on the right. Also happy with us playing with this later in a new PR.

@jffng
Copy link
Contributor Author

jffng commented Aug 5, 2021

The logo has a few differences comparing to Quadrat:

@melchoyce any guidance on the position of the logo across viewports? The header on Quadrat is different so I wasn't sure how to handle.

And if possible, open the menu underneath instead of overlaying the header:

I think this will be tricky / I'm not sure if it's possible with the nav block currently. We can at least move the position of the close button within the modal so it's the same location as the open button.

@melchoyce
Copy link
Contributor

Would it work to display side-by-side on desktop, and stack on mobile?

image

@MaggieCabrera
Copy link
Contributor

Just adding that this also closes #4319 since I don't think we need a separate issue for that

@MaggieCabrera MaggieCabrera linked an issue Aug 9, 2021 that may be closed by this pull request
@jffng jffng force-pushed the add/skatepark-header branch from 9534e37 to e8ec881 Compare August 10, 2021 16:33
@jffng
Copy link
Contributor Author

jffng commented Aug 10, 2021

Would it work to display side-by-side on desktop, and stack on mobile?

I gave this a try. Unless there is a purely flex based approach that I am missing, I don't think it's worth it because it would require another group block and more media-query based CSS, which is very fragile when we open things to the site editor.

The tagline's font-weight should be medium

I opened a small change in Gutenberg to allow this so we don't have to add CSS for it and the user can customize it: WordPress/gutenberg#33983

I also removed the responsive menu label in favor of adding the ability to the nav block itself: WordPress/gutenberg#33985

Thoughts on bringing this in and iterating?

@jffng jffng requested a review from a team August 10, 2021 18:51
@mikachan
Copy link
Member

This is looking good for me in all browsers and resolutions. I've tested with and without both a logo and a menu.

Bringing this in and iterating sounds good to me.

Copy link
Contributor

@MaggieCabrera MaggieCabrera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on bringing this in and iterating. And I also agree that the menu label is best handled on the editor.

@jffng jffng merged commit 1cb8b71 into trunk Aug 11, 2021
@jffng jffng deleted the add/skatepark-header branch August 11, 2021 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Theme] Skatepark Automatically generated label for Skatepark.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skatepark: Navigation (if needed) Skatepark: Templates:Header template part (including mobile)
4 participants