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

Try: Enabling all alignments for the site title and navigation blocks #32778

Closed
wants to merge 8 commits into from
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"orientation": "orientation"
},
"supports": {
"align": [ "wide", "full" ],
"align": true,
"anchor": true,
"html": false,
"inserter": true,
Expand Down
26 changes: 26 additions & 0 deletions packages/block-library/src/navigation/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
display: inline-block;
}

// Properly center-align the block.
.wp-block[data-align="center"] > .wp-block-navigation {
display: table;
margin-left: auto;
margin-right: auto;
}

/**
* Submenus.
Expand Down Expand Up @@ -55,6 +61,26 @@
}
}

// When aligned right, open all submenus leftwards.
// This needs high specificity.
.wp-block[data-align="right"] > .wp-block-navigation .wp-block-page-list > .has-child,
.wp-block[data-align="right"] > .wp-block-navigation > .wp-block-navigation__container .has-child {

// First submenu.
.submenu-container,
.wp-block-navigation-link__container {
left: auto;
right: 0;

// Nested submenus.
.submenu-container,
.wp-block-navigation-link__container {
left: auto;
right: 100%;
}
}
}

// Show a submenu when generally dragging (is-dragging-components-draggable) if that
// submenu has children (has-child) and is being dragged within (is-dragging-within).
.is-dragging-components-draggable .has-child.is-dragging-within {
Expand Down
12 changes: 11 additions & 1 deletion packages/block-library/src/navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
stroke: currentColor;
}
}

// Properly center-align the block.
&.aligncenter {
display: table;
margin-left: auto;
margin-right: auto;
}
}


Expand Down Expand Up @@ -274,11 +281,14 @@

// When justified space-between, open submenus leftward for last menu item.
// When justified right, open all submenus leftwards.
// When aligned right, open all submenus leftwards.
// This needs high specificity.
.wp-block-navigation.items-justified-space-between .wp-block-page-list > .has-child:last-child,
.wp-block-navigation.items-justified-space-between > .wp-block-navigation__container > .has-child:last-child,
.wp-block-navigation.items-justified-right .wp-block-page-list > .has-child,
.wp-block-navigation.items-justified-right > .wp-block-navigation__container .has-child {
.wp-block-navigation.items-justified-right > .wp-block-navigation__container .has-child,
.wp-block-navigation.alignright .wp-block-page-list > .has-child,
.wp-block-navigation.alignright > .wp-block-navigation__container .has-child {

// First submenu.
.submenu-container,
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/site-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"supports": {
"align": [ "wide", "full" ],
"align": true,
"html": false,
"color": {
"gradients": true,
Expand Down
7 changes: 7 additions & 0 deletions packages/block-library/src/site-title/editor.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Properly center-align the block.
.wp-block[data-align="center"] > .wp-block-site-title {
display: table;
margin-left: auto;
margin-right: auto;
}

.wp-block-site-title__placeholder {
padding: 1em 0;
border: 1px dashed;
Expand Down
6 changes: 6 additions & 0 deletions packages/block-library/src/site-title/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Properly center-align the block.
.wp-block-site-title.aligncenter {
display: table;
margin-left: auto;
margin-right: auto;
}
1 change: 1 addition & 0 deletions packages/block-library/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
@import "./search/style.scss";
@import "./separator/style.scss";
@import "./site-logo/style.scss";
@import "./site-title/style.scss";
@import "./social-links/style.scss";
@import "./spacer/style.scss";
@import "./tag-cloud/style.scss";
Expand Down