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

Fix the default icon for the navigation block #44104

Merged
merged 1 commit into from Sep 13, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/edit/index.js
Expand Up @@ -92,7 +92,7 @@ function Navigation( {
flexWrap = 'wrap',
} = {},
hasIcon,
icon,
icon = 'handle',
Copy link
Contributor

Choose a reason for hiding this comment

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

The block does have a default attribute of 'handle', so this may not be required, but I don't mind a bit of extra safety.

} = attributes;

const ref = attributes.ref;
Expand Down
30 changes: 14 additions & 16 deletions packages/block-library/src/navigation/edit/overlay-menu-icon.js
Expand Up @@ -5,27 +5,25 @@ import { SVG, Rect } from '@wordpress/primitives';
import { Icon, menu, moreVertical, moreHorizontal } from '@wordpress/icons';

export default function OverlayMenuIcon( { icon } ) {
if ( icon === 'handle' ) {
return (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
aria-hidden="true"
focusable="false"
>
<Rect x="4" y="7.5" width="16" height="1.5" />
<Rect x="4" y="15" width="16" height="1.5" />
</SVG>
);
} else if ( icon === 'menu' ) {
if ( icon === 'menu' ) {
return <Icon icon={ menu } />;
} else if ( icon === 'more-vertical' ) {
return <Icon icon={ moreVertical } />;
} else if ( icon === 'more-horizontal' ) {
return <Icon icon={ moreHorizontal } />;
}

return null;
return (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
aria-hidden="true"
focusable="false"
>
<Rect x="4" y="7.5" width="16" height="1.5" />
<Rect x="4" y="15" width="16" height="1.5" />
</SVG>
);
}
14 changes: 8 additions & 6 deletions packages/block-library/src/navigation/index.php
Expand Up @@ -611,12 +611,14 @@ function render_block_core_navigation( $attributes, $content, $block ) {

$should_display_icon_label = isset( $attributes['hasIcon'] ) && true === $attributes['hasIcon'];
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg>';
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>';
if ( isset( $attributes['icon'] ) ) {
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>';
}
}
$toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' );
$toggle_close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg>';
Expand Down