import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { fn } from 'storybook/test'; import { Checkpoint, CheckpointIcon, CheckpointTrigger } from './checkpoint'; import { componentDescription } from '../stories/docs/element-controls'; const meta = { title: 'Solid (Advanced)/Elements/Checkpoint', component: Checkpoint, tags: ['autodocs'], parameters: { layout: 'padded', docs: { description: componentDescription([ 'An inline marker that lets a user restore the conversation to a saved point. Composed of `Checkpoint` (row + separator) wrapping a `CheckpointIcon` and a `CheckpointTrigger` button.', '**When to use:** to mark a restorable state in a transcript — e.g. before an edit or a branching action — so the user can revert to it.', '**How to use:** place a `CheckpointIcon` and a `CheckpointTrigger` inside `Checkpoint`. Give the trigger an `onClick` handler and an optional `tooltip`; pass custom SVG children to `CheckpointIcon` to override the default flag.', '**Placement:** between messages in a chat transcript, as a thin separator-style row.', ]), controls: { exclude: ['use:eventListener'] }, }, }, argTypes: { children: { control: false, description: 'The `CheckpointIcon` and `CheckpointTrigger` contents.', }, class: { control: 'text', description: 'Extra classes for the checkpoint row.', }, }, args: {}, render: (args) => (
Restore
), } satisfies Meta; export default meta; type Story = StoryObj; const IMPORT = `import { Checkpoint, CheckpointIcon, CheckpointTrigger } from '@kitn.ai/chat';`; const src = (code: string) => ({ parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } }, }); /** Interactive playground — the default flag icon with a restore trigger. */ export const Playground: Story = { ...src(` Restore `), }; export const WithCustomIcon: Story = { render: () => (
Revert to checkpoint
), ...src(` Revert to checkpoint `), }; export const NoTooltip: Story = { render: () => (
Restore
), ...src(` Restore `), };