-
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 ability to style and/or use a custom icon for responsive menu #37930
Comments
Yes please! My thoughts on this, some of which may or may not be possible. Just putting them out there. Make the returned icon filterable. Options in the block controls to select a different icon. Option to use the Button block instead. I know some who dislike hamburger icons and would prefer to have a button, that could then use any text they like such as 'Menu' etc. |
We've discussed at a high level some ideas on how we can bring additional customization to the icon in this PR. The basic idea is to add a "card" preview to the inspector, similar to that of Global Styles, which can be clicked to surface additional customization options. This is a first draft mockup of how that might work: |
Noting that this came up in the latest call for testing for the FSE Outreach Program:
Updating the title of this issue to more clearly reflect the description too :) |
A filter for the theme would be great! Each theme can have its own custom icon/DOM/provision for the button.
Adding a simple filter here allows themes to change the icon for the frontend. |
Hint for everyone else looking for a solution now: |
I'm implementing a partial solution in #37930 (comment). Will link the PR once it's out. |
I found out a couple of things that I think might be the dealbreakers for the "uploading custom icons" feature:
I’m not sure if this is still worth doing in the block settings anymore. Maybe a preset and a PHP filter would be enough to cover most of the use cases? |
Just being able to choose between a couple of stock icons like the ones suggested, is a great first step worth doing. Uploading a PNG file, even if it can't be re-colored, or even allowing pasting some custom SVG code, that could still be interesting. But it's nothing that need block the main feature. |
There exist some plugins which bring SVG support to the media lib. IMO this is the way most people get SVGs into their WP sites. Just allow to pick a custom icon / image from media lib would solve the main need to replace the native icon. Coloring could be done either on graphic tool side or through custom css. Having a set of some preset icons with coloring options would be a nice plus for less experienced users I guess. |
As part of the seventeenth FSE Outreach Program call for testing, the following feedback was shared:
This touches on this issue as well around customizing the text: #40580 |
appart from being able to set custom svg icon, there is also the critical need to manage
Actually the burger icon is displayed with a 24px/24px default size, and there is no way to enlarge it from the nav block settings. Please also note that if we enlarge with css the icon size, it is blured !
|
Can you speak to this a bit? I know that even vector-based SVGs such as the icon used for the overlay menu is designed to an initial pixel grid. But in being vector based, it should at least scale better than pixels. |
yep, if anyone is stucked with this bluring issue, we have a use a integer multiple of 24px to not have a blur hope the nav will be improved very soon on the nav icon styling...included the icon sizes. |
+1! I currently have to parse the navigation block HTML and replace the |
Navigation icon customization would be still great, but it is now possible to select between two different icons (one with two lines and one with three lines). Select the icon in the settings sidebar for a selected navigation block, then a menu icon can be selected. |
Now tracked in #49156 |
I raised a canonical issue to solve this across the editor #51563 Update: the Issue still stands, but there is now also a formalised Github Discussion about a new API to facilitate icons. |
With four weeks left ahead of 6.4 beta 1, I'm removing this from the board due to lack of progress/updates. |
This won't happen for 6.4. The requirements here are:
Step 1 is a significant effort that will likely take a while to land. The best way to advance this feature request is to participate in the active discussion regarding Icon Registration. |
In the meantime, it might be a good case for the add_filter('render_block_core/navigation', 'filter_navigation_block_output', 10, 2);
function filter_navigation_block_output($output, $block) {
$tags = new WP_HTML_Tag_Processor($output);
if ($tags->next_tag(array('tag_name' => 'button', 'class' => 'wp-block-navigation__responsive-container-open'))) {
if ($tags->next_tag(array('tag_name' => 'svg'))) {
if ($tags->next_tag(array('tag_name' => 'path'))) {
// NOTE: Google Material Symbol: Manage Search https://fonts.google.com/icons?selected=Material+Symbols+Outlined:manage_search:FILL@0;wght@400;GRAD@0;opsz@24&icon.query=search
$tags->set_attribute('d', 'M80-200v-80h400v80H80Zm0-200v-80h200v80H80Zm0-200v-80h200v80H80Zm744 400L670-354q-24 17-52.5 25.5T560-320q-83 0-141.5-58.5T360-520q0-83 58.5-141.5T560-720q83 0 141.5 58.5T760-520q0 29-8.5 57.5T726-410l154 154-56 56ZM560-400q50 0 85-35t35-85q0-50-35-85t-85-35q-50 0-85 35t-35 85q0 50 35 85t85 35Z');
}
}
}
$output = $tags->get_updated_html();
return $output;
} |
A reminder to anyone arriving here that if you would like to see icons in Navigation we first need:
|
No we don't need SVG support in the core or an icon api. The mvp here is having the default icon in place or select a media file for the menu / close icon. No fancy addons needed and still backwards compatible after adding icon libs. |
By the way, for some releases now the responsive menu icon can be selected from a set of icons (as from two to three lines) now. |
@dennisheiden Happy for folks to disagree with my assessment, but how do you see that working without SVG support in Core? Yes there are Plugins which enable SVGs to be uploaded but the block must work when those Plugins are not active. Are you advocating for all / any Media being admissible to be used as the icon? |
SVG support is in discussion for years now. Do you really want to make another feature depended to that?
Yes, let people be stupid. |
What problem does this address?
The responsive menu option for the navigation block currently comes with the ability to only use one icon.
What is your proposed solution?
Allow for the ability to either use different styled icons or use your own (depending). Doing so will allow for greater customization and unification of designs folks are trying to implement.
The text was updated successfully, but these errors were encountered: