Skip to content

Commit

Permalink
Revert using Icon in IconButton to avoid regression in plugin icons (…
Browse files Browse the repository at this point in the history
…pinned icons) (#11256)
  • Loading branch information
youknowriad authored and mcsf committed Oct 30, 2018
1 parent 3add7c1 commit 9d46788
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
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 { isArray } from 'lodash';
import { isArray, isString } from 'lodash';

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

// 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 }>
<Icon icon={ icon } />
{ isString( icon ) ? <Dashicon 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( 'Icon' ).prop( 'icon' ) ).toBe( 'wordpress' );
expect( iconButton.find( 'Dashicon' ).shallow().hasClass( 'dashicons-wordpress' ) ).toBe( true );
} );

it( 'should render child elements when passed as children', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,22 @@ exports[`MoreMenu should match snapshot 1`] = `
onMouseLeave={[Function]}
type="button"
>
<Icon
<Dashicon
icon="ellipsis"
key="0,0"
>
<Dashicon
icon="ellipsis"
size={20}
<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"
>
<SVG
aria-hidden={true}
<svg
aria-hidden="true"
className="dashicon dashicons-ellipsis"
focusable="false"
height={20}
Expand All @@ -60,27 +66,16 @@ exports[`MoreMenu should match snapshot 1`] = `
width={20}
xmlns="http://www.w3.org/2000/svg"
>
<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
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
<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
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>
/>
</Path>
</svg>
</SVG>
</Dashicon>
</button>
</Button>
</Tooltip>
Expand Down

0 comments on commit 9d46788

Please sign in to comment.