/** * External dependencies */ import type { Story } from '@storybook/react'; import { useState } from '@wordpress/element'; import { Icon } from '@wordpress/icons'; /** * Internal dependencies */ import * as icons from '../index'; const { ...availableIcons } = icons; export const Library: Story = ( args ) => { const [ filter, setFilter ] = useState( '' ); 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 (
setFilter( event.target.value ) } />
{ Object.entries( filteredIcons ).map( ( [ name, icon ] ) => { return (
{ name }
); } ) }
); }; Library.parameters = { controls: { include: [], hideNoControlsWarning: true }, }; Library.storyName = 'Icon Library';