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

Header navigation margins option 2 #1033

Merged
merged 16 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 15 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
14 changes: 9 additions & 5 deletions packages/components/header/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,12 @@
color: $color_nhsuk-white;
display: block;
font-size: inherit;
padding: nhsuk-spacing(3) 12px;
padding: nhsuk-spacing(3) 2px;
text-decoration: underline;
white-space: nowrap;

@include mq($from: tablet) {
padding: 12px nhsuk-spacing(3);
padding: 12px 2px;
}

.nhsuk-icon__chevron-right {
Expand Down Expand Up @@ -421,13 +421,17 @@
z-index: 1;

&.nhsuk-header__navigation-link {
padding-right: 30px;
padding-right: 23px;
}

@include mq($from: desktop) {
display: none;
}

.nhsuk-icon__chevron-down {
right: -3px;
}

&:focus {
text-decoration: none;

Expand Down Expand Up @@ -467,11 +471,11 @@
.nhsuk-header__navigation-list {
@extend %nhsuk-navigation-list;
@include govuk-width-container;

display: flex;
gap: nhsuk-spacing(4);
width: 100%;

@include mq($from: desktop) {
display: flex;
justify-content: space-between;
}

Expand Down
13 changes: 9 additions & 4 deletions packages/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ class Header {
*
*/
calculateBreakpoints() {
// Get the width of the gap between each navigation item
const navigationListStyles = window.getComputedStyle(this.navigationList)
const gapPixels = navigationListStyles.getPropertyValue('gap')
const gap = Number(gapPixels.replace('px', ''))

let childrenWidth = 0
for (let i = 0; i < this.navigationList.children.length; i++) {
childrenWidth += this.navigationList.children[i].offsetWidth
childrenWidth += this.navigationList.children[i].offsetWidth + gap
this.breakpoints[i] = childrenWidth
}
}
Expand All @@ -72,7 +77,7 @@ class Header {
*
* Closes the mobile menu and updates accessibility state.
*
* Remvoes the margin-bottom from the navigation
* Removes the margin-bottom from the navigation
*/
closeMobileMenu() {
this.menuIsOpen = false
Expand Down Expand Up @@ -115,7 +120,7 @@ class Header {
this.navigation.style.marginBottom = `${marginBody}px`
this.mobileMenuToggleButton.setAttribute('aria-expanded', 'true')

// add event listerer for esc key to close menu
// add event listener for esc key to close menu
document.addEventListener('keydown', this.handleEscapeKey.bind(this))

// add event listener for close icon to close menu
Expand Down Expand Up @@ -145,7 +150,7 @@ class Header {
* If the available space is greater than the current breakpoint,
* remove the mobile menu toggle button and move the first item in the
*
* Additionaly will close the mobile menu if the window gets resized
* Additionally will close the mobile menu if the window gets resized
* and the menu is open.
*/

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading