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

Closed
wants to merge 4 commits into 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!

media/css/firefox/features/article.scss Outdated Show resolved Hide resolved
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?

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 don't quite understand why the main nav needs to be changed? Could you further elaborate on that?

I'll post more info to the original issue #14081 to explain it a bit more, but just quickly following up your investigation from #14081 (comment):

I think I came to understand that the reason there's considered to be a misalignment is actually because the Breadcrumb component is aligned similarly to the subnav that we have. Now the question is, do we want to:

  1. Change the alignments of both subnav and Breadcrumb component to align better with the main nav of the site
  2. Only change the Breadcrumb component alignment
  3. Keep things as is

Or there is 4.: Keep breadcrumbs and subnav aligned to mzp-l-content as it is now, but overcome the perception of these being misaligned in comparison to the main nav by actually tweaking some mq breakpoint styling of the nav instead, bc it's the main masthead that doesn't match mzp-l-content alignment in a handful of breakpoints. But I'll explain that a tad better with videos & examples so I'll keep you posted there…

TL;DR 3.) is out of the equation and mozilla/protocol#933 needs fixing anyways, so 2.) will happen upstream mozilla/protocol#938; 1.) was this PR and I don't like the result, so I will see about 4.) eventually, probably again in Protocol itself, but that's a separate issue then.

@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 182 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 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:

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?

@@ -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.

Copy link
Contributor Author

@janbrasna janbrasna Jun 20, 2024

Choose a reason for hiding this comment

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

@stephaniehobson Exactly, i'll most likely abandon all the changes here and start with the most important fix straight upstream mozilla/protocol#938


Reasoning: ↑ #14413 (comment):

I don't quite understand why the main nav needs to be changed? Could you further elaborate on that?

I'll post more info to the original issue #14081 to explain it a bit more, but just quickly following up your investigation from #14081 (comment):

I think I came to understand that the reason there's considered to be a misalignment is actually because the Breadcrumb component is aligned similarly to the subnav that we have. Now the question is, do we want to:

  1. Change the alignments of both subnav and Breadcrumb component to align better with the main nav of the site
  2. Only change the Breadcrumb component alignment
  3. Keep things as is

Or there is 4.: Keep breadcrumbs and subnav aligned to mzp-l-content as it is now, but overcome the perception of these being misaligned in comparison to the main nav by actually tweaking some mq breakpoint styling of the nav instead, bc it's the main masthead that doesn't match mzp-l-content alignment in a handful of breakpoints. But I'll explain that a tad better with videos & examples so I'll keep you posted there…

TL;DR 3.) is out of the equation and mozilla/protocol#933 needs fixing anyways, so 2.) will happen upstream mozilla/protocol#938; 1.) was this PR and I don't like the result, so I will see about 4.) eventually, probably again in Protocol itself, but that's a separate issue then.

TL;DR² … 2.) will hapen upstream, and we'll see about 4.) after nav redesign later.

@alexgibson alexgibson added the Frontend HTML, CSS, JS... client side stuff label Jun 24, 2024
@janbrasna janbrasna closed this Jul 18, 2024
@janbrasna janbrasna deleted the fix/features-breadcrumbs branch July 18, 2024 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend HTML, CSS, JS... client side stuff
4 participants