shadcn base
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
import { useState } from 'react';
|
||||
import { me, people } from '../../stories/fixtures';
|
||||
import { CommentComposer, CommentItem, type CommentData } from './Comment';
|
||||
|
||||
const meta: Meta<typeof CommentItem> = {
|
||||
title: 'Aufgaben/Kommentare',
|
||||
component: CommentItem,
|
||||
};
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof CommentItem>;
|
||||
|
||||
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 Verlauf: Story = {
|
||||
render: function Render() {
|
||||
const [comments, setComments] = useState(initial);
|
||||
const [draft, setDraft] = useState('');
|
||||
return (
|
||||
<div className="flex max-w-[460px] flex-col gap-4">
|
||||
<ol aria-label="Kommentarverlauf" className="m-0 flex flex-col gap-3.5 p-0">
|
||||
{comments.map((c) => (
|
||||
<CommentItem key={c.id} comment={c} onDelete={(id) => setComments((cs) => cs.filter((x) => x.id !== id))} />
|
||||
))}
|
||||
</ol>
|
||||
<CommentComposer
|
||||
me={me}
|
||||
value={draft}
|
||||
onChange={setDraft}
|
||||
onSend={() => {
|
||||
setComments((cs) => [...cs, { id: `c${cs.length + 1}`, author: me, when: 'gerade eben', text: draft, mine: true }]);
|
||||
setDraft('');
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user