import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { createSignal } from 'solid-js'; import { ConfirmCard, type ConfirmCardData } from './confirm-card'; import { componentDescription } from '../stories/docs/element-controls'; import type { CardEvent, CardHost, CardContext } from '../primitives/card-contract'; const ctx: CardContext = { theme: { mode: 'light' }, locale: 'en' }; /** Renders the Solid with a capturing `host`, logging emitted events. */ function Demo(props: { def: ConfirmCardData; heading?: string; cardId: string }) { const [log, setLog] = createSignal([]); const host: CardHost = { context: () => ctx, emit: (e) => setLog((p) => [...p, e]) }; return (
        {log().length === 0 ? '// emitted CardEvents appear here' : JSON.stringify(log(), null, 2)}
      
); } const APPROVE: ConfirmCardData = { body: 'This will apply 3 pending migrations to production. This cannot be undone.', tone: 'warning', actions: [ { id: 'approve', label: 'Run migration', style: 'primary', default: true }, { id: 'reject', label: 'Cancel' }, ], }; const DESTRUCTIVE: ConfirmCardData = { body: 'Permanently delete 12 files? This cannot be undone.', tone: 'danger', actions: [ { id: 'delete', label: 'Delete files', style: 'destructive', default: true }, { id: 'cancel', label: 'Keep them' }, ], }; const meta = { title: 'Solid (Advanced)/Elements/ConfirmCard', component: ConfirmCard, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: componentDescription([ 'The SolidJS layer behind ``. Pass a `host` (a `CardHost`) to receive the emitted `CardEvent`s directly (the native-host path), or wrap in a `CardProvider`. Activating an action emits the `action` verb and resolves the card.', ]), }, }, } satisfies Meta; export default meta; type Story = StoryObj; export const ApproveReject: Story = { render: () => , }; export const Destructive: Story = { render: () => , };