import React from 'react' import { StoryFn, Meta } from '@storybook/react' import Reset from '../components/decorator-reset' import { useControls } from '../../src' export default { title: 'Inputs/Select', decorators: [Reset], } as Meta const Template: StoryFn = (args) => { const values = useControls({ foo: args, }) return (
{JSON.stringify(values, null, '  ')}
) } export const Simple = Template.bind({}) Simple.args = { value: 'x', options: ['x', 'y'], } export const CustomLabels = Template.bind({}) CustomLabels.args = { value: 'helloWorld', options: { 'Hello World': 'helloWorld', 'Leva is awesome!': 'leva', }, } export const InferredValueAsOption = Template.bind({}) InferredValueAsOption.args = { value: true, options: [false], } export const DifferentOptionTypes = Template.bind({}) DifferentOptionTypes.args = { value: undefined, options: ['x', 'y', ['x', 'y']], } const IconA = () => IconA const IconB = () => IconB export const FunctionAsOptions = () => { const values = useControls({ foo: { options: { none: '', IconA, IconB } }, }) return (
{values.foo.toString()}
) }