-
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
Add select icon for Navigation Block's menu button #43674
Conversation
Size Change: +511 B (0%) Total Size: 1.24 MB
ℹ️ View Unchanged
|
1ea6c0d
to
d8451cb
Compare
d8451cb
to
43f7fc0
Compare
What a cool addition! |
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 tested this and it worked as described. The code LGTM!
@kevin940726 would you say those styling inspector controls could be in their own file to make that edit component less of a giant?
Yeah, separating them into smaller components seems more maintainable to me, but I guess that's up to whoever touches this component more often. 😅 |
if ( 'menu' === $attributes['icon'] ) { | ||
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 5v1.5h14V5H5zm0 7.8h14v-1.5H5v1.5zM5 19h14v-1.5H5V19z" /></svg>'; | ||
} elseif ( 'more-vertical' === $attributes['icon'] ) { | ||
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" /></svg>'; | ||
} elseif ( 'more-horizontal' === $attributes['icon'] ) { | ||
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" /></svg>'; | ||
} |
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.
@kevin940726 I'm seeing some PHP errors here:
I'd recommend checking for the existence of a property before accessing it using something like isset( $attributes['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.
My "bad" as well for not recommending this - I keep forgetting the "older source" problem sorry @kevin940726 ✋🏻
Hi! Great work! Any chance to have filters on that icons? so we can add our owns. Thanks! :) |
I think a filter would be a good idea, but I'm not familiar with PHP and the WP-way to do it, so it might be better to leave it to someone else. If you're familiar with it, feel free to submit a PR and see where it goes! |
@annezazu As this PR was in 14.1 I expect it to be in WP 6.1. We should verify this by testing Beta 1 as I wasn't previously able to replicate. |
Here's what I could find with 6.1 beta 2. Seems there are only two options. Is that intentional @kevin940726 ? Did something get missed? nav.icon.6.1.beta.2.mov |
Out of interest, why are the '[Type] Developer Documentation' and '[Type] User Documentation' labels being added to a PR like this? Those labels signify that a PR is documentation. I think there should be separate labels for 'Needs Developer Documentation' and 'Needs User Documentation'? Unfortunately, it looks like adding those labels is causing PRs to show up in the 'Documentation' part of the changelog. If you search for 43674 in the changelog it's in the wrong place - https://github.com/WordPress/gutenberg/releases/tag/v14.1.0. |
What?
A partial solution to #36149 (comment). If it's the right path, we can add the ability to add custom icons next.
Why?
See #36149 for more info.
How?
Add an
icon
attribute to the Navigation Block and add controls to it.Testing Instructions
Screenshots or screencast
Kapture.2022-08-29.at.13.30.55.mp4