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

Improve subnav & breadcrumb alignment #14413

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

janbrasna
Copy link
Contributor

@janbrasna janbrasna commented Apr 4, 2024

One-line summary

Improves the default breadcrumb styling and adjusts subnav to better align all the navigation components.

Significant changes and points to review

TL;DR: The subnav & breadcrumbs were aligned as part of the content, not matching the nav masthead above. This aims to reset the content-like styling for these additional nav components, and apply the same layout as the main nav above them.

WIP

not sure i like the looks of "aligned with nav" now on various pages, where the alignment with content underneath looked probably better? 🤷
— feel free to browse around locally, i've picked some good examples below in "testing", where are some nice examples of different content alignment, and how that interacts with the repositioned subnav…

  • monkey-patched breadcrumb overrides to _sub-navigation.scss as it's compiled into base everywhere important
    • (b/c breadcrumbs are included w/o any styling, implying default protocol, so to override this a "cheap" place ideally loaded everywhere is needed; this just avoids adding a new component and including it in a dozen places…)
  • BTW changes VPN breadcrumbs colour for contrast with subnav

Issue / Bugzilla link

Fixes #14081
Fixes #13462
Supersedes #14253

Testing

http://localhost:8000/en-US/firefox/features/private/
http://localhost:8000/en-US/firefox/new/
http://localhost:8000/en-US/firefox/enterprise/
http://localhost:8000/en-US/firefox/channel/desktop/
http://localhost:8000/en-US/products/vpn/
http://localhost:8000/en-US/products/vpn/resource-center/is-a-vpn-safe/

@reemhamz
Copy link
Contributor

Hello! I reviewed the PR and have some comments and suggestions, however before I officially write them up, I've posed a question on the issue ticket to help clarify some things before we continue with this change :)

@janbrasna
Copy link
Contributor Author

janbrasna commented Apr 15, 2024

This ought to be fixed globally, together with similar spacing improvements in subnav. The alignment jumps badly between M, L, XL viewports.

@janbrasna janbrasna marked this pull request as draft April 17, 2024 05:40
Copy link
Contributor

@reemhamz reemhamz left a comment

Choose a reason for hiding this comment

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

Nice work on this!

As Alex said in the issue, this seems to be a fix for Bedrock because the subnav isn't backported into Protocol
I've left a few comments that need to be addressed. I also have a strong suggestion:

Since this Breadcrumbs component is used in different pages, and will be used in other pages in the future, we should make it into a CSS bundle that can easily be imported to other pages using this component, especially because we now have some new CSS that needs to align with the website's main nav.

Here's more information on how it works: https://bedrock.readthedocs.io/en/latest/coding.html#id2

  1. So, we could move this Breadcrumb-specific CSS into its own file here: https://github.com/mozilla/bedrock/tree/main/media/css/protocol/components -- make sure to import the following as well:
@import '~@mozilla-protocol/core/protocol/css/includes/lib';
@import '~@mozilla-protocol/core/protocol/css/components/breadcrumb';
  1. Then create a CSS bundle for the component in static-bundles.json (make sure to restart your server after doing this so the file updates)

  2. Import the CSS bundle in the HTML pages using the component

  3. You can now remove @import '~@mozilla-protocol/core/protocol/css/components/breadcrumb'; from relative CSS files

Let me know if you need any help with this!

padding-bottom: $spacing-md;

.mzp-c-breadcrumb-item a {
color: inherit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: By changing the color of the link, it doesn't make it obvious that it's a link a user can interact with anymore, so it's best to remove this declaration to not make it become an accessibility issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @reemhamz but I can't take any credit for this 😇 it's just repurposing the code @nathan-barrett originally wrote for stories/articles, and I didn't want it to disappear in git history now that the content is gone;)

But you're right, the styling should be more generic, and also cover all the occurrences of the breadcrumbs (VPN articles is a good example where the bad alignment shows best) so I'm backing out of this local change, and starting over together with fixes to subnav, basically treating the subnav+breadcrumbs containers as close as possible to the masthead, not the content defaults they inherit.

Thanks for the hand-holding, I really appreciate it! Sure I've read about the bundles needing restarts but have forgotten about it since;) so better to get reminded a few times than scratching my head why can't get it loaded;)

I'm trying to improve things that I feel comfortable with, either from what I can infer from some historic patterns, or current epics — as not to bother anyone else too much, having pretty good idea what all you have to juggle… — so you can focus on what needs to be done, and I'm toying with random cosmetic stuff that I can either reliably resolve, or bail out fast if any broader involvement is needed. So I'll try to do my best to only bring up important decisions, not bothering you with me tripping over things, that's for me to figure out… (let's call it a learning curve, one pebble at a time, right?)

I'll see if I can apply fixes without introducing any new bundles (as subnav is included everywhere important, in base; and historically breadcrumbs never needed any custom styles so I'd be awkward for everyone to get used to including a bundle for them everywhere now…) and once the layout is something folks would like to see happening, we can find the best place where to keep the patches.

media/css/firefox/features/article.scss Outdated Show resolved Hide resolved
Comment on lines 13 to 14
padding-top: $spacing-md;
padding-bottom: $spacing-md;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: This change would probably be better placed in the actual Protocol design system rather than it just being in Bedrock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've come to understand that any updates regarding nav (and breadcrumbs) in Protocol are now paused in expectations of a bigger redesign coming up, so probably if something of this is supposed to end up upstream, it's gonna be in the next design language anyways — and so with the nav due redesigning in a few months, I see this whole improvement as a tentative fix nonetheless, to be completely replaced with something more systematic, come summer(?)

For now I've managed to align the subnav & breadcrumbs perfectly to the main menu. But not sure I really love the outcome on some pages. 🤷

