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 blocks navigation menu SVG icon size. #11153

Merged
merged 6 commits into from
Oct 30, 2018
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/components/src/icon-button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* External dependencies
*/
import classnames from 'classnames';
import { isString, isArray } from 'lodash';
import { isArray } from 'lodash';

/**
* WordPress dependencies
Expand All @@ -14,7 +14,7 @@ import { Component } from '@wordpress/element';
*/
import Tooltip from '../tooltip';
import Button from '../button';
import Dashicon from '../dashicon';
import Icon from '../icon';

// This is intentionally a Component class, not a function component because it
// is common to apply a ref to the button element (only supported in class)
Expand Down Expand Up @@ -42,7 +42,7 @@ class IconButton extends Component {

let element = (
<Button aria-label={ label } { ...additionalProps } className={ classes }>
{ isString( icon ) ? <Dashicon icon={ icon } /> : icon }
<Icon icon={ icon } />
{ children }
</Button>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/icon-button/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe( 'IconButton', () => {

it( 'should render a Dashicon component matching the wordpress icon', () => {
const iconButton = shallow( <IconButton icon="wordpress" /> );
expect( iconButton.find( 'Dashicon' ).shallow().hasClass( 'dashicons-wordpress' ) ).toBe( true );
expect( iconButton.find( 'Icon' ).prop( 'icon' ) ).toBe( 'wordpress' );
} );

it( 'should render child elements when passed as children', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,16 @@ exports[`MoreMenu should match snapshot 1`] = `
onMouseLeave={[Function]}
type="button"
>
<Dashicon
<Icon
icon="ellipsis"
key="0,0"
>
<SVG
aria-hidden={true}
className="dashicon dashicons-ellipsis"
focusable="false"
height={20}
role="img"
viewBox="0 0 20 20"
width={20}
xmlns="http://www.w3.org/2000/svg"
<Dashicon
icon="ellipsis"
size={20}
>
<svg
aria-hidden="true"
<SVG
aria-hidden={true}
className="dashicon dashicons-ellipsis"
focusable="false"
height={20}
Expand All @@ -66,16 +60,27 @@ exports[`MoreMenu should match snapshot 1`] = `
width={20}
xmlns="http://www.w3.org/2000/svg"
>
<Path
d="M5 10c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm12-2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-7 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
<svg
aria-hidden="true"
className="dashicon dashicons-ellipsis"
focusable="false"
height={20}
role="img"
viewBox="0 0 20 20"
width={20}
xmlns="http://www.w3.org/2000/svg"
>
<path
<Path
d="M5 10c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm12-2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-7 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
/>
</Path>
</svg>
</SVG>
</Dashicon>
>
<path
d="M5 10c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm12-2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-7 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
/>
</Path>
</svg>
</SVG>
</Dashicon>
</Icon>
</button>
</Button>
</Tooltip>
Expand Down
9 changes: 5 additions & 4 deletions packages/editor/src/components/block-navigation/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
import { Fragment } from '@wordpress/element';
import { IconButton, Dropdown, SVG, Path, KeyboardShortcuts } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { rawShortcut } from '@wordpress/keycodes';
import { rawShortcut, displayShortcut } from '@wordpress/keycodes';

/**
* Internal dependencies
*/
import BlockNavigation from './';

const menuIcon = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20">
const MenuIcon = (
<SVG xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20">
<Path d="M5 5H3v2h2V5zm3 8h11v-2H8v2zm9-8H6v2h11V5zM7 11H5v2h2v-2zm0 8h2v-2H7v2zm3-2v2h11v-2H10z" />
</SVG>
);
Expand All @@ -29,11 +29,12 @@ function BlockNavigationDropdown() {
} }
/>
<IconButton
icon={ menuIcon }
icon={ MenuIcon }
aria-expanded={ isOpen }
onClick={ onToggle }
label={ __( 'Block Navigation' ) }
className="editor-block-navigation"
shortcut={ displayShortcut.access( 'o' ) }
/>
</Fragment>
) }
Expand Down