canonical / vanilla-framework

From community websites to web applications, this CSS framework will help you achieve a consistent look and feel.
https://vanillaframework.io
GNU Lesser General Public License v3.0
825 stars 166 forks source link

Improve alignment of top navigation items with grid #4898

Open bartaz opened 11 months ago

bartaz commented 11 months ago

Context

Padding in top navigation items is different from padding on the grid. We want text of first item of top navigation to align with the content on the page below it. Hoverbox of the item should stick outside of the grid (text is aligned, but navigation items actually expands to the left).

Currently, because padding on item and grid are different they would misalign like this (if we align navigation with outside margin of the grid:

image

Or like this (if we align both using same grid padding):

image

Visual

On canonical.com it's hacked with some undocumented usage of grid in top navigation and negative margin:

image

We want to achieve this in docs layout as well (currently local styles):

image

We need to update the top navigation to improve the alignment with the grid below it, while making sure it still works on small screens and doesn't affect older websites that may still use old layout.

lyubomir-popov commented 11 months ago

Maybe we can modify the hover/active state to not use padding-left: image (Just a thought, we need to discuss this in the Design team)

bartaz commented 11 months ago

Another (relatively simple to implement) solution could be to increase hover area padding to 1.5rem (making it the same as grid margin) so that it aligns naturaly:

image

Although it does create 3rem space between unselected navigation items making it probably wider than needed (and may make some sites not fit their navigation - although we did increase the grid width in 4.0 so we have more space there).

lyubomir-popov commented 11 months ago

THat works for me. We've increased the fixed width fro m72 to 80 rem, which should compensate. Happy to go with that but we need to test maas and other sites with large numbers of menu items

bartaz commented 8 months ago

In JIRA as: WD-8284