-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Show block icon in contentOnly toolbar #64694
Changes from all commits
1d62017
25db139
872b8af
5939e0e
3d3b0cd
b5a9c8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,6 +181,21 @@ function BlockSwitcherDropdownMenuContents( { | |
); | ||
} | ||
|
||
const BlockIndicator = ( { icon, showTitle, blockTitle } ) => ( | ||
<> | ||
<BlockIcon | ||
className="block-editor-block-switcher__toggle" | ||
icon={ icon } | ||
showColors | ||
/> | ||
{ showTitle && blockTitle && ( | ||
<span className="block-editor-block-switcher__toggle-text"> | ||
{ blockTitle } | ||
</span> | ||
) } | ||
</> | ||
); | ||
|
||
export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => { | ||
const { | ||
canRemove, | ||
|
@@ -247,6 +262,7 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => { | |
: __( 'Multiple blocks selected' ); | ||
|
||
const hideDropdown = disabled || ( ! hasBlockStyles && ! canRemove ); | ||
|
||
if ( hideDropdown ) { | ||
return ( | ||
<ToolbarGroup> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the Should we evaluate their removal separately? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably. I thought about this too. My guess is that it was a styling issue and not a technical one originally. But you're right that it should be evaluated separately. I'll add the ToolbarGroup in and put in another PR that removes the ToolbarGroups from those. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you, @jeryj! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added it back in 👍🏻 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the |
||
|
@@ -255,14 +271,11 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => { | |
className="block-editor-block-switcher__no-switcher-icon" | ||
title={ blockSwitcherLabel } | ||
icon={ | ||
<> | ||
<BlockIcon icon={ icon } showColors /> | ||
{ ( isReusable || isTemplate ) && ( | ||
<span className="block-editor-block-switcher__toggle-text"> | ||
{ blockTitle } | ||
</span> | ||
) } | ||
</> | ||
<BlockIndicator | ||
icon={ icon } | ||
showTitle={ isReusable || isTemplate } | ||
blockTitle={ blockTitle } | ||
/> | ||
} | ||
/> | ||
</ToolbarGroup> | ||
|
@@ -292,18 +305,11 @@ export const BlockSwitcher = ( { clientIds, disabled, isUsingBindings } ) => { | |
className: 'block-editor-block-switcher__popover', | ||
} } | ||
icon={ | ||
<> | ||
<BlockIcon | ||
icon={ icon } | ||
className="block-editor-block-switcher__toggle" | ||
showColors | ||
/> | ||
{ ( isReusable || isTemplate ) && ( | ||
<span className="block-editor-block-switcher__toggle-text"> | ||
{ blockTitle } | ||
</span> | ||
) } | ||
</> | ||
<BlockIndicator | ||
icon={ icon } | ||
showTitle={ isReusable || isTemplate } | ||
blockTitle={ blockTitle } | ||
/> | ||
} | ||
toggleProps={ { | ||
description: blockSwitcherDescription, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,12 +46,11 @@ | |
} | ||
|
||
// Even when the block switcher does not have any transformations, it still serves as a block indicator. | ||
.components-button.block-editor-block-switcher__no-switcher-icon:disabled { | ||
opacity: 1; | ||
.components-button.block-editor-block-switcher__no-switcher-icon[aria-disabled="true"] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It wasn't applying the CSS until switching to aria-disabled. |
||
color: $gray-900; | ||
|
||
// Since it's not clickable, though, don't show a hover state. | ||
&, | ||
.block-editor-block-icon.has-colors { | ||
&:hover { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matching the comment worked to keep this consistent. |
||
color: $gray-900; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this into its own component so it could be shared between the two places it's used. I'm tempted to fully extract it as I know I've ran into issues where I wanted to get the block indicator for a block but didn't because it wasn't going to be too much work.