2020-06-26 14:22:41 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2022-11-02 16:46:14 +00:00
|
|
|
import type { Story } from '@storybook/react';
|
2020-06-26 14:22:41 +00:00
|
|
|
import { useState } from '@wordpress/element';
|
2022-02-01 16:54:38 +00:00
|
|
|
import { Icon } from '@wordpress/icons';
|
2020-06-26 14:22:41 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import * as icons from '../index';
|
2022-02-01 16:54:38 +00:00
|
|
|
const { ...availableIcons } = icons;
|
2020-06-26 14:22:41 +00:00
|
|
|
|
2022-02-01 16:54:38 +00:00
|
|
|
export const Library: Story = ( args ) => {
|
2020-06-26 14:22:41 +00:00
|
|
|
const [ filter, setFilter ] = useState( '' );
|
2023-04-28 10:29:45 +00:00
|
|
|
|
|
|
|
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 >
|
|
|
|
);
|
2021-05-16 17:59:32 +00:00
|
|
|
|
2020-06-26 14:22:41 +00:00
|
|
|
return (
|
|
|
|
<div style={ { padding: '20px' } }>
|
|
|
|
<label htmlFor="filter-icons" style={ { paddingRight: '30px' } }>
|
|
|
|
Filter Icons
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
id="filter-icons"
|
|
|
|
type="search"
|
|
|
|
value={ filter }
|
|
|
|
placeholder="Icon name"
|
|
|
|
onChange={ ( event ) => setFilter( event.target.value ) }
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
style={ {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'bottom',
|
2021-05-16 17:59:32 +00:00
|
|
|
flexWrap: 'wrap',
|
2020-06-26 14:22:41 +00:00
|
|
|
} }
|
|
|
|
>
|
2021-05-16 17:59:32 +00:00
|
|
|
{ Object.entries( filteredIcons ).map( ( [ name, icon ] ) => {
|
2020-06-26 14:22:41 +00:00
|
|
|
return (
|
|
|
|
<div
|
|
|
|
key={ name }
|
|
|
|
style={ {
|
|
|
|
display: 'flex',
|
2021-05-16 17:59:32 +00:00
|
|
|
flexDirection: 'column',
|
2020-06-26 14:22:41 +00:00
|
|
|
width: '25%',
|
|
|
|
padding: '25px 0 25px 0',
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
<strong
|
|
|
|
style={ {
|
|
|
|
width: '200px',
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
{ name }
|
|
|
|
</strong>
|
|
|
|
<div
|
|
|
|
style={ {
|
|
|
|
display: 'flex',
|
|
|
|
alignItems: 'center',
|
|
|
|
} }
|
|
|
|
>
|
|
|
|
<Icon
|
2021-12-02 16:56:53 +00:00
|
|
|
className={ args.className }
|
2022-02-01 16:54:38 +00:00
|
|
|
icon={ icon }
|
2021-12-02 16:56:53 +00:00
|
|
|
/>
|
|
|
|
<Icon
|
|
|
|
className={ args.className }
|
2021-05-16 17:59:32 +00:00
|
|
|
style={ { paddingLeft: '10px' } }
|
2022-02-01 16:54:38 +00:00
|
|
|
icon={ icon }
|
2020-06-26 14:22:41 +00:00
|
|
|
size={ 36 }
|
|
|
|
/>
|
|
|
|
<Icon
|
2021-12-02 16:56:53 +00:00
|
|
|
className={ args.className }
|
2021-05-16 17:59:32 +00:00
|
|
|
style={ { paddingLeft: '10px' } }
|
2022-02-01 16:54:38 +00:00
|
|
|
icon={ icon }
|
2020-06-26 14:22:41 +00:00
|
|
|
size={ 48 }
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} ) }
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2021-12-02 16:56:53 +00:00
|
|
|
Library.parameters = {
|
|
|
|
controls: { include: [], hideNoControlsWarning: true },
|
|
|
|
};
|
|
|
|
Library.storyName = 'Icon Library';
|