import React, { useState } from 'react'; import { Meta, Story } from '@storybook/react'; import CheckboxLabeled, { ICheckboxLabeledProps } from './CheckboxLabeled'; export default { title: 'Controls/CheckboxLabeled', component: CheckboxLabeled, subcomponents: { 'CheckboxLabeled.Label': CheckboxLabeled.Label }, parameters: { docs: { description: { component: CheckboxLabeled.peek.description, }, }, }, } as Meta; const Template: Story = (args) => { const [selected, setSelected] = useState(args.isSelected || false); return ( setSelected(!selected)} /> ); }; export const Basic: Story = Template.bind({}); Basic.args = { title: 'Default', Label: 'Default', }; export const Disabled: Story = Template.bind({}); Disabled.args = { title: 'Disabled', Label: 'Disabled', isDisabled: true, }; export const Selected: Story = Template.bind({}); Selected.args = { title: 'Selected', Label: 'Selected', isSelected: true, }; export const DisabledSelected: Story = Template.bind({}); DisabledSelected.args = { title: 'Disabled Selected', Label: 'Disabled Selected', isDisabled: true, isSelected: true, }; export const LabelAsProp: Story = Template.bind({}); LabelAsProp.args = { Label: 'Label as prop', title: 'Label as prop', }; export const HTMLElement: Story = Template.bind({}); HTMLElement.args = { Label: HTML element, title: 'HTML element', }; export const TextInAnArray: Story = Template.bind({}); TextInAnArray.args = { Label: [ 'Text in an array', 'Only the first value in the array is used', 'The rest of these should be ignored', ], title: 'Text in an array', }; export const HTMLElementInAnArray: Story = Template.bind( {} ); HTMLElementInAnArray.args = { Label: [ HTML element in an array, Again only the first value in the array is used, The rest should not be rendered, ] as any, title: 'HTML element in an array', }; export const LabelAsChild: Story = (args) => { const [selected, setSelected] = useState(args.isSelected || false); return ( setSelected(!selected)} > HTML element as Child ); }; LabelAsChild.args = { title: 'Label as Child', };