-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
Size Change: -870 B (-0.05%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
Only thing that stands out to me is the grayed out icon:
Some feedback from @richtabor would be good on that. Otherwise this looks good to me. 👍
Yes, it shouldn't be gray. |
It's gray because it's a disabled button in this state. I'll look at changing it to not be a button so we can style it to be black while maintaining good html semantics. |
c6a3b3d
to
5939e0e
Compare
if ( hideDropdown ) { | ||
return ( | ||
<ToolbarGroup> |
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 removed the <ToolbarGroup />
from this and the switcher, as it will only ever have one item so doesn't feel semantically like a group... Also, it's already within a group.
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.
This makes the BlockSwitcher
the only component in the block-editor-block-toolbar__block-controls
toolbar the group without the inner group. Both BlockLockToolbar
and BlockMover
have group wrappers.
Should we evaluate their removal separately?
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.
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the ToolbarGroups
. We'll see if it breaks anything :) #64909
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> | ||
) } | ||
</> | ||
); |
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.
</ToolbarGroup> | ||
<ToolbarButton | ||
disabled | ||
className="block-editor-block-switcher__no-switcher-icon" |
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 want to extract this. block-editor-block-switcher__no-switcher-icon
is a code smell to me. It's not a switcher, it's just an indicator at this point, and it doesn't seem to have an instance where it switches states on the fly.
|
||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Matching the comment worked to keep this consistent.
@@ -46,12 +46,12 @@ | |||
} | |||
|
|||
// 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 { | |||
.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 comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't applying the CSS until switching to aria-disabled.
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.
LGTM. Only comment is if the opacity: 1
necessary?
Good catch. Removed. |
It seems that after this pull request, the block icon is duplicated in pattern overrides cc: @talldan |
Yep, I can also repro, I'll see if I can fix it. |
Fixes #64663
What?
The block toolbar doesn't have any context when in contentOnly mode. The block icon would be helpful.
Why?
Give a landmark to the user.
How?
Adds contentOnly to the allowed modes that will show the icon.
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast