Skip to content

Commit

Permalink
[MWPW-159667] - Add dark mode fixes (#3285)
Browse files Browse the repository at this point in the history
* dark mode changes

* lint-fix

* small fix for animation

* Fix spacing and dark mode things for localnav

* Set page overlay for local nav

* Added some pending fix for keyboard navigation

* Added some pending fix for keyboard navigation

* Added some pending fix for keyboard navigation
  • Loading branch information
Deva309 authored and bandana147 committed Jan 14, 2025
1 parent 2dd5cc1 commit fe7994f
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 60 deletions.
9 changes: 9 additions & 0 deletions libs/blocks/global-navigation/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@
--feds-background-footer: #fafafa;
--feds-borderColor-featuredProducts: #999;
--feds-gutter-footer: 32px;

/* mobile gnav redesign */
--feds-color-white-v2: #fff;
--feds-color-black-v2: #000;
--feds-background-cloudmenu-v2: #111;
--feds-borderColor-link-v2: #eaeaea;
--feds-backgroundColor-tabs-v2: #f8f8f8;
--feds-backgroundColor-tabContent-v2: #f3f3f3;
--feds-borderColor-localnav-v2: #eee;
}

/* Nav Link styles */
Expand Down
42 changes: 42 additions & 0 deletions libs/blocks/global-navigation/dark-nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
--feds-color-profile--dark: #dbdbdb;
--feds-color-profile--emphasis--dark: #f2f2f2;
--feds-border-profile--dark: 1px solid var(--feds-borderColor);

/* mobile gnav redesign */
--feds-borderColor-link-v2: #323232;
--feds-borderColor-localnav-v2: #323232;
}

