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 Required() { 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 Disabled() { const items = [ { description: 'A red fruit', disabled: false, label: 'Apple', value: 'apple', }, { description: 'A yellow fruit', disabled: true, label: 'Banana', value: 'banana', }, { description: 'An orange fruit', disabled: false, label: 'Orange', value: 'orange', }, ]; const [value, setValue] = useState('apple'); return (
setValue(newValue)}> {items.map(({ label: itemLabel, value: itemValue }) => ( ))} {items.map( ({ description, label: itemLabel, value: itemValue, disabled }) => ( ), )}
); } export function ItemDescriptions() { const items = [ { description: 'A red fruit', label: 'Apple', value: 'apple', }, { description: 'A yellow fruit', label: 'Banana', value: 'banana', }, { description: 'An orange fruit', label: 'Orange', value: 'orange', }, ]; const [value, setValue] = useState('apple'); return ( setValue(newValue)}> {items.map(({ description, 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 }) => ( ))}
); }