/** * External dependencies */ import { omitBy } from 'lodash'; import { Story, Meta } from '@storybook/react'; import { useState } from '@wordpress/element'; /** * Internal dependencies */ import * as icons from '../index'; import { IconProps } from '../icon'; const { Icon, ...availableIcons } = icons; export default { title: 'WooCommerce Blocks/@woocommerce/icons', component: Icon, argTypes: { size: { control: { type: 'range', min: 8, max: 96 }, }, srcElement: { control: 'select', mapping: availableIcons, options: Object.keys( availableIcons ), }, }, } as Meta< IconProps >; const Template: Story< IconProps > = ( args ) => ; export const BaseIcon = Template.bind( {} ); BaseIcon.args = { srcElement: icons.woo, size: 24, }; export const Library: Story< IconProps > = ( args ) => { const [ filter, setFilter ] = useState( '' ); const filteredIcons = omitBy( availableIcons, ( _, name ) => { return ! name.includes( filter ); } ); return (
setFilter( event.target.value ) } />
{ Object.entries( filteredIcons ).map( ( [ name, icon ] ) => { return (
{ name }
); } ) }
); }; Library.parameters = { controls: { include: [], hideNoControlsWarning: true }, }; Library.storyName = 'Icon Library';