import type { Meta, StoryObj } from 'storybook-solidjs-vite'; import { Message, MessageAvatar, MessageContent } from './message'; import { ChatContainer } from './chat-container'; import { ChatConfig } from '../primitives/chat-config'; import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../ui/resizable'; import { componentDescription } from '../stories/docs/element-controls'; const meta = { title: 'Solid (Advanced)/Elements/Message/Narrow Panel', component: Message, tags: ['autodocs'], parameters: { layout: 'centered', docs: { controls: { exclude: ['use:eventListener'] }, description: componentDescription([ 'Layout stress-tests for `Message` inside narrow chat panels (300–380px) and resizable side panels, verifying text wraps and the 32px avatar stays fixed.', '**When to use:** as a reference when embedding the chat in a constrained column — a browser-extension side panel, a docked drawer, or a resizable split view.', '**How to use:** wrap messages in a fixed/min-width container (and usually `ChatConfig proseSize="sm"`), keeping `min-w-0` on flex children so long text wraps instead of overflowing.', '**Placement:** these are full-composition showcases, not control-driven; use them to copy the surrounding panel structure.', ]), }, }, argTypes: { class: { control: 'text', description: 'Layout classes for the message row.', }, }, render: (args) => (
{longText}
), } satisfies Meta; export default meta; type Story = StoryObj; const IMPORT = `import { Message, MessageAvatar, MessageContent, ChatContainer, ChatConfig } from '@kitn.ai/chat';`; const src = (code: string) => ({ parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } }, }); const longText = 'The document is a transcript of a YouTube video where Andre Karpathy discusses building AI agents using large language models. He explains how he structures his personal knowledge base and shares techniques for prompt engineering that maximize output quality.'; /** Default render — a single message inside a 380px card; tweak `class` via controls. */ export const Playground: Story = { ...src(`
{longText}
`), }; /** Simulates the chat panel at 380px — the default width in the detail page. */ export const NarrowPanel380: Story = { render: () => (
New Thread
{longText}
), ...src(`
{longText}
`), }; /** Even narrower — 300px minimum width with two messages. */ export const NarrowPanel300: Story = { render: () => (
New Thread
{longText} A shorter reply.
), ...src(`
{longText}
`), }; /** Without ChatContainer — isolates the Message component's own wrapping. */ export const NarrowDivOnly: Story = { render: () => (
{longText}
), ...src(`
{longText}
`), }; /** The avatar in isolation — verifies it stays a fixed 32px. */ export const AvatarIsolation: Story = { render: () => (
{longText}
), ...src(`
{longText}
`), }; /** Reproduces the full extension layout — left nav, content column, resizable chat. */ export const FullExtensionLayout: Story = { render: () => (
Left Nav
Content
Summary
Key Points
Header Bar

Article Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

New Thread
{longText} {longText + ' ' + longText}
Ask about this page...
), ...src(` {/* article */} {longText} `), }; /** A simpler resizable split — main content beside a chat panel. */ export const InsideResizablePanel: Story = { render: () => (

Main content area — this simulates the article/transcript view

New Thread
{longText} A short reply to test mixed lengths. {longText + ' ' + longText}
Ask about this page...
), ...src(` {/* main content */} {longText} `), };