@kitnai/chat 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +314 -0
- package/dist/bash-InADTalH.js +6 -0
- package/dist/core-AYMC6_lb.js +5874 -0
- package/dist/engine-javascript-vq0WuIJl.js +2643 -0
- package/dist/github-dark-dimmed-DUshB20C.js +4 -0
- package/dist/github-light-JYsPkUQd.js +4 -0
- package/dist/javascript-C25yR2R2.js +6 -0
- package/dist/json-DxJze_jm.js +6 -0
- package/dist/kitn-chat.es.js +6632 -0
- package/dist/tsx-B8rCNbgL.js +6 -0
- package/dist/typescript-RycA9KXf.js +6 -0
- package/package.json +80 -0
- package/src/components/attachments.stories.tsx +304 -0
- package/src/components/attachments.tsx +394 -0
- package/src/components/chain-of-thought.stories.tsx +212 -0
- package/src/components/chain-of-thought.tsx +139 -0
- package/src/components/chat-container.stories.tsx +188 -0
- package/src/components/chat-container.tsx +78 -0
- package/src/components/chat-scope-picker.tsx +47 -0
- package/src/components/checkpoint.stories.tsx +103 -0
- package/src/components/checkpoint.tsx +81 -0
- package/src/components/code-block.stories.tsx +151 -0
- package/src/components/code-block.tsx +99 -0
- package/src/components/context.stories.tsx +180 -0
- package/src/components/context.tsx +323 -0
- package/src/components/conversation-item.stories.tsx +126 -0
- package/src/components/conversation-item.tsx +18 -0
- package/src/components/conversation-list.stories.tsx +134 -0
- package/src/components/conversation-list.tsx +100 -0
- package/src/components/empty.stories.tsx +435 -0
- package/src/components/empty.tsx +166 -0
- package/src/components/feedback-bar.stories.tsx +101 -0
- package/src/components/feedback-bar.tsx +58 -0
- package/src/components/file-upload.stories.tsx +157 -0
- package/src/components/file-upload.tsx +161 -0
- package/src/components/image.stories.tsx +90 -0
- package/src/components/image.tsx +67 -0
- package/src/components/loader.stories.tsx +182 -0
- package/src/components/loader.tsx +333 -0
- package/src/components/markdown.stories.tsx +181 -0
- package/src/components/markdown.tsx +81 -0
- package/src/components/message-narrow.stories.tsx +330 -0
- package/src/components/message-skills.stories.tsx +212 -0
- package/src/components/message-skills.tsx +36 -0
- package/src/components/message.stories.tsx +282 -0
- package/src/components/message.tsx +149 -0
- package/src/components/model-switcher.stories.tsx +98 -0
- package/src/components/model-switcher.tsx +36 -0
- package/src/components/prompt-input.stories.tsx +223 -0
- package/src/components/prompt-input.tsx +190 -0
- package/src/components/prompt-suggestion.stories.tsx +143 -0
- package/src/components/prompt-suggestion.tsx +115 -0
- package/src/components/reasoning.stories.tsx +141 -0
- package/src/components/reasoning.tsx +157 -0
- package/src/components/response-stream.tsx +103 -0
- package/src/components/scroll-button.stories.tsx +101 -0
- package/src/components/scroll-button.tsx +33 -0
- package/src/components/slash-command.stories.tsx +164 -0
- package/src/components/slash-command.tsx +223 -0
- package/src/components/source.stories.tsx +125 -0
- package/src/components/source.tsx +129 -0
- package/src/components/text-shimmer.stories.tsx +88 -0
- package/src/components/text-shimmer.tsx +37 -0
- package/src/components/thinking-bar.stories.tsx +88 -0
- package/src/components/thinking-bar.tsx +50 -0
- package/src/components/tool.stories.tsx +154 -0
- package/src/components/tool.tsx +173 -0
- package/src/components/voice-input.stories.tsx +84 -0
- package/src/components/voice-input.tsx +103 -0
- package/src/elements/chat-types.ts +14 -0
- package/src/elements/chat.tsx +111 -0
- package/src/elements/compiled.css +2 -0
- package/src/elements/conversation-list.tsx +26 -0
- package/src/elements/css.ts +5 -0
- package/src/elements/default-input.tsx +53 -0
- package/src/elements/define.tsx +54 -0
- package/src/elements/kitn-chat.stories.tsx +105 -0
- package/src/elements/kitn-conversation-list.stories.tsx +177 -0
- package/src/elements/kitn-prompt-input.stories.tsx +123 -0
- package/src/elements/prompt-input.tsx +39 -0
- package/src/elements/register.ts +9 -0
- package/src/elements/styles.css +12 -0
- package/src/index.ts +128 -0
- package/src/primitives/chat-config.tsx +76 -0
- package/src/primitives/highlighter.ts +150 -0
- package/src/primitives/use-auto-resize.ts +31 -0
- package/src/primitives/use-stick-to-bottom.ts +43 -0
- package/src/primitives/use-text-stream.ts +112 -0
- package/src/primitives/use-voice-recorder.ts +50 -0
- package/src/stories/chat-panel-layout.stories.tsx +144 -0
- package/src/stories/chat-scene.tsx +570 -0
- package/src/stories/checkpoint-restore.stories.tsx +224 -0
- package/src/stories/context-usage.stories.tsx +155 -0
- package/src/stories/conversation-with-reasoning.stories.tsx +151 -0
- package/src/stories/conversation-with-sources.stories.tsx +165 -0
- package/src/stories/docs/GettingStarted.mdx +76 -0
- package/src/stories/docs/Installation.mdx +48 -0
- package/src/stories/docs/Integrations.mdx +110 -0
- package/src/stories/docs/Introduction.mdx +29 -0
- package/src/stories/docs/Theming.mdx +87 -0
- package/src/stories/docs/theme-editor/canvas.tsx +32 -0
- package/src/stories/docs/theme-editor/inspector.tsx +66 -0
- package/src/stories/docs/theme-editor/presets.test.ts +32 -0
- package/src/stories/docs/theme-editor/presets.ts +64 -0
- package/src/stories/docs/theme-editor/theme-css.test.ts +19 -0
- package/src/stories/docs/theme-editor/theme-css.ts +15 -0
- package/src/stories/docs/theme-editor/theme-editor.tsx +145 -0
- package/src/stories/docs/theme-tokens.tsx +174 -0
- package/src/stories/full-chat.stories.tsx +18 -0
- package/src/stories/message-actions.stories.tsx +167 -0
- package/src/stories/prompt-input-variants.stories.tsx +179 -0
- package/src/stories/streaming-response.stories.tsx +234 -0
- package/src/stories/theme-editor.stories.tsx +16 -0
- package/src/stories/token-reference.stories.tsx +18 -0
- package/src/types.ts +41 -0
- package/src/ui/avatar.stories.tsx +104 -0
- package/src/ui/avatar.tsx +23 -0
- package/src/ui/badge.stories.tsx +87 -0
- package/src/ui/badge.tsx +21 -0
- package/src/ui/button.stories.tsx +146 -0
- package/src/ui/button.tsx +37 -0
- package/src/ui/collapsible.tsx +14 -0
- package/src/ui/dialog.tsx +21 -0
- package/src/ui/dropdown.tsx +26 -0
- package/src/ui/hover-card.tsx +48 -0
- package/src/ui/resizable.stories.tsx +171 -0
- package/src/ui/resizable.tsx +219 -0
- package/src/ui/scroll-area.tsx +13 -0
- package/src/ui/separator.stories.tsx +82 -0
- package/src/ui/separator.tsx +10 -0
- package/src/ui/skeleton.stories.tsx +338 -0
- package/src/ui/skeleton.tsx +16 -0
- package/src/ui/textarea.tsx +21 -0
- package/src/ui/tooltip.stories.tsx +75 -0
- package/src/ui/tooltip.tsx +22 -0
- package/src/utils/cn.ts +6 -0
- package/theme.css +115 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
+
import { Markdown } from './markdown';
|
|
3
|
+
|
|
4
|
+
const meta = {
|
|
5
|
+
title: 'Components/Markdown',
|
|
6
|
+
component: Markdown,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: 'padded',
|
|
10
|
+
docs: {
|
|
11
|
+
controls: { exclude: ['use:eventListener'] },
|
|
12
|
+
description: {
|
|
13
|
+
component: [
|
|
14
|
+
'Renders a Markdown string to styled HTML (GFM enabled — tables, lists, blockquotes), splitting fenced code into highlighted `CodeBlock`s.',
|
|
15
|
+
'**When to use:** to display assistant message content, documentation, or any rich text authored in Markdown.',
|
|
16
|
+
'**How to use:** pass the Markdown string as `content`; optionally set `codeTheme` for code fences and `class` for the prose container. Prose sizing follows the surrounding `ChatConfig`.',
|
|
17
|
+
'**Placement:** inside `MessageContent`, response panels, or anywhere formatted text is shown.',
|
|
18
|
+
].join('\n\n'),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
argTypes: {
|
|
23
|
+
content: {
|
|
24
|
+
control: 'text',
|
|
25
|
+
description: 'The Markdown source string to render.',
|
|
26
|
+
},
|
|
27
|
+
id: {
|
|
28
|
+
control: 'text',
|
|
29
|
+
description: 'Optional stable id used for block keys (auto-generated if omitted).',
|
|
30
|
+
},
|
|
31
|
+
codeTheme: {
|
|
32
|
+
control: 'text',
|
|
33
|
+
description: 'Shiki theme name applied to fenced code blocks (falls back to the chat config theme).',
|
|
34
|
+
},
|
|
35
|
+
class: {
|
|
36
|
+
control: 'text',
|
|
37
|
+
description: 'Additional CSS classes for the prose container.',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
args: {
|
|
41
|
+
content: 'This is a simple paragraph of text rendered through the **Markdown** component.',
|
|
42
|
+
},
|
|
43
|
+
render: (args) => <Markdown {...args} />,
|
|
44
|
+
} satisfies Meta<typeof Markdown>;
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
type Story = StoryObj<typeof meta>;
|
|
48
|
+
|
|
49
|
+
const IMPORT = `import { Markdown } from '@kitnai/chat';`;
|
|
50
|
+
const src = (code: string) => ({
|
|
51
|
+
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/** Interactive playground — edit the `content` control to render any Markdown. */
|
|
55
|
+
export const Playground: Story = {
|
|
56
|
+
...src(`<Markdown content="This is a simple paragraph of **Markdown** text." />`),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const PlainText: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
content: 'This is a simple paragraph of text rendered through the Markdown component.',
|
|
62
|
+
},
|
|
63
|
+
...src(`<Markdown content="This is a simple paragraph of text rendered through the Markdown component." />`),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const Headings: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
content: `# Heading 1
|
|
69
|
+
## Heading 2
|
|
70
|
+
### Heading 3
|
|
71
|
+
#### Heading 4
|
|
72
|
+
|
|
73
|
+
Some text below the headings.`,
|
|
74
|
+
},
|
|
75
|
+
...src(`<Markdown content={\`# Heading 1
|
|
76
|
+
## Heading 2
|
|
77
|
+
### Heading 3
|
|
78
|
+
|
|
79
|
+
Some text below the headings.\`} />`),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const CodeBlocks: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
content: `Here is some inline \`code\` in a paragraph.
|
|
85
|
+
|
|
86
|
+
\`\`\`typescript
|
|
87
|
+
const x: number = 42;
|
|
88
|
+
console.log(x);
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
And another block:
|
|
92
|
+
|
|
93
|
+
\`\`\`python
|
|
94
|
+
print("hello world")
|
|
95
|
+
\`\`\``,
|
|
96
|
+
},
|
|
97
|
+
...src(`<Markdown content={\`Here is some inline \\\`code\\\` in a paragraph.
|
|
98
|
+
|
|
99
|
+
\\\`\\\`\\\`typescript
|
|
100
|
+
const x: number = 42;
|
|
101
|
+
console.log(x);
|
|
102
|
+
\\\`\\\`\\\`\`} />`),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Lists: Story = {
|
|
106
|
+
args: {
|
|
107
|
+
content: `### Unordered List
|
|
108
|
+
- First item
|
|
109
|
+
- Second item
|
|
110
|
+
- Nested item
|
|
111
|
+
- Another nested
|
|
112
|
+
- Third item
|
|
113
|
+
|
|
114
|
+
### Ordered List
|
|
115
|
+
1. Step one
|
|
116
|
+
2. Step two
|
|
117
|
+
3. Step three`,
|
|
118
|
+
},
|
|
119
|
+
...src(`<Markdown content={\`### Unordered List
|
|
120
|
+
- First item
|
|
121
|
+
- Second item
|
|
122
|
+
- Nested item
|
|
123
|
+
|
|
124
|
+
### Ordered List
|
|
125
|
+
1. Step one
|
|
126
|
+
2. Step two\`} />`),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const GFMTable: Story = {
|
|
130
|
+
args: {
|
|
131
|
+
content: `### Comparison Table
|
|
132
|
+
|
|
133
|
+
| Feature | SolidJS | React | Svelte |
|
|
134
|
+
|---------|---------|-------|--------|
|
|
135
|
+
| Reactivity | Fine-grained | Virtual DOM | Compiler |
|
|
136
|
+
| Bundle Size | ~7KB | ~40KB | ~2KB |
|
|
137
|
+
| Performance | Excellent | Good | Excellent |
|
|
138
|
+
| Learning Curve | Moderate | Moderate | Easy |`,
|
|
139
|
+
},
|
|
140
|
+
...src(`<Markdown content={\`| Feature | SolidJS | React |
|
|
141
|
+
|---------|---------|-------|
|
|
142
|
+
| Reactivity | Fine-grained | Virtual DOM |
|
|
143
|
+
| Bundle Size | ~7KB | ~40KB |\`} />`),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const RichContent: Story = {
|
|
147
|
+
args: {
|
|
148
|
+
class: 'max-w-2xl',
|
|
149
|
+
content: `# Project Overview
|
|
150
|
+
|
|
151
|
+
This is a **comprehensive** guide to building modern web applications.
|
|
152
|
+
|
|
153
|
+
## Key Technologies
|
|
154
|
+
|
|
155
|
+
- **SolidJS** -- Reactive UI framework
|
|
156
|
+
- **TypeScript** -- Type-safe JavaScript
|
|
157
|
+
- **Tailwind CSS** -- Utility-first styling
|
|
158
|
+
|
|
159
|
+
## Getting Started
|
|
160
|
+
|
|
161
|
+
\`\`\`bash
|
|
162
|
+
pnpm create solid
|
|
163
|
+
cd my-app
|
|
164
|
+
pnpm install
|
|
165
|
+
pnpm dev
|
|
166
|
+
\`\`\`
|
|
167
|
+
|
|
168
|
+
> **Note:** Make sure you have Node.js 18+ installed.
|
|
169
|
+
|
|
170
|
+
## Architecture
|
|
171
|
+
|
|
172
|
+
| Layer | Technology | Purpose |
|
|
173
|
+
|-------|-----------|---------|
|
|
174
|
+
| UI | SolidJS | Components |
|
|
175
|
+
| State | Signals | Reactivity |
|
|
176
|
+
| Styling | Tailwind | Design |
|
|
177
|
+
|
|
178
|
+
For more info, visit [solidjs.com](https://solidjs.com).`,
|
|
179
|
+
},
|
|
180
|
+
...src(`<Markdown class="max-w-2xl" content={richMarkdown} />`),
|
|
181
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { splitProps, createMemo, createUniqueId, For, Show, Switch, Match } from 'solid-js';
|
|
2
|
+
import { cn } from '../utils/cn';
|
|
3
|
+
import { marked } from 'marked';
|
|
4
|
+
import { CodeBlock, CodeBlockCode } from './code-block';
|
|
5
|
+
import { useChatConfig, textClass } from '../primitives/chat-config';
|
|
6
|
+
|
|
7
|
+
marked.setOptions({ gfm: true, breaks: true });
|
|
8
|
+
|
|
9
|
+
export interface MarkdownProps {
|
|
10
|
+
content: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
class?: string;
|
|
13
|
+
codeTheme?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface ParsedBlock {
|
|
17
|
+
type: 'markdown' | 'code';
|
|
18
|
+
content: string;
|
|
19
|
+
language?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function parseMarkdownIntoBlocks(markdown: string): ParsedBlock[] {
|
|
23
|
+
const tokens = marked.lexer(markdown);
|
|
24
|
+
return tokens.map((token) => {
|
|
25
|
+
if (token.type === 'code') {
|
|
26
|
+
return {
|
|
27
|
+
type: 'code' as const,
|
|
28
|
+
content: token.text,
|
|
29
|
+
language: token.lang || undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
type: 'markdown' as const,
|
|
34
|
+
content: token.raw,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function MarkdownBlock(props: { content: string }) {
|
|
40
|
+
const html = createMemo(() => {
|
|
41
|
+
try {
|
|
42
|
+
return marked.parse(props.content, { async: false }) as string;
|
|
43
|
+
} catch {
|
|
44
|
+
return props.content;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
return <div innerHTML={html()} />;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function Markdown(props: MarkdownProps) {
|
|
52
|
+
const [local] = splitProps(props, ['content', 'id', 'class', 'codeTheme']);
|
|
53
|
+
const config = useChatConfig();
|
|
54
|
+
const blockId = () => local.id ?? createUniqueId();
|
|
55
|
+
const blocks = createMemo(() => parseMarkdownIntoBlocks(local.content));
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div class={cn('chat-markdown max-w-none break-words whitespace-normal [&>div:first-child>p:first-child]:mt-0 [&>div:last-child>p:last-child]:mb-0', textClass(config.proseSize()), local.class)}>
|
|
59
|
+
<For each={blocks()}>
|
|
60
|
+
{(block) => (
|
|
61
|
+
<Switch>
|
|
62
|
+
<Match when={block.type === 'code'}>
|
|
63
|
+
<CodeBlock class="my-4">
|
|
64
|
+
<CodeBlockCode
|
|
65
|
+
code={block.content}
|
|
66
|
+
language={block.language}
|
|
67
|
+
theme={local.codeTheme ?? config.codeTheme()}
|
|
68
|
+
/>
|
|
69
|
+
</CodeBlock>
|
|
70
|
+
</Match>
|
|
71
|
+
<Match when={block.type === 'markdown'}>
|
|
72
|
+
<MarkdownBlock content={block.content} />
|
|
73
|
+
</Match>
|
|
74
|
+
</Switch>
|
|
75
|
+
)}
|
|
76
|
+
</For>
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { Markdown };
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
2
|
+
import { Message, MessageAvatar, MessageContent } from './message';
|
|
3
|
+
import { ChatContainer } from './chat-container';
|
|
4
|
+
import { ChatConfig } from '../primitives/chat-config';
|
|
5
|
+
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from '../ui/resizable';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
title: 'Components/Message/Narrow Panel',
|
|
9
|
+
component: Message,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'centered',
|
|
13
|
+
docs: {
|
|
14
|
+
controls: { exclude: ['use:eventListener'] },
|
|
15
|
+
description: {
|
|
16
|
+
component: [
|
|
17
|
+
'Layout stress-tests for `Message` inside narrow chat panels (300–380px) and resizable side panels, verifying text wraps and the 32px avatar stays fixed.',
|
|
18
|
+
'**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.',
|
|
19
|
+
'**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.',
|
|
20
|
+
'**Placement:** these are full-composition showcases, not control-driven; use them to copy the surrounding panel structure.',
|
|
21
|
+
].join('\n\n'),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
argTypes: {
|
|
26
|
+
class: {
|
|
27
|
+
control: 'text',
|
|
28
|
+
description: 'Layout classes for the message row.',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
render: (args) => (
|
|
32
|
+
<ChatConfig proseSize="sm">
|
|
33
|
+
<div
|
|
34
|
+
style={{ width: '380px', background: 'var(--color-card, #202127)' }}
|
|
35
|
+
class="p-3 rounded-lg"
|
|
36
|
+
>
|
|
37
|
+
<Message {...args}>
|
|
38
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
39
|
+
<MessageContent>{longText}</MessageContent>
|
|
40
|
+
</Message>
|
|
41
|
+
</div>
|
|
42
|
+
</ChatConfig>
|
|
43
|
+
),
|
|
44
|
+
} satisfies Meta<typeof Message>;
|
|
45
|
+
|
|
46
|
+
export default meta;
|
|
47
|
+
type Story = StoryObj<typeof meta>;
|
|
48
|
+
|
|
49
|
+
const IMPORT = `import { Message, MessageAvatar, MessageContent, ChatContainer, ChatConfig } from '@kitnai/chat';`;
|
|
50
|
+
const src = (code: string) => ({
|
|
51
|
+
parameters: { docs: { source: { code: `${IMPORT}\n\n${code}`, language: 'tsx' } } },
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const longText =
|
|
55
|
+
'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.';
|
|
56
|
+
|
|
57
|
+
/** Default render — a single message inside a 380px card; tweak `class` via controls. */
|
|
58
|
+
export const Playground: Story = {
|
|
59
|
+
...src(`<ChatConfig proseSize="sm">
|
|
60
|
+
<div style={{ width: '380px' }} class="p-3 rounded-lg">
|
|
61
|
+
<Message>
|
|
62
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
63
|
+
<MessageContent>{longText}</MessageContent>
|
|
64
|
+
</Message>
|
|
65
|
+
</div>
|
|
66
|
+
</ChatConfig>`),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** Simulates the chat panel at 380px — the default width in the detail page. */
|
|
70
|
+
export const NarrowPanel380: Story = {
|
|
71
|
+
render: () => (
|
|
72
|
+
<ChatConfig proseSize="sm">
|
|
73
|
+
<div
|
|
74
|
+
style={{ width: '380px', height: '500px', background: 'var(--color-card, #202127)' }}
|
|
75
|
+
class="flex flex-col overflow-hidden rounded-lg"
|
|
76
|
+
>
|
|
77
|
+
<div class="px-3 py-2.5 bg-muted/30 text-sm font-semibold text-foreground flex-shrink-0">
|
|
78
|
+
New Thread
|
|
79
|
+
</div>
|
|
80
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
81
|
+
<div class="space-y-3 min-w-0">
|
|
82
|
+
<Message>
|
|
83
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
84
|
+
<MessageContent>{longText}</MessageContent>
|
|
85
|
+
</Message>
|
|
86
|
+
</div>
|
|
87
|
+
</ChatContainer>
|
|
88
|
+
</div>
|
|
89
|
+
</ChatConfig>
|
|
90
|
+
),
|
|
91
|
+
...src(`<ChatConfig proseSize="sm">
|
|
92
|
+
<div style={{ width: '380px', height: '500px' }} class="flex flex-col rounded-lg">
|
|
93
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
94
|
+
<Message>
|
|
95
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
96
|
+
<MessageContent>{longText}</MessageContent>
|
|
97
|
+
</Message>
|
|
98
|
+
</ChatContainer>
|
|
99
|
+
</div>
|
|
100
|
+
</ChatConfig>`),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
/** Even narrower — 300px minimum width with two messages. */
|
|
104
|
+
export const NarrowPanel300: Story = {
|
|
105
|
+
render: () => (
|
|
106
|
+
<ChatConfig proseSize="sm">
|
|
107
|
+
<div
|
|
108
|
+
style={{ width: '300px', height: '500px', background: 'var(--color-card, #202127)' }}
|
|
109
|
+
class="flex flex-col overflow-hidden rounded-lg"
|
|
110
|
+
>
|
|
111
|
+
<div class="px-3 py-2.5 bg-muted/30 text-sm font-semibold text-foreground flex-shrink-0">
|
|
112
|
+
New Thread
|
|
113
|
+
</div>
|
|
114
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
115
|
+
<div class="space-y-3 min-w-0">
|
|
116
|
+
<Message>
|
|
117
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
118
|
+
<MessageContent>{longText}</MessageContent>
|
|
119
|
+
</Message>
|
|
120
|
+
|
|
121
|
+
<Message>
|
|
122
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
123
|
+
<MessageContent>A shorter reply.</MessageContent>
|
|
124
|
+
</Message>
|
|
125
|
+
</div>
|
|
126
|
+
</ChatContainer>
|
|
127
|
+
</div>
|
|
128
|
+
</ChatConfig>
|
|
129
|
+
),
|
|
130
|
+
...src(`<ChatConfig proseSize="sm">
|
|
131
|
+
<div style={{ width: '300px', height: '500px' }} class="flex flex-col rounded-lg">
|
|
132
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
133
|
+
<Message>
|
|
134
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
135
|
+
<MessageContent>{longText}</MessageContent>
|
|
136
|
+
</Message>
|
|
137
|
+
</ChatContainer>
|
|
138
|
+
</div>
|
|
139
|
+
</ChatConfig>`),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/** Without ChatContainer — isolates the Message component's own wrapping. */
|
|
143
|
+
export const NarrowDivOnly: Story = {
|
|
144
|
+
render: () => (
|
|
145
|
+
<ChatConfig proseSize="sm">
|
|
146
|
+
<div
|
|
147
|
+
style={{ width: '380px', background: 'var(--color-card, #202127)' }}
|
|
148
|
+
class="p-3 rounded-lg"
|
|
149
|
+
>
|
|
150
|
+
<Message>
|
|
151
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
152
|
+
<MessageContent>{longText}</MessageContent>
|
|
153
|
+
</Message>
|
|
154
|
+
</div>
|
|
155
|
+
</ChatConfig>
|
|
156
|
+
),
|
|
157
|
+
...src(`<ChatConfig proseSize="sm">
|
|
158
|
+
<div style={{ width: '380px' }} class="p-3 rounded-lg">
|
|
159
|
+
<Message>
|
|
160
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
161
|
+
<MessageContent>{longText}</MessageContent>
|
|
162
|
+
</Message>
|
|
163
|
+
</div>
|
|
164
|
+
</ChatConfig>`),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/** The avatar in isolation — verifies it stays a fixed 32px. */
|
|
168
|
+
export const AvatarIsolation: Story = {
|
|
169
|
+
render: () => (
|
|
170
|
+
<div
|
|
171
|
+
style={{ width: '380px', background: 'var(--color-card, #202127)' }}
|
|
172
|
+
class="p-3 rounded-lg"
|
|
173
|
+
>
|
|
174
|
+
<div class="flex items-start gap-3">
|
|
175
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
176
|
+
<div class="min-w-0 rounded-lg p-2 bg-secondary text-sm text-foreground break-words">
|
|
177
|
+
{longText}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
),
|
|
182
|
+
...src(`<div class="flex items-start gap-3">
|
|
183
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
184
|
+
<div class="min-w-0 rounded-lg p-2 bg-secondary break-words">{longText}</div>
|
|
185
|
+
</div>`),
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** Reproduces the full extension layout — left nav, content column, resizable chat. */
|
|
189
|
+
export const FullExtensionLayout: Story = {
|
|
190
|
+
render: () => (
|
|
191
|
+
<ChatConfig proseSize="sm">
|
|
192
|
+
<div class="flex h-screen bg-background relative" style={{ height: '600px' }}>
|
|
193
|
+
<div class="flex-shrink-0 w-[300px] bg-[#161618] p-4 overflow-y-auto">
|
|
194
|
+
<div class="text-sm text-muted-foreground">Left Nav</div>
|
|
195
|
+
<div class="mt-2 space-y-1">
|
|
196
|
+
<div class="text-sky-400 text-sm px-2 py-1 bg-sky-400/10 rounded">Content</div>
|
|
197
|
+
<div class="text-muted-foreground text-sm px-2 py-1">Summary</div>
|
|
198
|
+
<div class="text-muted-foreground text-sm px-2 py-1">Key Points</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<div class="flex-1 min-w-0 flex flex-col">
|
|
203
|
+
<div class="px-4 py-2 bg-muted/30 text-sm font-medium text-foreground flex-shrink-0">
|
|
204
|
+
Header Bar
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<ResizablePanelGroup orientation="horizontal" class="flex-1 min-w-0 overflow-hidden">
|
|
208
|
+
<ResizablePanel class="min-w-0 overflow-hidden">
|
|
209
|
+
<div class="flex-1 overflow-y-auto">
|
|
210
|
+
<div class="flex gap-16 mx-auto" style={{ "max-width": "calc(768px + 256px + 64px + 32px)" }}>
|
|
211
|
+
<div class="flex-1 min-w-0 max-w-[768px] px-4">
|
|
212
|
+
<h2 class="text-lg font-semibold text-foreground mt-4">Article Title</h2>
|
|
213
|
+
<p class="text-sm text-muted-foreground mt-2">
|
|
214
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
215
|
+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
|
|
216
|
+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
|
217
|
+
</p>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
</div>
|
|
221
|
+
</ResizablePanel>
|
|
222
|
+
<ResizableHandle withHandle />
|
|
223
|
+
<ResizablePanel class="overflow-hidden" defaultSize={35}>
|
|
224
|
+
<div class="h-full flex flex-col overflow-hidden">
|
|
225
|
+
<div class="flex flex-col h-full min-w-0 overflow-hidden bg-card">
|
|
226
|
+
<div class="px-3 py-2.5 bg-muted/30 text-sm font-semibold text-foreground flex-shrink-0">
|
|
227
|
+
New Thread
|
|
228
|
+
</div>
|
|
229
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
230
|
+
<div class="space-y-3 min-w-0">
|
|
231
|
+
<Message>
|
|
232
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
233
|
+
<MessageContent>{longText}</MessageContent>
|
|
234
|
+
</Message>
|
|
235
|
+
<Message>
|
|
236
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
237
|
+
<MessageContent>{longText + ' ' + longText}</MessageContent>
|
|
238
|
+
</Message>
|
|
239
|
+
</div>
|
|
240
|
+
</ChatContainer>
|
|
241
|
+
<div class="px-3 pb-3 pt-1 flex-shrink-0">
|
|
242
|
+
<div class="bg-muted/40 rounded-lg px-3 py-2.5 text-sm text-muted-foreground/40">
|
|
243
|
+
Ask about this page...
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
</ResizablePanel>
|
|
249
|
+
</ResizablePanelGroup>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</ChatConfig>
|
|
253
|
+
),
|
|
254
|
+
...src(`<ResizablePanelGroup orientation="horizontal" class="flex-1 min-w-0 overflow-hidden">
|
|
255
|
+
<ResizablePanel class="min-w-0 overflow-hidden">{/* article */}</ResizablePanel>
|
|
256
|
+
<ResizableHandle withHandle />
|
|
257
|
+
<ResizablePanel defaultSize={35}>
|
|
258
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
259
|
+
<Message>
|
|
260
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
261
|
+
<MessageContent>{longText}</MessageContent>
|
|
262
|
+
</Message>
|
|
263
|
+
</ChatContainer>
|
|
264
|
+
</ResizablePanel>
|
|
265
|
+
</ResizablePanelGroup>`),
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/** A simpler resizable split — main content beside a chat panel. */
|
|
269
|
+
export const InsideResizablePanel: Story = {
|
|
270
|
+
render: () => (
|
|
271
|
+
<ChatConfig proseSize="sm">
|
|
272
|
+
<div style={{ width: '900px', height: '500px' }} class="flex">
|
|
273
|
+
<ResizablePanelGroup orientation="horizontal" class="flex-1 min-w-0 overflow-hidden">
|
|
274
|
+
<ResizablePanel class="min-w-0 overflow-hidden">
|
|
275
|
+
<div class="h-full p-4 bg-background overflow-y-auto">
|
|
276
|
+
<p class="text-foreground text-sm">Main content area — this simulates the article/transcript view</p>
|
|
277
|
+
</div>
|
|
278
|
+
</ResizablePanel>
|
|
279
|
+
<ResizableHandle withHandle />
|
|
280
|
+
<ResizablePanel class="overflow-hidden" defaultSize={40}>
|
|
281
|
+
<div class="h-full flex flex-col overflow-hidden">
|
|
282
|
+
<div class="flex flex-col h-full min-w-0 overflow-hidden bg-card">
|
|
283
|
+
<div class="px-3 py-2.5 bg-muted/30 text-sm font-semibold text-foreground flex-shrink-0">
|
|
284
|
+
New Thread
|
|
285
|
+
</div>
|
|
286
|
+
|
|
287
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
288
|
+
<div class="space-y-3 min-w-0">
|
|
289
|
+
<Message>
|
|
290
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
291
|
+
<MessageContent>{longText}</MessageContent>
|
|
292
|
+
</Message>
|
|
293
|
+
|
|
294
|
+
<Message>
|
|
295
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
296
|
+
<MessageContent>A short reply to test mixed lengths.</MessageContent>
|
|
297
|
+
</Message>
|
|
298
|
+
|
|
299
|
+
<Message>
|
|
300
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
301
|
+
<MessageContent>{longText + ' ' + longText}</MessageContent>
|
|
302
|
+
</Message>
|
|
303
|
+
</div>
|
|
304
|
+
</ChatContainer>
|
|
305
|
+
|
|
306
|
+
<div class="px-3 pb-3 pt-1 flex-shrink-0">
|
|
307
|
+
<div class="bg-muted/40 rounded-lg px-3 py-2.5 text-sm text-muted-foreground/40">
|
|
308
|
+
Ask about this page...
|
|
309
|
+
</div>
|
|
310
|
+
</div>
|
|
311
|
+
</div>
|
|
312
|
+
</div>
|
|
313
|
+
</ResizablePanel>
|
|
314
|
+
</ResizablePanelGroup>
|
|
315
|
+
</div>
|
|
316
|
+
</ChatConfig>
|
|
317
|
+
),
|
|
318
|
+
...src(`<ResizablePanelGroup orientation="horizontal" class="flex-1 min-w-0 overflow-hidden">
|
|
319
|
+
<ResizablePanel class="min-w-0 overflow-hidden">{/* main content */}</ResizablePanel>
|
|
320
|
+
<ResizableHandle withHandle />
|
|
321
|
+
<ResizablePanel defaultSize={40}>
|
|
322
|
+
<ChatContainer class="flex-1 min-w-0 px-3 py-3">
|
|
323
|
+
<Message>
|
|
324
|
+
<MessageAvatar src="" alt="AI" fallback="AI" />
|
|
325
|
+
<MessageContent>{longText}</MessageContent>
|
|
326
|
+
</Message>
|
|
327
|
+
</ChatContainer>
|
|
328
|
+
</ResizablePanel>
|
|
329
|
+
</ResizablePanelGroup>`),
|
|
330
|
+
};
|