I also don't fancy the way I've patched up the overrides to implicit breadcrumb protocol styles here locally to with subnav 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@reemhamz Maybe the whole fix should be upstream mozilla/protocol#933 after all — the ideal combo might be: subnav stays, only breadcrumbs get fixed (e.g. main...8390523 but upstream instead), and what needs to change to better align with the rest is the main nav, not the other subnav elements (which are properly aligned to content in all breakpoints; it's the masthead that gets narrower sometimes…)

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at your changes, I actually agree that the breadcrumb component should get fixed upstream in Protocol rather than have it override itself within Bedrock. However, I don't quite understand why the main nav needs to be changed? Could you further elaborate on that?

@alexgibson
Copy link
Member

alexgibson commented Apr 17, 2024

Since this Breadcrumbs component is used in different pages, and will be used in other pages in the future, we should make it into a CSS bundle that can easily be imported to other pages using this component, especially because we now have some new CSS that needs to align with the website's main nav.

Since so many pages use a sub nav, I wonder if it might actually be easier to add these styles to the main Protocol base stylesheet, so they are kept along with the main nav styles? That might make for easier maintenance and saves on an HTTP request. Just a thought though, I’ll leave it up to you both to decide what’s best.

@janbrasna
Copy link
Contributor Author

@alexgibson Yup I'm looking into this, basically since this will be touching the subnav that lives in css/protocol/components/_sub-navigation anyways I'll try to accommodate the breadcrumb "local adjustments" in similar fashion, it shouldn't be more than a few lines. If you have a good place in mind (existing file, or a preference to create a new component), I'm open to suggestions. I'm not monkey-patching the .c-breadcrumbs to the bottom of .c-menu or .c-navigation without prior approval ;D

@alexgibson
Copy link
Member

alexgibson commented Apr 17, 2024

If it's only a few lines of CSS then perhaps adding it to css/protocol/components/_sub-navigation makes sense, but I'm open to @reemhamz's idea here as well, as this was just a passing thought.

@reemhamz
Copy link
Contributor

That can also work @alexgibson! I see the benefit of saving on HTTP requests + it's one less step for developers needing to implement the Breadcrumb component on a page 👍🏼

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.44%. Comparing base (929ad7d) to head (a647961).
Report is 50 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14413      +/-   ##
==========================================
- Coverage   76.56%   76.44%   -0.12%     
==========================================
  Files         143      148       +5     
  Lines        7803     7977     +174     
==========================================
+ Hits         5974     6098     +124     
- Misses       1829     1879      +50     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@janbrasna janbrasna changed the title Improve firefox/features breadcrumbs Improve subnav & breadcrumb alignment Apr 19, 2024
@reemhamz reemhamz removed the Needs Review Awaiting code review label Apr 22, 2024
Copy link
Contributor Author

@janbrasna janbrasna left a comment

Choose a reason for hiding this comment

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

So now this aligns exactly to the main nav bar, and while that improves the look&feel for pages with narrow content (think fx features, vpn… where the issue was originally raised), it also shows why it was aligned to the main content below in the first place, the most prominent pages that are wide and start with logos and headings look IMO better with the original alignment that treats the subnavs more as a content — than this "improved" alignment, which moves with the logo and main nav, not the content — depending on viewport these two start to align differently.

I'm taking some time to think about it a bit more, feel free to testdrive it locally, you'll soon notice what I mean…

Some random thoughts:

// * -------------------------------------------------------------------------- */
// Overrides to align with subnav https://github.com/mozilla/bedrock/issues/14081

nav.mzp-c-breadcrumb {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

used nav selector here for specificity to override the defaults which is not ideal (as it can be really applied to anything), but other than that, only blocks full of !important are the other option?

Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, I believe it would make more sense to have these override style changes be a part of the Protocol component : )

Edit: Just viewed your comment above and looks like we agree

padding: 0 $layout-lg;
}

@media #{$mq-lg} {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is being repeated from _sub-nav above; if it's bothering i could make it a mixin so it's maintained only in one place?

@@ -82,6 +82,11 @@ $image-path: '/media/protocol/img';
color: #666;
}

#outer-wrapper .mzp-c-breadcrumb {
// when stacked with subnav of the same color this makes it stand out
background: none;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not really needed, but since i started playing with the subnavs in vpn i felt like the two layers of additional navigation need some sort of separation… wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this separation!

Copy link
Contributor

@reemhamz reemhamz left a comment

Choose a reason for hiding this comment

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

Your changes are pretty good! However, I'm on the fence of adding them in Bedrock, and I think they would be better suited to be an update on the Breadcrumb component in Protocol instead.

@@ -82,6 +82,11 @@ $image-path: '/media/protocol/img';
color: #666;
}

#outer-wrapper .mzp-c-breadcrumb {
// when stacked with subnav of the same color this makes it stand out
background: none;
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this separation!

Comment on lines 13 to 14
padding-top: $spacing-md;
padding-bottom: $spacing-md;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at your changes, I actually agree that the breadcrumb component should get fixed upstream in Protocol rather than have it override itself within Bedrock. However, I don't quite understand why the main nav needs to be changed? Could you further elaborate on that?

// * -------------------------------------------------------------------------- */
// Overrides to align with subnav https://github.com/mozilla/bedrock/issues/14081

nav.mzp-c-breadcrumb {
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, I believe it would make more sense to have these override style changes be a part of the Protocol component : )

Edit: Just viewed your comment above and looks like we agree

@@ -13,12 +13,22 @@
inset 0 10px 3px -10px rgba(29, 17, 51, 0.12);

.mzp-l-content {
padding-top: 0;
padding-bottom: $spacing-md;
max-width: none;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants