import { ComponentMeta } from '@storybook/react'; import { DropdownMenu, DropdownMenuAlignment, DropdownMenuSize } from '@tih/ui'; import React, { useState } from 'react'; const DropdownMenuAlignments: ReadonlyArray = [ 'start', 'end', ]; const DropdownMenuSizes: ReadonlyArray = [ 'inherit', 'regular', ]; export default { title: 'DropdownMenu', component: DropdownMenu, parameters: { docs: { inlineStories: false, iframeHeight: 300, }, }, argTypes: { align: { options: DropdownMenuAlignments, control: { type: 'select' }, }, label: { control: 'text', }, size: { options: DropdownMenuSizes, control: { type: 'select' }, }, }, } as ComponentMeta; export function Basic({ align, label, size }) { const menuItems = [ { label: 'Apple', value: 'apple', }, { label: 'Banana', value: 'banana', }, { label: 'Orange', value: 'orange', }, ]; const [selectedValue, setSelectedValue] = useState('apple'); return ( {menuItems.map(({ label, value }) => ( { setSelectedValue(value); }} /> ))} ); } Basic.args = { align: 'start', label: 'Select fruitzz', size: 'regular', }; export function Align() { const menuItems = [ { label: 'Apple', value: 'apple', }, { label: 'Banana', value: 'banana', }, { label: 'Orange', value: 'orange', }, ]; const [selectedValue, setSelectedValue] = useState('apple'); return (
{menuItems.map(({ label, value }) => ( { setSelectedValue(value); }} /> ))} {menuItems.map(({ label, value }) => ( { setSelectedValue(value); }} /> ))}
); }