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

DocumentTools: Use standard ToolbarButton for inserter #68332

Merged
merged 1 commit into from
Dec 27, 2024
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
9 changes: 3 additions & 6 deletions packages/editor/src/components/document-tools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useViewportMatch } from '@wordpress/compose';
import { useSelect, useDispatch } from '@wordpress/data';
import { __, _x } from '@wordpress/i18n';
import { NavigableToolbar, ToolSelector } from '@wordpress/block-editor';
import { Button, ToolbarItem } from '@wordpress/components';
import { ToolbarButton, ToolbarItem } from '@wordpress/components';
import { listView, plus } from '@wordpress/icons';
import { useCallback } from '@wordpress/element';
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
Expand Down Expand Up @@ -118,9 +118,8 @@ function DocumentTools( { className, disableBlockTools = false } ) {
>
<div className="editor-document-tools__left">
{ ! isDistractionFree && (
<ToolbarItem
<ToolbarButton
ref={ inserterSidebarToggleRef }
as={ Button }
className="editor-document-tools__inserter-toggle"
variant="primary"
isPressed={ isInserterOpened }
Expand Down Expand Up @@ -159,8 +158,7 @@ function DocumentTools( { className, disableBlockTools = false } ) {
size="compact"
/>
{ ! isDistractionFree && (
<ToolbarItem
as={ Button }
<ToolbarButton
className="editor-document-tools__document-overview-toggle"
icon={ listView }
disabled={ disableBlockTools }
Expand All @@ -175,7 +173,6 @@ function DocumentTools( { className, disableBlockTools = false } ) {
}
aria-expanded={ isListViewOpen }
ref={ listViewToggleRef }
size="compact"
/>
) }
</>
Expand Down
6 changes: 0 additions & 6 deletions packages/editor/src/components/document-tools/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,8 @@
}

.editor-document-tools .editor-document-tools__left > .editor-document-tools__inserter-toggle.has-icon {
min-width: $button-size-compact;
width: $button-size-compact;
height: $button-size-compact;
padding: 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The padding doesn't seem to be necessary?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, yes, the button is unchanged as the styles currently come from here:

// The Toolbar component adds different styles to buttons, so we reset them
// here to the original button styles
.editor-document-tools__left > .components-button.has-icon,
.editor-document-tools__left > .components-dropdown > .components-button.has-icon {
// @todo override toolbar group inherited paddings from components/block-tools/style.scss.
// This is best fixed by making the mover control area a proper single toolbar group.
// It needs specificity due to style inherited from .components-accessible-toolbar .components-button.has-icon.has-icon.
height: $button-size-compact;
min-width: $button-size-compact;
padding: 4px;


.show-icon-labels & {
width: auto;
height: $button-size-compact;
padding: 0 $grid-unit-10;
}
}
Expand Down
Loading