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

[WNMGDS-2350] Fix background color of docs vertical nav on hover #2937

Merged
merged 2 commits into from
Feb 14, 2024

Conversation

zarahzachz
Copy link
Collaborator

WNMGDS-2350

I thought we needed to refactor our vertical nav CSS due to how complex the docs site CSS overrides were, but I was wrong and the solution turned out to be much simpler 🎉

  • Removed clever CSS in favor of redefining vertical nav token in docs site
  • Removed unnecessary util classes from docs header
  • Fixed :hover:focus state of hamburger icon

@zarahzachz zarahzachz requested a review from pwolfert February 14, 2024 16:48
<Button
className="ds-u-md-display--none ds-u-padding-left--0 ds-u-padding-right--1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removing ds-u-md-display--none from Button because the parent header is handling this logic

@@ -106,9 +106,9 @@ const SideNav = ({ location }: SideNavProps) => {
})}
>
<UsaBanner className="ds-u-display--block ds-u-md-display--none" />
<header className="c-navigation__header ds-u-md-display--block ds-u-md-display--none">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removing the ds-u-md-display--block class as the following ds-u-md-display--none cancels it out.

@@ -11,8 +11,13 @@
gap: $spacer-2;
padding: $spacer-2;

button {
> button {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

made the button selector more precise here with the >


&:hover,
&:focus:hover {
color: currentColor;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

noticed the 🍔 icon is illegible when :focus:hover is applied and fixed that

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, I never noticed that because I must have always tested it in touch-device mode

.ds-c-vertical-nav__label {
&:hover,
:visited:hover {
--vertical-nav-item__background-color--hover: color-mix(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

all the code in the :before styles seemed to be in an attempt to modify an existing color token to be something we don't have (adding an alpha to whatever the vert nav hover bg was).

css filters are expensive in terms of overall perf, so removing that was a boon to us. also using color-mix() to accomplish the transparency needs.

side-note: i don't really think we should be combining/modifying tokens for one-off implementation, and the best solution here was probably to update this to just rely on --color-primary-lightest. i tried that out, but the color was noticeably different than our current color and decided to be less aggressive with the change. maybe add this to the pile for things to review if we update the docs site?

Copy link
Contributor

Choose a reason for hiding this comment

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

Great analysis and solution! Very elegant

Sounds good to pile it onto future doc site changes 👍

@@ -133,42 +138,23 @@
}
}

.ds-c-vertical-nav__label {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved this rule outside of the desktop media query as the hover state should be available across viewport sizes

// Desktop
@media (min-width: $media-width-md) {
.c-navigation {
// Set it to a fixed width that is wide enough for most links so that it
// doesn't jump around when we open and close subsections.
width: 17rem;

.c-navigation__header {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

because the header doesn't appear on md+ sized viewports, this isn't needed

@zarahzachz zarahzachz added Type: Fixed Indicates an unexpected problem or unintended behavior Impacts: Documentation Indicates that this item relates to documentation labels Feb 14, 2024
Copy link
Contributor

@pwolfert pwolfert left a comment

Choose a reason for hiding this comment

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

Tested, and it looks good!

.ds-c-vertical-nav__label {
&:hover,
:visited:hover {
--vertical-nav-item__background-color--hover: color-mix(
Copy link
Contributor

Choose a reason for hiding this comment

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

Great analysis and solution! Very elegant

Sounds good to pile it onto future doc site changes 👍

@zarahzachz zarahzachz merged commit e01520a into main Feb 14, 2024
1 check passed
@zarahzachz zarahzachz deleted the WNMGDS-2350/refactor-vertical-nav-styles branch February 14, 2024 18:19
@pwolfert pwolfert added this to the 10.0.0-beta.1 milestone Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impacts: Documentation Indicates that this item relates to documentation Type: Fixed Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants