init commit
This commit is contained in:
@@ -1,40 +1,102 @@
|
||||
import type { Meta, StoryObj } from '@storybook/react';
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { SendHorizontal, Trash2 } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
import { Stage, me, people, tasks } from '../../stories/fixtures';
|
||||
import { priorityLabel, type Priority } from '../../lib/tokens';
|
||||
import { PersonAvatar } from '../Avatar/Avatar';
|
||||
import { StatusBadge, Swatch } from '../Badge/Badge';
|
||||
import { Button, type ButtonState } from '../Button/Button';
|
||||
import { CommentComposer, CommentItem } from '../Comment/Comment';
|
||||
import { Field, Input, Select, Textarea } from '../Field/Field';
|
||||
import { SegmentedControl } from '../SegmentedControl/SegmentedControl';
|
||||
import { Dialog, Drawer } from './Dialog';
|
||||
import {
|
||||
Comment,
|
||||
CommentAuthor,
|
||||
CommentBody,
|
||||
CommentBubble,
|
||||
CommentComposer,
|
||||
CommentComposerHint,
|
||||
CommentComposerRow,
|
||||
CommentHeader,
|
||||
CommentInput,
|
||||
CommentList,
|
||||
CommentTime,
|
||||
} from '../Comment/Comment';
|
||||
import { Field, FieldError, FieldLabel, FieldNote, Input, Select, SelectOption, Textarea } from '../Field/Field';
|
||||
import { SegmentedControl, SegmentedControlItem } from '../SegmentedControl/SegmentedControl';
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
AlertDialogTrigger,
|
||||
Dialog,
|
||||
DialogBody,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogTrigger,
|
||||
Drawer,
|
||||
DrawerActions,
|
||||
DrawerBody,
|
||||
DrawerContent,
|
||||
DrawerFooter,
|
||||
DrawerHeader,
|
||||
DrawerTitle,
|
||||
DrawerTrigger,
|
||||
} from './Dialog';
|
||||
|
||||
const meta: Meta<typeof Dialog> = {
|
||||
title: 'Overlays/Dialog',
|
||||
component: Dialog,
|
||||
parameters: { layout: 'padded' },
|
||||
};
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj<typeof Dialog>;
|
||||
|
||||
const groupOptions = [
|
||||
{ value: 'swe', label: 'SWE · Collabry' },
|
||||
{ value: 'db', label: 'Datenbanken Übung' },
|
||||
{ value: 'mk', label: 'Marketing Seminar' },
|
||||
];
|
||||
const peopleOptions = Object.entries(people).map(([k, p]) => ({ value: k, label: p.name }));
|
||||
const prioOptions = [
|
||||
{ value: 'Hoch', label: 'Hoch' },
|
||||
{ value: 'Mittel', label: 'Mittel' },
|
||||
{ value: 'Niedrig', label: 'Niedrig' },
|
||||
];
|
||||
const priorities: Priority[] = ['high', 'medium', 'low'];
|
||||
|
||||
export const NeueAufgabe: Story = {
|
||||
name: 'Neue Aufgabe',
|
||||
function PrioritySelect({ value, onValueChange }: { value: string; onValueChange: (v: string) => void }) {
|
||||
return (
|
||||
<SegmentedControl aria-label="Priorität" size="md" value={value} onValueChange={onValueChange}>
|
||||
{priorities.map((p) => (
|
||||
<SegmentedControlItem key={p} value={p}>
|
||||
{priorityLabel[p]}
|
||||
</SegmentedControlItem>
|
||||
))}
|
||||
</SegmentedControl>
|
||||
);
|
||||
}
|
||||
|
||||
function GroupOptions() {
|
||||
return (
|
||||
<>
|
||||
<SelectOption value="swe">SWE · Collabry</SelectOption>
|
||||
<SelectOption value="db">Datenbanken Übung</SelectOption>
|
||||
<SelectOption value="mk">Marketing Seminar</SelectOption>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function PeopleOptions() {
|
||||
return (
|
||||
<>
|
||||
{Object.entries(people).map(([k, p]) => (
|
||||
<SelectOption key={k} value={k}>
|
||||
{p.name}
|
||||
</SelectOption>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const NewTask: Story = {
|
||||
render: function Render() {
|
||||
const [open, setOpen] = useState(true);
|
||||
const [prio, setPrio] = useState('Mittel');
|
||||
const [prio, setPrio] = useState('medium');
|
||||
const [title, setTitle] = useState('');
|
||||
const [tried, setTried] = useState(false);
|
||||
const [state, setState] = useState<ButtonState>('idle');
|
||||
@@ -50,165 +112,213 @@ export const NeueAufgabe: Story = {
|
||||
};
|
||||
return (
|
||||
<Stage height={640}>
|
||||
<div className="p-6">
|
||||
<Button variant="primary" onClick={() => setOpen(true)}>
|
||||
Neue Aufgabe
|
||||
</Button>
|
||||
</div>
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
title="Neue Aufgabe"
|
||||
description="Die zuständige Person wird benachrichtigt."
|
||||
footer={
|
||||
<>
|
||||
<Button onClick={() => setOpen(false)}>Abbrechen</Button>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<div className="p-6">
|
||||
<DialogTrigger asChild>
|
||||
<Button variant="primary">Neue Aufgabe</Button>
|
||||
</DialogTrigger>
|
||||
</div>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Neue Aufgabe</DialogTitle>
|
||||
<DialogDescription>Die zuständige Person wird benachrichtigt.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<DialogBody>
|
||||
<Field>
|
||||
<FieldLabel>Titel</FieldLabel>
|
||||
<Input placeholder="Was ist zu tun?" value={title} onChange={(e) => setTitle(e.target.value)} />
|
||||
{tried && !title.trim() && <FieldError>Bitte gib einen Titel ein.</FieldError>}
|
||||
</Field>
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-4">
|
||||
<Field>
|
||||
<FieldLabel>Gruppe</FieldLabel>
|
||||
<Select>
|
||||
<GroupOptions />
|
||||
</Select>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Zuständig</FieldLabel>
|
||||
<Select>
|
||||
<PeopleOptions />
|
||||
</Select>
|
||||
</Field>
|
||||
<Field>
|
||||
<FieldLabel>Fällig am</FieldLabel>
|
||||
<Input type="date" defaultValue="2026-11-09" />
|
||||
</Field>
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<span className="text-sm font-bold">Priorität</span>
|
||||
<PrioritySelect value={prio} onValueChange={setPrio} />
|
||||
</div>
|
||||
</div>
|
||||
<Field>
|
||||
<FieldLabel>
|
||||
Beschreibung <FieldNote>(optional)</FieldNote>
|
||||
</FieldLabel>
|
||||
<Textarea rows={3} />
|
||||
</Field>
|
||||
</DialogBody>
|
||||
<DialogFooter>
|
||||
<DialogClose asChild>
|
||||
<Button>Abbrechen</Button>
|
||||
</DialogClose>
|
||||
<Button variant="primary" state={state} onClick={submit}>
|
||||
Aufgabe erstellen
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Field label="Titel" error={tried && !title.trim() ? 'Bitte gib einen Titel ein.' : undefined}>
|
||||
{({ id, invalid, describedBy }) => (
|
||||
<Input
|
||||
id={id}
|
||||
placeholder="Was ist zu tun?"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
invalid={invalid}
|
||||
aria-describedby={describedBy}
|
||||
/>
|
||||
)}
|
||||
</Field>
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-4">
|
||||
<Field label="Gruppe">{({ id }) => <Select id={id} options={groupOptions} />}</Field>
|
||||
<Field label="Zuständig">{({ id }) => <Select id={id} options={peopleOptions} />}</Field>
|
||||
<Field label="Fällig am">{({ id }) => <Input id={id} type="date" defaultValue="2026-11-09" />}</Field>
|
||||
<div className="flex min-w-0 flex-col gap-1.5">
|
||||
<span className="text-sm font-bold">Priorität</span>
|
||||
<SegmentedControl label="Priorität" size="md" value={prio} onChange={setPrio} options={prioOptions} />
|
||||
</div>
|
||||
</div>
|
||||
<Field label="Beschreibung" labelNote="(optional)">
|
||||
{({ id }) => <Textarea id={id} rows={3} />}
|
||||
</Field>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Stage>
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const Bestaetigung: Story = {
|
||||
name: 'Bestätigung',
|
||||
render: function Render() {
|
||||
const [open, setOpen] = useState(true);
|
||||
return (
|
||||
<Stage height={360}>
|
||||
export const Confirmation: Story = {
|
||||
render: () => (
|
||||
<Stage height={360}>
|
||||
<AlertDialog defaultOpen>
|
||||
<div className="p-6">
|
||||
<Button variant="danger-outline" onClick={() => setOpen(true)}>
|
||||
Aufgabe löschen
|
||||
</Button>
|
||||
<AlertDialogTrigger asChild>
|
||||
<Button variant="danger-outline">Aufgabe löschen</Button>
|
||||
</AlertDialogTrigger>
|
||||
</div>
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
kind="alert"
|
||||
width={420}
|
||||
title="Aufgabe löschen?"
|
||||
description="„ER-Diagramm finalisieren“ wird für alle Gruppenmitglieder entfernt."
|
||||
footer={
|
||||
<>
|
||||
<Button onClick={() => setOpen(false)}>Abbrechen</Button>
|
||||
<Button variant="danger" onClick={() => setOpen(false)}>
|
||||
Löschen
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Stage>
|
||||
);
|
||||
},
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Aufgabe löschen?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
„ER-Diagramm finalisieren“ wird für alle Gruppenmitglieder entfernt.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Abbrechen</AlertDialogCancel>
|
||||
<Button variant="danger">Löschen</Button>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</Stage>
|
||||
),
|
||||
};
|
||||
|
||||
export const Aufgabendetails: Story = {
|
||||
export const TaskDetails: Story = {
|
||||
render: function Render() {
|
||||
const [open, setOpen] = useState(true);
|
||||
const [draft, setDraft] = useState('');
|
||||
const [prio, setPrio] = useState('Hoch');
|
||||
const [prio, setPrio] = useState('high');
|
||||
const t = tasks[1];
|
||||
return (
|
||||
<Stage height={760}>
|
||||
<div className="p-6">
|
||||
<Button onClick={() => setOpen(true)}>Details öffnen</Button>
|
||||
</div>
|
||||
<Drawer
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
label={t.title}
|
||||
header={
|
||||
<span className="flex items-center gap-[7px] text-sm text-fg-muted">
|
||||
<Swatch color={t.group.color} />
|
||||
{t.group.name}
|
||||
</span>
|
||||
}
|
||||
actions={
|
||||
<Button variant="ghost" size="sm" iconOnly aria-label="Aufgabe löschen" title="Löschen" className="text-fg-subtle">
|
||||
<Trash2 size={16} strokeWidth={1.75} />
|
||||
</Button>
|
||||
}
|
||||
footer={<CommentComposer me={me} value={draft} onChange={setDraft} onSend={() => setDraft('')} />}
|
||||
>
|
||||
<div>
|
||||
<input
|
||||
aria-label="Titel"
|
||||
defaultValue={t.title}
|
||||
className="-mx-2 box-border w-[calc(100%+16px)] rounded-lg border border-transparent bg-transparent px-2 py-1.5 text-xl leading-tight font-black text-fg hover:border-line focus:border-accent-focus focus:shadow-focus focus:outline-none"
|
||||
/>
|
||||
<div className="mt-1.5 flex gap-2">
|
||||
<StatusBadge status={t.status} />
|
||||
</div>
|
||||
<Drawer defaultOpen>
|
||||
<div className="p-6">
|
||||
<DrawerTrigger asChild>
|
||||
<Button>Details öffnen</Button>
|
||||
</DrawerTrigger>
|
||||
</div>
|
||||
<div className="grid grid-cols-[110px_minmax(0,1fr)] items-center gap-x-3.5 gap-y-3">
|
||||
<label htmlFor="td-status" className="text-sm text-fg-subtle">
|
||||
Status
|
||||
</label>
|
||||
<Select
|
||||
id="td-status"
|
||||
defaultValue="doing"
|
||||
options={[
|
||||
{ value: 'open', label: 'Offen' },
|
||||
{ value: 'doing', label: 'In Arbeit' },
|
||||
{ value: 'review', label: 'Review' },
|
||||
{ value: 'done', label: 'Erledigt' },
|
||||
]}
|
||||
/>
|
||||
<label htmlFor="td-who" className="text-sm text-fg-subtle">
|
||||
Zuständig
|
||||
</label>
|
||||
<Select id="td-who" options={peopleOptions} />
|
||||
<label htmlFor="td-due" className="text-sm text-fg-subtle">
|
||||
Fällig am
|
||||
</label>
|
||||
<Input id="td-due" type="date" defaultValue="2026-11-04" />
|
||||
<span className="text-sm text-fg-subtle">Priorität</span>
|
||||
<SegmentedControl label="Priorität" size="md" value={prio} onChange={setPrio} options={prioOptions} />
|
||||
</div>
|
||||
<Field label="Beschreibung">
|
||||
{({ id }) => <Textarea id={id} rows={4} placeholder="Details, Links oder Akzeptanzkriterien …" />}
|
||||
</Field>
|
||||
<section className="flex flex-col gap-1 border-t border-line-divider pt-4">
|
||||
<h3 className="m-0 mb-2 text-base font-bold">Kommentare</h3>
|
||||
<ol className="m-0 flex flex-col gap-3.5 p-0">
|
||||
<CommentItem
|
||||
comment={{ id: 'c1', author: people.LB, when: 'vor 2 Std.', text: 'Bitte auch die Validierung der E-Mail-Adresse einbauen.' }}
|
||||
/>
|
||||
<CommentItem
|
||||
comment={{ id: 'c2', author: me, when: 'vor 1 Std.', text: 'Mache ich, kommt heute noch.', mine: true }}
|
||||
onDelete={() => undefined}
|
||||
/>
|
||||
</ol>
|
||||
</section>
|
||||
<DrawerContent aria-describedby={undefined}>
|
||||
<DrawerTitle className="sr-only">{t.title}</DrawerTitle>
|
||||
<DrawerHeader>
|
||||
<span className="flex min-w-0 items-center gap-[7px] text-sm text-fg-muted">
|
||||
<Swatch color={t.group.color} />
|
||||
{t.group.name}
|
||||
</span>
|
||||
<DrawerActions>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
iconOnly
|
||||
aria-label="Aufgabe löschen"
|
||||
title="Löschen"
|
||||
className="text-fg-subtle"
|
||||
>
|
||||
<Trash2 size={16} strokeWidth={1.75} />
|
||||
</Button>
|
||||
</DrawerActions>
|
||||
</DrawerHeader>
|
||||
<DrawerBody>
|
||||
<div>
|
||||
<input
|
||||
aria-label="Titel"
|
||||
defaultValue={t.title}
|
||||
className="-mx-2 box-border w-[calc(100%+16px)] rounded-lg border border-transparent bg-transparent px-2 py-1.5 text-xl leading-tight font-black text-fg hover:border-line focus:border-accent-focus focus:shadow-focus focus:outline-none"
|
||||
/>
|
||||
<div className="mt-1.5 flex gap-2">
|
||||
<StatusBadge status={t.status} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-[110px_minmax(0,1fr)] items-center gap-x-3.5 gap-y-3">
|
||||
<label htmlFor="td-status" className="text-sm text-fg-subtle">
|
||||
Status
|
||||
</label>
|
||||
<Select id="td-status" defaultValue="doing">
|
||||
<SelectOption value="open">Offen</SelectOption>
|
||||
<SelectOption value="doing">In Arbeit</SelectOption>
|
||||
<SelectOption value="review">Review</SelectOption>
|
||||
<SelectOption value="done">Erledigt</SelectOption>
|
||||
</Select>
|
||||
<label htmlFor="td-who" className="text-sm text-fg-subtle">
|
||||
Zuständig
|
||||
</label>
|
||||
<Select id="td-who">
|
||||
<PeopleOptions />
|
||||
</Select>
|
||||
<label htmlFor="td-due" className="text-sm text-fg-subtle">
|
||||
Fällig am
|
||||
</label>
|
||||
<Input id="td-due" type="date" defaultValue="2026-11-04" />
|
||||
<span className="text-sm text-fg-subtle">Priorität</span>
|
||||
<PrioritySelect value={prio} onValueChange={setPrio} />
|
||||
</div>
|
||||
<Field>
|
||||
<FieldLabel>Beschreibung</FieldLabel>
|
||||
<Textarea rows={4} placeholder="Details, Links oder Akzeptanzkriterien …" />
|
||||
</Field>
|
||||
<section className="flex flex-col gap-1 border-t border-line-divider pt-4">
|
||||
<h3 className="m-0 mb-2 text-base font-bold">Kommentare</h3>
|
||||
<CommentList>
|
||||
<Comment>
|
||||
<PersonAvatar person={people.LB} size={30} aria-hidden="true" />
|
||||
<CommentBody>
|
||||
<CommentHeader>
|
||||
<CommentAuthor>{people.LB.name}</CommentAuthor>
|
||||
<CommentTime>vor 2 Std.</CommentTime>
|
||||
</CommentHeader>
|
||||
<CommentBubble>Bitte auch die Validierung der E-Mail-Adresse einbauen.</CommentBubble>
|
||||
</CommentBody>
|
||||
</Comment>
|
||||
<Comment>
|
||||
<PersonAvatar person={me} size={30} aria-hidden="true" />
|
||||
<CommentBody>
|
||||
<CommentHeader>
|
||||
<CommentAuthor>{me.name}</CommentAuthor>
|
||||
<CommentTime>vor 1 Std.</CommentTime>
|
||||
</CommentHeader>
|
||||
<CommentBubble>Mache ich, kommt heute noch.</CommentBubble>
|
||||
</CommentBody>
|
||||
</Comment>
|
||||
</CommentList>
|
||||
</section>
|
||||
</DrawerBody>
|
||||
<DrawerFooter>
|
||||
<CommentComposer>
|
||||
<CommentComposerRow>
|
||||
<PersonAvatar person={me} size={30} aria-hidden="true" />
|
||||
<CommentInput
|
||||
value={draft}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
onSubmit={() => setDraft('')}
|
||||
/>
|
||||
<Button
|
||||
variant="primary"
|
||||
iconOnly
|
||||
aria-label="Kommentar senden"
|
||||
className="h-[38px] w-[38px]"
|
||||
disabled={!draft.trim()}
|
||||
>
|
||||
<SendHorizontal size={16} strokeWidth={2} />
|
||||
</Button>
|
||||
</CommentComposerRow>
|
||||
<CommentComposerHint />
|
||||
</CommentComposer>
|
||||
</DrawerFooter>
|
||||
</DrawerContent>
|
||||
</Drawer>
|
||||
</Stage>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user