.feds--dark .feds-navLink--hoverCaret:hover,
Expand Down Expand Up @@ -84,6 +88,44 @@
color: var(--feds-color-link--dark);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .top-bar {
background-color: var(--feds-background-nav--desktop);
border-bottom: 1px solid var(--feds-background-nav--desktop);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .title {
background-color: var(--background-color);
border-bottom: 1px solid var(--feds-borderColor-link-v2);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .tabs {
background-color: var(--background-color);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .tab-content {
background-color: var(--background-color);
border-left: 1px solid var(--feds-borderColor-link-v2);
}

[dir = "rtl"] header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .tab-content {
border-left: none;
border-right: 1px solid var(--feds-borderColor-link-v2);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .tabs button {
color: var(--text-color);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .tabs button[aria-selected="true"] {
color: var(--background-color);
background-color: var(--feds-borderColor-navLink);
}

header.new-nav.feds--dark .feds-nav > section.feds-navItem > .feds-popup .sticky-cta {
background-color: var(--background-color);
border-top: 1px solid var(--feds-borderColor-link-v2);
}

/* Popup */
.feds--dark .feds-popup {
background-color: #151515;
Expand Down
101 changes: 54 additions & 47 deletions libs/blocks/global-navigation/global-navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,12 @@ header.new-nav.local-nav .feds-curtain--open {

header.new-nav .feds-nav-wrapper {
width: 100%;
background-color: black;
background-color: var(--feds-background-cloudmenu-v2);
translate: -200vw 0;
opacity: 0;
transition: translate 0.4s ease-out, opacity 0.4s ease;
transition: translate 0.4s ease-out, opacity 0.4s ease, visibility 0s linear 0.5s;
display: flex;
visibility: hidden;
}

[dir = "rtl"] header.new-nav .feds-nav-wrapper {
Expand All @@ -783,6 +784,8 @@ header.new-nav .feds-nav-wrapper--expanded {
translate: 0;
opacity: 1;
z-index: 2;
transition: translate 0.4s ease-out, opacity 0.4s ease, visibility 0s linear 0s;
visibility: visible;
}

[dir = "rtl"] header.new-nav .feds-nav-wrapper--expanded {
Expand All @@ -795,11 +798,11 @@ header.new-nav .feds-nav-wrapper--expanded .feds-nav > section.feds-navItem:firs

header.new-nav .feds-nav-wrapper--expanded .feds-nav > .feds-navItem.feds-navItem--mobile-only:last-of-type {
margin-bottom: 10px;
border-bottom: 2px solid #fff;
border-bottom: 2px solid var(--feds-color-white-v2);
}

header.new-nav .feds-nav-wrapper--expanded .feds-nav > section.feds-navItem > button.feds-navLink {
color: white;
color: var(--feds-color-white-v2);
font-size: 20px;
font-weight: 400;
line-height: 25px;
Expand Down Expand Up @@ -834,8 +837,9 @@ header.new-nav .feds-nav > section.feds-navItem > button.feds-navLink::after {
width: 9.271px;
height: 9.179px;
transform: rotate(-45deg);
border-color: white;
border-color: var(--feds-color-white-v2);
right: 20px;
top: calc(50% - 4px);
}

[dir = "rtl"] header.new-nav .feds-nav > section.feds-navItem > button.feds-navLink::after {
Expand All @@ -848,7 +852,7 @@ header.new-nav .feds-nav > .feds-navItem > a.feds-navLink {
border-bottom: 1px solid #2c2c2c;
padding: 20px;
font-size: 20px;
color: white;
color: var(--feds-color-white-v2);
}

/*
Expand All @@ -858,20 +862,12 @@ header.new-nav .feds-nav > .feds-navItem > a.feds-navLink {
header.new-nav .feds-nav > section.feds-navItem > .feds-popup {
position: fixed;
top: calc(-1 * var(--feds-height-nav));
visibility: visible;
visibility: hidden;
width: 100%;
height: calc(var(--feds-height-nav) + 100%);
background-color: var(--feds-background-nav);
/*animation: totheleft 0.3s ease-out, fadeout 0.3s ease;*/
/* we need to use transitions instead to avoid an issue on
* adobe home wherein if we click on the hamburger icon
* right after loading in, we see some feds-popups appear on the
* screen and fadeaway
*/
transition: translate 0.4s ease-out, opacity 0.2s ease;
transition: translate 0.4s ease-out, opacity 0.2s ease, visibility 0s linear 0.5s;
translate: 300vw 0;
/* animation-fill-mode: forwards; */

display: grid;
grid-template-rows: 56px max-content auto 80px;
grid-template-columns: 120px 1fr;
Expand All @@ -890,10 +886,16 @@ header.new-nav.local-nav .feds-nav > section.feds-navItem > .feds-popup {
translate: 0;
}

header.new-nav .feds-nav > section.feds-navItem.feds-dropdown--active::before {
width: 0;
}

header.new-nav .feds-nav > section.feds-navItem.feds-dropdown--active > .feds-popup {
translate: 0;
opacity: 1;
z-index: 2;
transition: translate 0.4s ease-out, opacity 0.2s ease, visibility 0s linear 0s;
visibility: visible;
}

[dir = "rtl"] header.new-nav .feds-nav > section.feds-navItem.feds-dropdown--active > .feds-popup {
Expand All @@ -905,10 +907,14 @@ header.new-nav .feds-nav > section.feds-navItem > .feds-popup .top-bar {
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1px solid #EAEAEA;
border-bottom: 1px solid var(--feds-borderColor-link-v2);
padding: 0 20px;
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .top-bar .feds-brand {
padding-left: 0;
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .top-bar .close-icon {
width:14px;
height:14px;
Expand Down Expand Up @@ -937,7 +943,7 @@ header.new-nav .feds-nav > section.feds-navItem > .feds-popup .title {
grid-area: title;
display: flex;
flex-direction: column;
border-bottom: 1px solid #EAEAEA;
border-bottom: 1px solid var(--feds-borderColor-link-v2);
padding: 0 20px;
}
header.new-nav .feds-nav > section.feds-navItem > .feds-popup .title .breadcrumbs {
Expand All @@ -958,6 +964,7 @@ header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tabs {
display: flex;
flex-direction: column;
padding-top: 16px;
background-color: var(--feds-backgroundColor-tabs-v2);
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tabs button {
Expand All @@ -971,19 +978,25 @@ header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tabs button {
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tabs button[aria-selected="true"] {
background-color: black;
color: white;
background-color: var(--feds-color-black-v2);
color: var(--feds-color-white-v2);
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tab-content {
background-color: #f3f3f3;
background-color: var(--feds-backgroundColor-tabContent-v2);
padding: 10px 13px 25px;
display: flex;
flex-direction: column;
gap: 28px;
font-size:14px;
line-height: 16px;
overflow-y: scroll;
border-left: 1px solid var(--feds-borderColor-link-v2);
}

[dir = "rtl"] header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tab-content {
border-left: none;
border-right: 1px solid var(--feds-borderColor-link-v2);
}

header.new-nav .feds-nav > section.feds-navItem > .feds-popup .tab-content a {
Expand All @@ -1010,8 +1023,9 @@ header.new-nav .feds-nav > section.feds-navItem > .feds-popup .sticky-cta {
display: flex;
align-items: center;
justify-content: center;
width: 100%;;
width: 100%;
position:sticky;
border-top: 1px solid var(--feds-borderColor-link-v2);
}

header.new-nav .feds-nav > section.feds-navItem.feds-dropdown--active > .feds-popup .sticky-cta a {
Expand All @@ -1028,7 +1042,7 @@ header.new-nav .feds-navItem--section {
}

header.new-nav .feds-breadcrumbs {
padding: 10px 0;
padding: 2px 0 0;
}

header.new-nav .feds-breadcrumbs ul {
Expand Down Expand Up @@ -1069,14 +1083,17 @@ header + .feds-localnav {
border: 0;
padding: 0 20px;
text-align: justify;
border-top: 1px solid #eee;
border-bottom: 1px solid #eee;
background-color: #F8F8F8;
color: var(--text-color);
cursor: pointer;
border-top: 1px solid var(--feds-borderColor-localnav-v2);
border-bottom: 1px solid var(--feds-borderColor-localnav-v2);
background-color: var(--feds-background-nav);
}

.feds-localnav-items {
background: #F3F3F3;
border-bottom: 1px solid #eee;
padding: 20px 0 24px;
background: var(--feds-background-popup);
border-bottom: 1px solid var(--feds-borderColor-localnav-v2);
display: none;
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
}
Expand Down Expand Up @@ -1120,18 +1137,18 @@ header + .feds-localnav {
border-bottom: 0;
font-size: 14px;
padding: 12px 20px;
background: #F3F3F3;
background: var(--feds-background-popup);
}

.feds-localnav .feds-localnav-items .feds-menu-headline {
background: #F3F3F3;
background: var(--feds-background-popup);
font-weight: 400;
border-bottom: 0;
padding: 12px 38px;
}

.feds-localnav .feds-localnav-items .feds-navItem--centered {
padding: 12px 20px;
padding: 10px 20px;
}

.feds-localnav .feds-dropdown--active::before {
Expand All @@ -1142,22 +1159,12 @@ header + .feds-localnav {
transform: rotateZ(-135deg);
}

@keyframes fromtheleft {
from {
translate: -200vw 0;
}
to {
translate: 0 0;
}
}

@keyframes totheleft {
from {
translate: 0 0;
}
to {
translate: -200vw 0;
}
.feds-localnav.active .feds-localnav-curtain {
width: 100%;
height: 100vh;
position: absolute;
background: var(--feds-color-black-v2);
opacity: 0.7;
}

@keyframes slideright {
Expand Down
13 changes: 10 additions & 3 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class Gnav {
localNav = toFragment`<div class="feds-localnav"/>`;
this.block.after(localNav);
}
localNav.append(toFragment`<button class="feds-navLink--hoverCaret feds-localnav-title"></button>`, toFragment` <div class="feds-localnav-items"></div>`);
localNav.append(toFragment`<button class="feds-navLink--hoverCaret feds-localnav-title"></button>`, toFragment` <div class="feds-localnav-curtain"></div>`, toFragment` <div class="feds-localnav-items"></div>`);

const itemWrapper = localNav.querySelector('.feds-localnav-items');
const titleLabel = await replaceKey('overview', getFedsPlaceholderConfig());
Expand Down Expand Up @@ -984,15 +984,22 @@ class Gnav {
const activeModifier = itemHasActiveLink ? ` ${selectors.activeNavItem.slice(1)}` : '';

const makeTabActive = (popup) => {
if (!popup?.querySelector('.tabs [aria-selected="true"]')) {
const selectedTab = popup?.querySelector('.tabs [aria-selected="true"]');
if (!selectedTab) {
const { origin, pathname } = window.location;
const url = `${origin}${pathname}`;
setTimeout(() => {
const activeLink = [
...popup.querySelectorAll('a:not([data-modal-hash])'),
].find((el) => (el.href === url || el.href.startsWith(`${url}?`) || el.href.startsWith(`${url}#`)));
const tabIndex = activeLink ? +activeLink.parentNode.id : 0;
popup.querySelectorAll('.tab')[tabIndex]?.click();
const selectTab = popup.querySelectorAll('.tab')[tabIndex];
selectTab?.click();
selectTab?.focus();
}, 100);
} else {
setTimeout(() => {
selectedTab.focus();
}, 100);
}
};
Expand Down
6 changes: 5 additions & 1 deletion libs/blocks/global-navigation/utilities/keyboard/mainNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ class MainNavItem {
case 'Escape': {
closeAllDropdowns();
const activePopup = document.querySelector(selectors.activePopup);
if (newNav && !activePopup) document.querySelector('header.new-nav .feds-toggle').click();
if (newNav && !activePopup) {
const toggle = document.querySelector('header.new-nav .feds-toggle');
toggle?.click();
toggle?.focus();
}
break;
}
case 'ArrowLeft': {
Expand Down
Loading

0 comments on commit fe7994f

Please sign in to comment.