import type { Meta, StoryObj } from 'storybook-solidjs-vite';
import { fn } from 'storybook/test';
import { PromptSuggestion } from './prompt-suggestion';
import { componentDescription } from '../stories/docs/element-controls';
const meta = {
title: 'Solid (Advanced)/Elements/PromptSuggestion',
component: PromptSuggestion,
tags: ['autodocs'],
parameters: {
layout: 'padded',
docs: {
description: componentDescription([
'A clickable suggestion chip built on `Button` — renders as a rounded pill, a full-width list row (`block`), or a search-style row that highlights a matching substring (`highlight`).',
'**When to use:** offer the user ready-made prompts to send — empty-state starter questions, follow-up suggestions, or a filtered list of matching prompts as they type.',
'**How to use:** pass the prompt text as children and wire `onClick` to submit it. Use `block` for stacked, left-aligned list rows; pass `highlight` to emphasize a matched substring (forces list-row layout). Override `variant`/`size` to restyle.',
'**Placement:** chat empty states, below the prompt input as follow-ups, or in a suggestion dropdown.',
]),
controls: { exclude: ['use:eventListener'] },
},
},
argTypes: {
children: {
control: 'text',
description: 'Suggestion content — the prompt text (or an element).',
},
variant: {
control: 'select',
options: ['default', 'ghost', 'outline'],
description: 'Button visual emphasis. Defaults vary by mode (`outline` pill, `ghost` highlight).',
table: { defaultValue: { summary: 'outline' } },
},
size: {
control: 'select',
options: ['sm', 'md', 'lg', 'icon', 'icon-sm'],
description: 'Button size preset. Defaults vary by mode.',
table: { defaultValue: { summary: 'lg' } },
},
highlight: {
control: 'text',
description: 'Substring to emphasize within the text. When set, renders as a list row with the match highlighted.',
},
block: {
control: 'boolean',
description: 'Render as a full-width, left-aligned list row that wraps long text instead of a pill. Ignored in highlight mode.',
table: { defaultValue: { summary: 'false' } },
},
onClick: {
action: 'click',
description: 'Fired when the suggestion is clicked.',
table: { category: 'Events' },
},
},
args: {
children: 'Tell me about TypeScript',
variant: 'outline',
block: false,
onClick: fn(),
},
render: (args) => ,
} satisfies Meta;
export default meta;
type Story = StoryObj;
const IMPORT = `import { PromptSuggestion } from '@kitn.ai/chat';`;
const src = (code: string) => ({
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
});
/** Interactive playground — tweak the controls to explore every mode. */
export const Playground: Story = {
...src(` send('Tell me about TypeScript')}>
Tell me about TypeScript
`),
};
export const WithHighlight: Story = {
args: { highlight: 'TypeScript', children: 'Tell me about TypeScript generics' },
...src(`
Tell me about TypeScript generics
`),
};
export const Block: Story = {
name: 'Block (list idiom)',
args: { block: true, children: 'What does being a Catalyst mean for how I work with others?' },
...src(`
What does being a Catalyst mean for how I work with others?
`),
};
/** A row of pill suggestions (showcase — not driven by controls). */
export const MultipleSuggestions: Story = {
render: () => (
What is SolidJS?
Explain reactive signals
Compare SolidJS vs React
Best practices for state management
),
...src(`
What is SolidJS?
Explain reactive signals
Compare SolidJS vs React
Best practices for state management
`),
};
/** Filtered list with a highlighted match (showcase). */
export const WithHighlightedSearch: Story = {
render: () => (
How does SolidJS handle reactivity?
What makes SolidJS fast?
SolidJS vs Svelte comparison
),
...src(`
How does SolidJS handle reactivity?
What makes SolidJS fast?
SolidJS vs Svelte comparison
`),
};
/** Stacked, full-width list rows (showcase). */
export const BlockList: Story = {
name: 'Block list',
render: () => (
What does being a Catalyst mean for how I work with others?
How do my Dominance and Influence styles play off each other?
Where might my lower Conscientiousness trip me up?
),
...src(`
What does being a Catalyst mean for how I work with others?
How do my Dominance and Influence styles play off each other?
Where might my lower Conscientiousness trip me up?
`),
};