import React, { useState } from 'react'; import type { ComponentMeta } from '@storybook/react'; import type { RadioListOrientation } from '@tih/ui'; import { HorizontalDivider } from '@tih/ui'; import { RadioList } from '@tih/ui'; const RadioListOrientations: ReadonlyArray = [ 'horizontal', 'vertical', ]; export default { argTypes: { description: { control: 'text', }, label: { control: 'text', }, orientation: { control: { type: 'select' }, options: RadioListOrientations, }, }, component: RadioList, title: 'RadioList', } as ComponentMeta; export function Basic({ description, label, }: Pick, 'description' | 'label'>) { const items = [ { label: 'Apple', value: 'apple', }, { label: 'Banana', value: 'banana', }, { label: 'Orange', value: 'orange', }, ]; return ( {items.map(({ label: itemLabel, value }) => ( ))} ); } Basic.args = { description: 'Your favorite fruit', label: 'Choose a fruit', }; export function Controlled() { const items = [ { label: 'Apple', value: 'apple', }, { label: 'Banana', value: 'banana', }, { label: 'Orange', value: 'orange', }, ]; const [value, setValue] = useState('apple'); return ( setValue(newValue)}> {items.map(({ label: itemLabel, value: itemValue }) => ( ))} ); } export function Orientation() { const items = [ { label: 'Apple', value: 'apple', }, { label: 'Banana', value: 'banana', }, { label: 'Orange', value: 'orange', }, ]; return (
{items.map(({ label: itemLabel, value: itemValue }) => ( ))} {items.map(({ label: itemLabel, value: itemValue }) => ( ))}
); }