import React, { useState } from 'react'; import type { ComponentMeta } from '@storybook/react'; import type { DropdownMenuAlignment, DropdownMenuSize } from '@tih/ui'; import { DropdownMenu } from '@tih/ui'; const DropdownMenuAlignments: ReadonlyArray = [ 'start', 'end', ]; const DropdownMenuSizes: ReadonlyArray = [ 'inherit', 'regular', ]; export default { argTypes: { align: { control: { type: 'select' }, options: DropdownMenuAlignments, }, label: { control: 'text', }, size: { control: { type: 'select' }, options: DropdownMenuSizes, }, }, component: DropdownMenu, parameters: { docs: { iframeHeight: 300, inlineStories: false, }, }, title: 'DropdownMenu', } as ComponentMeta; export function Basic({ align, label, size, }: Pick< React.ComponentProps, '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: itemLabel, 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); }} /> ))}
); }