import React from 'react' import { Button, Flex, Tag } from '../' import { Action, actions, Story } from '../helpers/storybook' const options = [ { label: 'this', id: 'tag-1', }, { label: 'is', id: 'tag-2', }, { label: 'an', id: 'tag-3', }, { label: 'example', id: 'tag-4', }, ] export default { title: 'Tag', component: Tag, argTypes: { ...actions('onCloseIconClick'), closeOption: { options: ['none', 'button', 'no-button'], mapping: { none: false } }, }, } as const type TagStory = Story }> export const WithCloseOption: TagStory = ({ closeOption, onCloseIconClick }) => { const [values, setValues] = React.useState(options) const onClose = (event: React.MouseEvent) => { const removeId = event.currentTarget.getAttribute('aria-controls') setValues(values.filter((v) => v.id !== removeId)) } const deleteTag = closeOption ? onCloseIconClick.wrap(onClose) : undefined return (
{values.map((e) => ( {e.label} ))}
{closeOption && ( )}
) } WithCloseOption.args = { closeOption: 'button' } WithCloseOption.storyName = 'With close option'