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

Navigation: Use gap instead of margin. #32367

Merged
merged 3 commits into from Sep 2, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/block-library/src/navigation/editor.scss
Expand Up @@ -11,6 +11,13 @@
margin-left: 0;
padding-left: 0;
}

// Revert any left/right margins.
// This also makes it work with classic theme auto margins.
.wp-block-navigation-item.wp-block {
margin-left: revert;
margin-right: revert;
}
}

// This element is inline on the frontend but needs to be editable, therefore inline-block, in the editor.
Expand Down
26 changes: 6 additions & 20 deletions packages/block-library/src/navigation/style.scss
Expand Up @@ -208,35 +208,22 @@

/**
* Margins
* @todo: refactor this to use gap.
*/

// Menu items with no background.
.wp-block-page-list,
.wp-block-page-list > .wp-block-navigation-item,
.wp-block-navigation__container > .wp-block-navigation-item {
margin: 0 2em 0 0;

// Margin of right-most margin should be zero, for right aligned or justified items.
&:last-child {
margin-right: 0;
}
.wp-block-navigation .wp-block-page-list,
.wp-block-navigation__container {
gap: 0.5em 2em;
}

// Menu items with background.
// We use :where to keep specificity minimal, yet still scope it to only the navigation block.
// That way if padding is set in theme.json, it still wins.
// https://css-tricks.com/almanac/selectors/w/where/
.wp-block-navigation:where(.has-background) {
.wp-block-page-list,
.wp-block-page-list > .wp-block-navigation-item,
.wp-block-navigation__container > .wp-block-navigation-item {
margin: 0 0.5em 0 0;

// Don't show right margin on the last child.
&:last-child {
margin: 0;
}
.wp-block-navigation .wp-block-page-list,
.wp-block-navigation__container {
gap: 0 0.5em;
}
}

Expand Down Expand Up @@ -357,7 +344,6 @@
align-items: flex-end;

.wp-block-navigation-item {
margin-right: 0;
justify-content: flex-end;
}
}
Expand Down