Skip to content

Commit

Permalink
Lodash: Remove completely from icons package (WordPress#41971)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyxla authored Jun 28, 2022
1 parent 4538cf4 commit e86e801
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/icons/src/icon/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* External dependencies
*/
import { omit, omitBy, map } from 'lodash';

/**
* WordPress dependencies
*/
Expand All @@ -15,7 +10,7 @@ import Icon from '../';
import check from '../../library/check';
import * as icons from '../../';

const availableIcons = omit( icons, 'Icon' );
const { Icon: _Icon, ...availableIcons } = icons;

export default { title: 'Icons/Icon', component: Icon };

Expand All @@ -42,9 +37,13 @@ export const _default = () => {

const LibraryExample = () => {
const [ filter, setFilter ] = useState( '' );
const filteredIcons = omitBy( availableIcons, ( _icon, name ) => {
return name.indexOf( filter ) === -1;
} );
const filteredIcons = filter.length
? Object.fromEntries(
Object.entries( availableIcons ).filter( ( [ name ] ) =>
name.includes( filter )
)
)
: availableIcons;
return (
<div style={ { padding: '20px' } }>
<label htmlFor="filter-icon" style={ { paddingRight: '10px' } }>
Expand All @@ -58,7 +57,7 @@ const LibraryExample = () => {
placeholder="Icon name"
onChange={ ( event ) => setFilter( event.target.value ) }
/>
{ map( filteredIcons, ( icon, name ) => {
{ Object.entries( filteredIcons ).map( ( [ name, icon ] ) => {
return (
<div
key={ name }
Expand Down

0 comments on commit e86e801

Please sign in to comment.