import type { Meta, StoryObj } from '@storybook/react'; import { SendHorizontal } from 'lucide-react'; import { useState } from 'react'; import { me, people } from '../../stories/fixtures'; import { PersonAvatar, type Person } from '../Avatar/Avatar'; import { Button } from '../Button/Button'; import { Comment, CommentAuthor, CommentBody, CommentBubble, CommentComposer, CommentComposerHint, CommentComposerRow, CommentHeader, CommentInput, CommentList, CommentTime, } from './Comment'; const meta: Meta = { title: 'Tasks/Comment', component: Comment, }; export default meta; type Story = StoryObj; interface CommentData { id: string; author: Person; when: string; text: string; mine?: boolean; } const initial: CommentData[] = [ { id: 'c1', author: people.PM, when: 'vor 1 Std.', text: 'Kannst du die n:m-Beziehung zwischen Gruppe und Mitglied noch auflösen?', }, { id: 'c2', author: me, when: 'vor 40 Min.', text: 'Ja, ich lege eine Zwischentabelle „Mitgliedschaft“ an.', mine: true, }, ]; export const Thread: Story = { render: function Render() { const [comments, setComments] = useState(initial); const [draft, setDraft] = useState(''); const empty = !draft.trim(); const send = () => { if (empty) return; setComments((cs) => [ ...cs, { id: `c${cs.length + 1}`, author: me, when: 'gerade eben', text: draft, mine: true }, ]); setDraft(''); }; return (
{comments.map((c) => ( ))}
); }, };