Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
replace omitby
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Apr 20, 2023
1 parent 96faef9 commit afad1d6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions assets/js/icons/stories/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/**
* External dependencies
*/
import { omitBy } from 'lodash';
import type { Story } from '@storybook/react';
import { useState } from '@wordpress/element';
import { Icon } from '@wordpress/icons';
Expand All @@ -14,9 +13,16 @@ const { ...availableIcons } = icons;

export const Library: Story = ( args ) => {
const [ filter, setFilter ] = useState( '' );
const filteredIcons = omitBy( availableIcons, ( _, name ) => {
return ! name.includes( filter );
} );

const filteredIcons = Object.entries( availableIcons ).reduce(
( acc: Record< string, unknown >, [ name, icon ] ) => {
if ( name.includes( filter ) ) {
acc[ name ] = icon;
}
return acc;
},
{} as Partial< typeof availableIcons >
);

return (
<div style={ { padding: '20px' } }>
Expand Down

0 comments on commit afad1d6

Please sign in to comment.