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

Fix the block toolbar styles to evenly space buttons #39630

Merged
merged 1 commit into from
Mar 23, 2022
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
29 changes: 29 additions & 0 deletions packages/block-editor/src/components/block-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,32 @@
.is-dragging-components-draggable .components-tooltip {
display: none;
}


// Size multiple sequential buttons to be optically balanced.
// Icons are 36px, as set by a 24px icon and 12px padding.
.block-editor-block-toolbar > .components-toolbar > .block-editor-block-toolbar__slot, // When a plugin adds to a slot, the segment has a `components-toolbar` class.
.block-editor-block-toolbar > .components-toolbar-group > .block-editor-block-toolbar__slot, // When no plugin adds to slots, the segment has a `components-toolbar-group` class.
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-toolbar, // The nesting order is sometimes reversed.
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-dropdown, // Targets unique markup for the "Replace" button.
.block-editor-block-toolbar .block-editor-block-toolbar__slot .components-toolbar-group { // Inline formatting tools use this class.
padding-left: $grid-unit-15 * 0.5; // 6px.
padding-right: $grid-unit-15 * 0.5;

> .components-button,
> div > .components-button,
> .components-dropdown .components-button {
min-width: $block-toolbar-height - $grid-unit-15;
padding-left: $grid-unit-15 * 0.5; // 6px.
padding-right: $grid-unit-15 * 0.5;

svg {
min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
}

&::before {
left: 2px;
right: 2px;
}
}
}
73 changes: 0 additions & 73 deletions packages/components/src/toolbar-group/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,76 +64,3 @@ div.components-toolbar {
}
}
}

// Size multiple sequential buttons to be optically balanced.
// Icons are 36px, as set by a 24px icon and 12px padding.
.block-editor-block-toolbar > .components-toolbar > .block-editor-block-toolbar__slot, // When a plugin adds to a slot, the segment has a `components-toolbar` class.
.block-editor-block-toolbar > .components-toolbar-group > .block-editor-block-toolbar__slot, // When no plugin adds to slots, the segment has a `components-toolbar-group` class.
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-toolbar, // The nesting order is sometimes reversed.
.block-editor-block-toolbar > .block-editor-block-toolbar__slot > .components-dropdown, // Targets unique markup for the "Replace" button.
.block-editor-block-toolbar .block-editor-block-toolbar__slot .components-toolbar-group { // Inline formatting tools use this class.

// Segments with just a single button.
> .components-button:first-child:last-child,
> .components-dropdown:first-child:last-child .components-button,
&.components-dropdown > .components-button.components-button, // Single segments where the dropdown is also the toolbar group (such as text align).
&.components-dropdown > * .components-button {
min-width: $block-toolbar-height;
padding-left: $grid-unit-15;
padding-right: $grid-unit-15;

&::before {
left: $grid-unit-10;
right: $grid-unit-10;
}
}

// First.
// @todo, this unnamed div only shows up when plugins add to slots. We should remove the fragment.
> .components-button:first-child,
> div:first-child > .components-button,
> .components-dropdown:first-child .components-button {
min-width: $block-toolbar-height - $grid-unit-15 * 0.5;
padding-left: $grid-unit-15 - $border-width;
padding-right: $grid-unit-15 * 0.5;

&::before {
left: $grid-unit-10;
right: 2px;
}
}

// Middle.
// @todo, this unnamed div only shows up when plugins add to slots. We should remove the fragment.
> .components-button,
> div > .components-button,
> .components-dropdown .components-button {
min-width: $block-toolbar-height - $grid-unit-15;
padding-left: $grid-unit-15 * 0.5; // 6px.
padding-right: $grid-unit-15 * 0.5;

svg {
min-width: $button-size-small; // This is the optimal icon size, and we size the whole button after this.
}

&::before {
left: 2px;
right: 2px;
}
}

// Last.
// @todo, this unnamed div only shows up when plugins add to slots. We should remove the fragment.
> .components-button:last-child,
> div:last-child > .components-button,
> .components-dropdown:last-child .components-button {
min-width: $block-toolbar-height - $grid-unit-15 * 0.5;
padding-left: $grid-unit-15 * 0.5;
padding-right: $grid-unit-15 - $border-width;

&::before {
left: 2px;
right: $grid-unit-10;
}
}
}