// Site navigation desktop layout // // The main layout for the website navigation, for a desktop // devices only. // // TODO: Needs harsh refactoring! // /* stylelint-disable selector-max-combinators, selector-max-compound-selectors, max-nesting-depth, a11y/no-display-none, order/properties-alphabetical-order, declaration-no-important, no-descending-specificity */ $absolute-navigation: true; $nav-link-padding-y: .6rem; $nav-link-padding-x: 2rem; $nav-link-padding-y-dropdown: .4rem; $nav-link-padding-x-dropdown: 1.5rem; $nav-links: ( 'color': $color-white, 'hover-color': $color-white, 'font-weight': 700, 'font-size': 1.6rem ); $nav-dropdown-links: ( 'color': $color-links, 'hover-color': $color-hover, 'font-weight': 400, 'font-size': 1.4rem ); $dropdown: ( 'background': $color-white, 'gap': 1rem, 'width': 22rem, 'border-radius': 4px ); $dropdown-toggle: ( 'background': transparent, 'border': none, 'border-radius': 50%, 'color': $color-white, 'size': auto, 'arrow-size': 1rem ); $dropdown-toggle-hover: ( 'background': $color-white, 'border': 1px solid $color-white, 'color': $color-links, ); $submenu-dropdown-toggle: ( 'background': transparent, 'border': none, 'border-radius': 0, 'color': $color-links, 'height': auto, 'width': 3rem, 'arrow-size': 1rem ); $submenu-dropdown-toggle-hover: ( 'background': $color-white, 'border': none, 'color': $color-links, ); @if $absolute-navigation == false { .nav-container { background-color: $color-background-nav-desktop; box-shadow: 0 0 10px rgba($color-dark, .1); position: relative; z-index: 222; } } @if $absolute-navigation == true { .nav-container { background-color: transparent; position: absolute; width: 100%; @media only screen and (min-width: $responsivenav) { // Main level links .nav-primary > ul > li > a, .nav-primary > ul > li > button { color: $color-white; position: relative; } .nav-primary > ul > li > a:focus, .nav-primary > ul > li > a:hover { color: $color-white; } } } } @media only screen and (min-width: $responsivenav) { .menu-item-has-children::before { content: ''; display: block; position: absolute; width: 0; height: 0; /* stylelint-disable */ border-color: transparent transparent $color-white; /* stylelint-enable */ border-style: solid; border-width: 0 5px 5px; left: 50%; bottom: -10px; transform: scale(0); margin-left: -20px; transform-origin: center bottom; transition: none; } .nav-primary > ul:first-of-type > .menu-item-has-children:focus::before, .nav-primary > ul:first-of-type > .menu-item-has-children:hover::before { transform: scale(1); transition: all .25s cubic-bezier(.19, 1, .22, 1); } .sub-menu { background: map-get($dropdown, 'background'); width: map-get($dropdown, 'width'); left: 0; z-index: -1; border-top-left-radius: map-get($dropdown, 'border-radius'); border-top-right-radius: map-get($dropdown, 'border-radius'); border-bottom-left-radius: map-get($dropdown, 'border-radius'); border-bottom-right-radius: map-get($dropdown, 'border-radius'); border-left: 1px solid rgba(0, 0, 0, .05); border-right: 1px solid rgba(0, 0, 0, .05); border-bottom: 1px solid rgba(0, 0, 0, .05); box-shadow: 0 25px 20px -10px rgba(5, 4, 25, .05); transition: opacity .25s cubic-bezier(.19, 1, .22, 1); // Hide by default visibility: hidden; opacity: 0; position: absolute; top: -9999px; a { line-height: 1.5; } } .nav-primary ul .sub-menu.toggled-on, .menu-item-has-children:focus > .sub-menu, .menu-item-has-children:hover > .sub-menu, .menu-item-has-children.hover-intent > .sub-menu { top: 100%; visibility: visible; opacity: 1; z-index: 1; transform: translateY(0%); } } @media only screen and (min-width: $responsivenav) { .nav-container { background: $color-background-nav-desktop; } @media only screen and (max-width: $responsivenav) { ul li:focus > ul, ul li:hover > ul { display: block; } } // Disable animations on IE10 + IE11 @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { // Enable hovers ul li:focus > ul, ul li:hover > ul { display: block; } } // Make sure mobile nav-toggle is hidden on desktop .nav-toggle { display: none; } // Start navigation .nav-primary { padding-top: 0; padding-bottom: 0; .menu-items { margin: 0; padding: 0; background: transparent; position: relative; display: flex; align-items: center; } // General menu items .menu-item { position: relative; margin: 0; // Main level > a { padding: $nav-link-padding-y $nav-link-padding-x; /* stylelint-disable */ color: map-get($nav-links, 'color'); font-size: map-get($nav-links, 'font-size'); font-weight: map-get($nav-links, 'font-weight'); /* stylelint-enable */ display: inline-flex; align-items: center; /* stylelint-disable */ min-height: map-get($dropdown-toggle, 'size'); /* stylelint-enable */ &.disabled { color: $color-disabled; } // Actions in menu items &:hover, &:focus, &:active, &.highlighted, &.current { color: map-get($nav-links, 'hover-color'); } } // Dropdowns .sub-menu { width: map-get($dropdown, 'width'); left: 5%; margin-left: 0; padding-bottom: .5rem; padding-top: .5rem; padding-left: 0; margin-top: map-get($dropdown, 'gap'); z-index: 999; li { float: none; width: map-get($dropdown, 'width'); padding: 0; } // All dropdowns in level 2 and after .sub-menu { top: 0; left: 100%; margin-left: 0; margin-top: -5px; } a { padding: $nav-link-padding-y-dropdown $nav-link-padding-x-dropdown; font-size: map-get($nav-dropdown-links, 'font-size'); /* stylelint-disable font-weight-notation */ font-weight: map-get($nav-dropdown-links, 'font-weight'); /* stylelint-enable font-weight-notation */ color: map-get($nav-dropdown-links, 'color'); display: flex; align-items: center; } a:hover, a:focus, a:active, a.highlighted { color: map-get($nav-dropdown-links, 'hover-color'); } .disabled { background: $color-white; color: $color-disabled; } } // Main level toggle arrow .dropdown-toggle { background-color: map-get($dropdown-toggle, 'background'); border: map-get($dropdown-toggle, 'border'); border-radius: map-get($dropdown-toggle, 'border-radius'); color: map-get($dropdown-toggle, 'color'); height: map-get($dropdown-toggle, 'height'); width: map-get($dropdown-toggle, 'width'); padding: 0; display: inline-flex; align-items: center; justify-content: center; svg { /* stylelint-disable no-descending-specificity */ transition: transform $transition-duration ease-in; width: map-get($dropdown-toggle, 'arrow-size'); height: map-get($dropdown-toggle, 'arrow-size'); /* stylelint-enable */ } &.toggled-on svg { transform: rotateX(180deg); } } // Sub-level toggle arrow ul li .dropdown-toggle { background-color: map-get($submenu-dropdown-toggle, 'background'); border: map-get($submenu-dropdown-toggle, 'border'); border-radius: map-get($submenu-dropdown-toggle, 'border-radius'); color: map-get($submenu-dropdown-toggle, 'color'); height: map-get($submenu-dropdown-toggle, 'height'); width: map-get($submenu-dropdown-toggle, 'width'); flex-shrink: 0; align-self: center; svg { transform: rotate(-90deg) rotateX(0deg); width: map-get($submenu-dropdown-toggle, 'arrow-size'); height: map-get($submenu-dropdown-toggle, 'arrow-size'); } &.toggled-on svg { transform: rotate(-90deg) rotateX(180deg); } } // Bubble arrow > li > ul::after { content: ''; position: absolute; width: 0; height: 0; overflow: hidden; border-style: dashed dashed solid; top: -16px; left: 31px; border-width: 8px; /* stylelint-disable sh-waqar/declaration-use-variable */ border-color: transparent transparent $color-white; /* stylelint-enable */ } } .menu-item.menu-item-has-children { margin-right: .8rem; position: relative; display: flex; justify-content: space-between; align-items: center; // Add a pseudo element to fill the gap // between menu item and sub menu to help hovering &::after { display: block; position: absolute; content: ''; height: map-get($dropdown, 'gap'); width: 100%; top: 100%; } /* stylelint-disable */ > a { // Let's make space for the nav-toggle/arrow padding-right: 1.5rem; } /* stylelint-enable */ } // .menu-item.menu-item-has-children // Don't use gap filler in sub menu items .sub-menu .menu-item-has-children::after { display: none; } } } // @media only screen and (min-width: $responsivenav)