import { useState } from 'react'; import type { Meta, StoryObj } from '@storybook/react'; import { Switch } from './Switch'; import { Typography } from '../Typography'; import { Card } from '../Card'; import Box from '@mui/material/Box'; import FormControlLabel from '@mui/material/FormControlLabel'; import FormGroup from '@mui/material/FormGroup'; const meta: Meta = { title: 'Atoms/Switch', component: Switch, tags: ['autodocs'], parameters: { layout: 'centered', design: { type: 'figma', url: 'https://www.figma.com/design/XUDUrw4yMkEexBCCYHXUvT/Parsons?node-id=2322-42538', }, }, argTypes: { checked: { control: 'boolean', description: 'Whether the switch is on', }, disabled: { control: 'boolean', description: 'Disable the switch', table: { defaultValue: { summary: 'false' } }, }, }, }; export default meta; type Story = StoryObj; // ─── Default ──────────────────────────────────────────────────────────────── /** Default switch — unchecked */ export const Default: Story = { args: {}, }; // ─── States ───────────────────────────────────────────────────────────────── /** All visual states */ export const States: Story = { render: () => ( } label="Unchecked" /> } label="Checked" /> } label="Disabled unchecked" /> } label="Disabled checked" /> ), }; // ─── Interactive: Service Add-ons ─────────────────────────────────────────── /** * Realistic arrangement form pattern — toggle add-on services. */ export const ServiceAddOns: Story = { name: 'Interactive — Service Add-ons', render: () => { const AddOnDemo = () => { const [addOns, setAddOns] = useState({ catering: true, flowers: true, music: false, memorial: false, guestBook: false, }); const toggle = (key: keyof typeof addOns) => { setAddOns((prev) => ({ ...prev, [key]: !prev[key] })); }; const items = [ { key: 'catering' as const, label: 'Catering', desc: 'Light refreshments after the service', price: '$450', }, { key: 'flowers' as const, label: 'Floral arrangements', desc: 'Seasonal flowers for the chapel', price: '$280', }, { key: 'music' as const, label: 'Live music', desc: 'Organist or solo musician', price: '$350', }, { key: 'memorial' as const, label: 'Memorial video', desc: 'Photo slideshow with music', price: '$200', }, { key: 'guestBook' as const, label: 'Guest book', desc: 'Leather-bound memorial guest book', price: '$85', }, ]; const total = items.reduce( (sum, item) => (addOns[item.key] ? sum + parseInt(item.price.replace('$', ''), 10) : sum), 0, ); return ( Service add-ons {items.map((item) => ( {item.label} {item.desc} {item.price} toggle(item.key)} /> ))} Total add-ons ${total} ); }; return ; }, }; // ─── With Labels ──────────────────────────────────────────────────────────── /** FormControlLabel pairing — the recommended usage pattern */ export const WithLabels: Story = { name: 'With Labels', render: () => ( } label="Email notifications" /> } label="SMS notifications" /> } label="Save arrangement progress" /> ), };