import React, { useState } from 'react'; import { SIZES, ALIGN_ITEMS, DISPLAY, COLORS, ICON_COLORS, FLEX_DIRECTION, JUSTIFY_CONTENT, TEXT, } from '../../../helpers/constants/design-system'; import Box from '../../ui/box/box'; import { Text } from '../text'; import { Icon } from './icon'; import { ICON_NAMES } from './icon.constants'; import README from './README.mdx'; const marginSizeControlOptions = [ undefined, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 'auto', ]; export default { title: 'Components/ComponentLibrary/Icon', id: __filename, component: Icon, parameters: { docs: { page: README, }, }, argTypes: { name: { control: 'select', options: Object.values(ICON_NAMES), }, size: { control: 'select', options: Object.values(SIZES), }, color: { control: 'select', options: Object.values(ICON_COLORS), }, className: { control: 'text', }, marginTop: { options: marginSizeControlOptions, control: 'select', table: { category: 'box props' }, }, marginRight: { options: marginSizeControlOptions, control: 'select', table: { category: 'box props' }, }, marginBottom: { options: marginSizeControlOptions, control: 'select', table: { category: 'box props' }, }, marginLeft: { options: marginSizeControlOptions, control: 'select', table: { category: 'box props' }, }, }, args: { name: ICON_NAMES.ADD_SQUARE_FILLED, color: COLORS.INHERIT, size: SIZES.MD, }, }; export const DefaultStory = (args) => ; DefaultStory.storyName = 'Default'; export const Name = (args) => { const [search, setSearch] = useState(''); const iconList = Object.keys(ICON_NAMES) .filter( (item) => search === '' || item.toLowerCase().includes(search.toLowerCase().replace(' ', '_')), ) .sort(); const handleSearch = (e) => { setSearch(e.target.value); }; return ( <> Icon search {iconList.length > 0 ? ( <> {iconList.map((item) => { return ( { const tempEl = document.createElement('textarea'); tempEl.value = item; document.body.appendChild(tempEl); tempEl.select(); document.execCommand('copy'); document.body.removeChild(tempEl); }} > {item} ); })} ) : ( No matches. Please try again or ask in the{' '} #metamask-design-system {' '} channel on slack. )} ); }; export const Size = (args) => ( <> Auto also exists and inherits the font-size of the parent element. ); export const Color = (args) => ( );