Skip to content

feat: Add More Collapsed Navigation Icon Options for Navigation Block #70086

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,87 @@
/**
* WordPress dependencies
*/
import { SVG, Rect } from '@wordpress/primitives';
import { SVG, Rect, Path } from '@wordpress/primitives';
import { Icon, menu } from '@wordpress/icons';

export default function OverlayMenuIcon( { icon } ) {
if ( icon === 'menu' ) {
return <Icon icon={ menu } />;
}

if ( icon === 'quad-lines' ) {
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="10" y="17.2" width="14" height="1.6" />
<Rect x="10" y="13.2" width="14" height="1.6" />
<Rect x="10" y="9.2" width="14" height="1.6" />
<Rect x="10" y="5.2" width="14" height="1.6" />
</SVG>
);
}

if ( icon === 'menu-alt' ) {
return (
<SVG
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
>
<Path
d="M4 6H20M7 12H17M9 18H15"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
/>
</SVG>
);
}

if ( icon === 'hamburger-2' ) {
return (
<SVG
width="24"
height="24"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M4 17H8M12 17H20M4 12H20M4 7H12M16 7H20"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</SVG>
);
}

if ( icon === 'grid' ) {
return (
<SVG
fill="currentColor"
width="24"
height="24"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M0 0h4v4H0V0zm0 6h4v4H0V6zm0 6h4v4H0v-4zM6 0h4v4H6V0zm0 6h4v4H6V6zm0 6h4v4H6v-4zm6-12h4v4h-4V0zm0 6h4v4h-4V6zm0 6h4v4h-4v-4z"
fill-rule="evenodd"
/>
</SVG>
);
}

return (
<SVG
xmlns="http://www.w3.org/2000/svg"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,26 @@ export default function OverlayMenuPreview( { setAttributes, hasIcon, icon } ) {
aria-label={ __( 'menu' ) }
label={ <OverlayMenuIcon icon="menu" /> }
/>
<ToggleGroupControlOption
value="menu-alt"
aria-label={ __( 'menu-alt' ) }
label={ <OverlayMenuIcon icon="menu-alt" /> }
/>
<ToggleGroupControlOption
value="quad-lines"
aria-label={ __( 'quad-lines' ) }
label={ <OverlayMenuIcon icon="quad-lines" /> }
/>
<ToggleGroupControlOption
value="grid"
aria-label={ __( 'grid' ) }
label={ <OverlayMenuIcon icon="grid" /> }
/>
<ToggleGroupControlOption
value="hamburger-2"
aria-label={ __( 'hamburger-2' ) }
label={ <OverlayMenuIcon icon="hamburger-2" /> }
/>
</ToggleGroupControl>
</>
);
Expand Down
8 changes: 8 additions & 0 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,14 @@ private static function get_responsive_container_markup( $attributes, $inner_blo
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 ( 'quad-lines' === $attributes['icon'] ) {
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 4h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2z"/><path d="M3 8h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2z"/><path d="M3 12h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2z"/><path d="M3 16h18a1 1 0 0 1 0 2H3a1 1 0 0 1 0-2z"/></svg>';
} elseif ( 'menu-alt' === $attributes['icon'] ) {
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 6H20M7 12H17M9 18H15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
} elseif ( 'hamburger-2' === $attributes['icon'] ) {
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 17H8M12 17H20M4 12H20M4 7H12M16 7H20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>';
} elseif ( 'grid' === $attributes['icon'] ) {
$toggle_button_icon = '<svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0h4v4H0V0zm0 6h4v4H0V6zm0 6h4v4H0v-4zM6 0h4v4H6V0zm0 6h4v4H6V6zm0 6h4v4H6v-4zm6-12h4v4h-4V0zm0 6h4v4h-4V6zm0 6h4v4h-4v-4z" fill-rule="evenodd"/></svg>';
}
}
$toggle_button_content = $should_display_icon_label ? $toggle_button_icon : __( 'Menu' );
Expand Down
Loading