Skip to content

Commit

Permalink
Local Navigation Bar: Fix alignment of dropdown caret (#606)
Browse files Browse the repository at this point in the history
* Fix alignment of dropdown caret in local nav.

* Fix bugs with initial implementation.

* Linting.

* Modify how padding is applied.

* Linting.

* Update value to match padding variable used.
  • Loading branch information
ndiego authored May 3, 2024
1 parent be8c24c commit 73f8ad6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions mu-plugins/blocks/local-navigation-bar/postcss/style.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,13 @@
position: relative !important;
top: 0 !important;

/* Matches the padding of the global header button. */
padding-right: calc(16px + var(--wp--custom--alignment--scroll-bar-width)) !important;
/* Needed for aligning the dropdown caret correctly. */
padding-right: 0;

/* Add right padding if the dropdown caret is not being displayed. */
& nav:not(.wporg-is-mobile-nav):not(.wporg-is-collapsed-nav) {
padding-right: var(--wp--preset--spacing--edge-space);
}

& .global-header__wporg-logo-mark {
display: none;
Expand Down Expand Up @@ -225,6 +230,9 @@
& .wp-block-navigation__responsive-container-close {
padding: 17px;

/* Add right padding to correctly align the dropdown caret. */
padding-right: calc(16px + var(--wp--custom--alignment--scroll-bar-width));

&:focus-visible {
outline: none;
border-radius: 2px;
Expand All @@ -234,10 +242,6 @@

& .wp-block-navigation__responsive-container-close {
margin-block-start: calc(var(--wp--custom--local-navigation-bar--spacing--height) * -1) !important;

@media (max-width: 600px) {
margin-inline-end: calc(16px + var(--wp--custom--alignment--scroll-bar-width));
}
}

& .wp-block-navigation__responsive-close,
Expand Down
3 changes: 2 additions & 1 deletion mu-plugins/blocks/local-navigation-bar/src/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ function init() {
window.innerWidth -
parseInt( paddingInlineStart, 10 ) -
parseInt( paddingInlineEnd, 10 ) -
parseInt( gap, 10 );
parseInt( gap, 10 ) -
20; // 20px right padding is added when the collapsed nav is hidden.

const titleElement = container.querySelector( '.wp-block-site-title, div.wp-block-group' );
if ( ! titleElement ) {
Expand Down

0 comments on commit 73f8ad6

Please sign in to comment.