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

UHF-7609 global nav inject #514

Merged
merged 3 commits into from
Jan 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/css/nav_global.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/menu.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/nav-global.min.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/js/nav-global/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ function isInPath() {
return !!this.inPath;
}

/**
* Convert null `is_injected` values to boolean for mustache templates to avoid using parent values
* @return {boolean} does current object have is_injected set and trueish
*/
function isInjected() {
return !!this.is_injected;
}

/** *
* Convert attributes to to template-friendly object
* @return {object} {external:bool, protocol:bool}
Expand Down Expand Up @@ -191,7 +199,7 @@ const MobilePanel = {
<ul class="mmenu__items">
{{#sub_tree}}
<li class="mmenu__item">
<a href="{{url}}" class="mmenu__item-link{{#isInPath}} mmenu__item-link--in-path{{/isInPath}}"{{#isActive}} aria-current="page"{{/isActive}}
<a href="{{url}}" class="mmenu__item-link{{#isInPath}} mmenu__item-link--in-path{{/isInPath}}{{#isInjected}} mmenu__item-link--injected{{/isInjected}}"{{#isActive}} aria-current="page"{{/isActive}}
{{#externalLinkAttributes.external}}
data-external="true"
{{/externalLinkAttributes.external}}
Expand Down Expand Up @@ -285,6 +293,7 @@ const MobilePanel = {
button,
isActive,
isInPath,
isInjected,
externalLinkAttributes,
hasLang,
externalLinkIcon,
Expand Down
6 changes: 3 additions & 3 deletions src/scss/06_components/navigation/global/_menu-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $-default-label-icon-size: 32px;
$label-font: 'special.navigation.icon_label';

// When menu is opened with anchor instead of JS, this forces the page to scroll to top
.nav-toggle-target:not([data-js]) {
#menu:not([data-js]) {
scroll-margin-top: 100vh;
}

Expand Down Expand Up @@ -237,7 +237,7 @@ $label-font: 'special.navigation.icon_label';
}

// When JS is enabled, switch to use button instead of anchor
.nav-toggle-target[data-js] ~ * {
#menu[data-js] ~ * {
.nav-toggle__anchor {
display: none;
}
Expand All @@ -258,7 +258,7 @@ $label-font: 'special.navigation.icon_label';
}
}

.nav-toggle-target:not([data-js]) ~ * {
#menu:not([data-js]) ~ * {
// Chrome browser has a bug that renders initial menu state as open on page load and then animates it close.
// For this reason I had to remove the closing animation when there is no js available :(
.nav-toggle-dropdown__wrapper,
Expand Down
5 changes: 5 additions & 0 deletions src/scss/06_components/navigation/global/_mmenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ $-footerlink-target-size: 44px;
font-weight: $font-weight-bold;
}

.mmenu__item-link--injected,
.mmenu__item-link--injected + .mmenu__forward {
background: $color-black-5;
}

.mmenu__forward {
align-items: center;
background: none;
Expand Down