import { type Meta, type StoryObj } from '@storybook/react-vite' import React, { useState } from 'react' import { DocsTemplate } from '../../../.storybook' import Switch from './Switch' import { toast } from '../Toast/Toast' const meta: Meta = { title: 'Components/Switch', component: Switch, parameters: { design: { type: 'figma', url: 'https://www.figma.com/design/RvhKD82948FMQnh5MyCi0o/Web-Design-System?node-id=121-347&p=f&t=9R4mlUY42yEaNlLp-0', }, docs: { page: () => ( The Switch component is a user interface element that allows users to switch between two states, typically representing an "on" and "off" state. It returns a boolean value, either{' '} true or false, indicating the current state of the switch. It is commonly used in forms and settings panels to enable users to turn specific features or options on or off. } infoBullets={[ Include the Switch component within forms or settings sections where users need to make binary choices or enable/disable specific functionalities. , ]} /> ), }, }, } export default meta type Story = StoryObj const Template: Story = { render: function Render(args) { const [checked, setChecked] = useState(args.checked) const callout = (val) => { setChecked(val) } return ( ) }, } export const Basic: Story = { ...Template, args: { checked: true, }, } export const Disabled: Story = { ...Template, args: { checked: true, disabled: true, }, } const ConfirmationTemplate: StoryObj = { render: function Render(args) { const [checked, setChecked] = useState(args.checked) return ( { toast({ message: 'You did it!', type: 'success' }) setChecked(!checked) }, }} callout={undefined} /> ) }, } const confirmation = { header: 'Are you sure?', type: 'blue' as const, body: 'This will perform some action. Would you like to continue?', } export const WithConfirmation: Story = { ...ConfirmationTemplate, args: { checked: true, confirmation: { ...confirmation, confirmCallout: () => {}, }, }, } export const ConfirmationPlacement: Story = { ...ConfirmationTemplate, args: { checked: true, confirmation: { ...confirmation, confirmCallout: () => {}, }, popoverProps: { position: 'left', children: () => <>, popoverContent: () => <>, }, }, }