(null);
+
+/**
+ * Props a control needs to join the surrounding `Field`: `id`, `aria-describedby`
+ * and `aria-invalid`. Explicit props win. Use it to make your own controls field-aware.
+ */
+export function useFieldControl(
+ props: P,
+): P {
+ const field = useContext(FieldContext);
+ if (!field) return props;
+ return {
+ ...props,
+ id: props.id ?? field.id,
+ 'aria-describedby': props['aria-describedby'] ?? field.describedBy,
+ 'aria-invalid': props['aria-invalid'] ?? (field.invalid || undefined),
+ };
+}
+
+export interface FieldProps extends ComponentProps<'div'> {
+ /** Marks the control invalid. Rendering a `FieldError` does this too. */
+ invalid?: boolean;
+ /** `horizontal` puts control and label side by side (checkboxes). */
+ orientation?: 'vertical' | 'horizontal';
+}
+
+/**
+ * Groups a label, one control and its messages, and wires ids and ARIA between them.
+ *
+ *
+ * E-Mail
+ *
+ * {error && {error}}
+ *
+ */
+export function Field({ invalid, orientation = 'vertical', className, ...props }: FieldProps) {
+ const id = useId();
+ const [messages, setMessages] = useState<{ id: string; error: boolean }[]>([]);
+ const register = useCallback((messageId: string, error: boolean) => {
+ setMessages((m) => [...m, { id: messageId, error }]);
+ return () => setMessages((m) => m.filter((x) => x.id !== messageId));
+ }, []);
+ const value = useMemo(
+ () => ({
+ id,
+ invalid: invalid ?? messages.some((m) => m.error),
+ describedBy: messages.map((m) => m.id).join(' ') || undefined,
+ register,
+ }),
+ [id, invalid, messages, register],
+ );
+ return (
+
+
+
+ );
+}
+
+/** Row above the control: the label and something aligned right, e.g. "Passwort vergessen?". */
+export function FieldHeader({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+export function FieldLabel({ className, ...props }: ComponentProps) {
+ const field = useContext(FieldContext);
+ return (
+
);
- if (!leadingIcon && !trailing) return input;
+}
+
+/** Small, muted text inside a label, e.g. "(optional)". */
+export function FieldNote({ className, ...props }: ComponentProps<'span'>) {
+ return ;
+}
+
+function useMessageId(id: string | undefined, error: boolean) {
+ const field = useContext(FieldContext);
+ const ownId = useId();
+ const messageId = id ?? `${field?.id ?? ownId}-${error ? 'error' : 'description'}`;
+ const register = field?.register;
+ useLayoutEffect(() => register?.(messageId, error), [register, messageId, error]);
+ return messageId;
+}
+
+/** Hint under the control; linked to it with `aria-describedby`. */
+export function FieldDescription({ id, className, ...props }: ComponentProps<'div'>) {
return (
-
- {leadingIcon && (
- {leadingIcon}
- )}
- {input}
- {trailing && {trailing}}
-
- );
-});
-
-export const PasswordInput = forwardRef>(
- function PasswordInput(props, ref) {
- const [visible, setVisible] = useState(false);
- const label = visible ? 'Passwort verbergen' : 'Passwort anzeigen';
- return (
- setVisible((v) => !v)}
- aria-pressed={visible}
- aria-label={label}
- title={label}
- className="flex h-8 w-8 items-center justify-center rounded-[7px] text-fg-subtle hover:bg-hover hover:text-fg"
- >
- {visible ? : }
-
- }
- {...props}
- />
- );
- },
-);
-
-export interface TextareaProps extends TextareaHTMLAttributes {
- invalid?: boolean;
-}
-
-export const Textarea = forwardRef(function Textarea(
- { invalid, rows = 3, ...props },
- ref,
-) {
- return ;
-});
-
-export interface SelectOption {
- value: string;
- label: string;
-}
-
-export interface SelectProps extends Omit, 'size'> {
- options: SelectOption[];
- invalid?: boolean;
- size?: FieldSize | 'settings';
-}
-
-/** Native select with the design's chevron. */
-export const Select = forwardRef(function Select(
- { options, invalid, size = 'md', ...props },
- ref,
-) {
- return (
-
- {options.map((o) => (
-
- {o.label}
-
- ))}
-
- );
-});
-
-export interface FieldProps {
- label: ReactNode;
- /** Small, muted text after the label, e.g. "(optional)". */
- labelNote?: ReactNode;
- /** Element aligned right of the label, e.g. "Passwort vergessen?". */
- labelAside?: ReactNode;
- hint?: ReactNode;
- error?: ReactNode;
- className?: string;
- /** Receives the generated ids so the control can wire up label and messages. */
- children: (ids: { id: string; describedBy?: string; invalid: boolean }) => ReactNode;
-}
-
-/** Label, control and message stacked with the design's 6px rhythm. */
-export function Field({ label, labelNote, labelAside, hint, error, className, children }: FieldProps) {
- const id = useId();
- const msgId = `${id}-msg`;
- const hasMsg = Boolean(error || hint);
- return (
-
-
-
- {labelAside && {labelAside}}
-
- {children({ id, describedBy: hasMsg ? msgId : undefined, invalid: Boolean(error) })}
- {error ? (
-
{error}
- ) : hint ? (
-
- {hint}
-
- ) : null}
-
+
);
}
-export function FieldError({ id, children }: { id?: string; children: ReactNode }) {
+/** Error under the control; marks the field invalid while rendered. */
+export function FieldError({ id, className, children, ...props }: ComponentProps<'div'>) {
return (
-
+
);
}
+
+/* ---------------------------------------------------------------- Controls */
+
+export type FieldSize = 'md' | 'lg';
+const heights: Record
= { md: 'h-[38px]', lg: 'h-[42px]' };
+
+export interface InputProps extends Omit, 'size'> {
+ /** 38px (filters, dialogs) or 42px (auth forms). */
+ size?: FieldSize;
+}
+
+export function Input({ size = 'md', className, ...props }: InputProps) {
+ return ;
+}
+
+/** Wraps an `Input` with addons inside the field: icons on the left, buttons on the right. */
+export function InputGroup({ className, ...props }: ComponentProps<'div'>) {
+ return (
+ [data-align=start]]:[&>input]:pl-[34px] has-[>[data-align=end]]:[&>input]:pr-12',
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export interface InputGroupAddonProps extends ComponentProps<'span'> {
+ /** `start`: decorative icon on the left. `end`: interactive element on the right. */
+ align?: 'start' | 'end';
+}
+
+export function InputGroupAddon({ align = 'start', className, ...props }: InputGroupAddonProps) {
+ return (
+
+ );
+}
+
+/** Small square button for an `InputGroupAddon align="end"`. */
+export function InputGroupButton({ className, type = 'button', ...props }: ComponentProps<'button'>) {
+ return (
+
+ );
+}
+
+/** Password input with a show/hide button. `className` goes to the wrapping `InputGroup`. */
+export function PasswordInput({ className, ...props }: Omit
) {
+ const [visible, setVisible] = useState(false);
+ const label = visible ? 'Passwort verbergen' : 'Passwort anzeigen';
+ return (
+
+
+
+ setVisible((v) => !v)} aria-pressed={visible} aria-label={label} title={label}>
+ {visible ? : }
+
+
+
+ );
+}
+
+export function Textarea({ rows = 3, ...props }: ComponentProps<'textarea'>) {
+ return ;
+}
+
+/** Native select with the design's chevron. Children are `SelectOption`s; `className` sizes the wrapper. */
+export function Select(props: ComponentProps) {
+ return ;
+}
+
+export const SelectOption = NativeSelectOption;
diff --git a/src/components/Group/Group.stories.tsx b/src/components/Group/Group.stories.tsx
index feb542c..dcab8c2 100644
--- a/src/components/Group/Group.stories.tsx
+++ b/src/components/Group/Group.stories.tsx
@@ -1,98 +1,241 @@
import type { Meta, StoryObj } from '@storybook/react';
-import { LogOut, Pencil, Plus, SquareArrowOutUpRight, Users } from 'lucide-react';
+import {
+ CalendarClock,
+ ChevronRight,
+ LogOut,
+ MoreHorizontal,
+ Pencil,
+ Plus,
+ SquareArrowOutUpRight,
+ Users,
+} from 'lucide-react';
import { useState } from 'react';
-import { groups, people } from '../../stories/fixtures';
+import { groups, people, type GroupData } from '../../stories/fixtures';
+import { AvatarGroup, PersonAvatar } from '../Avatar/Avatar';
+import { CountBadge, RoleBadge, Swatch } from '../Badge/Badge';
import { Button, type ButtonState } from '../Button/Button';
-import { Card, CardHeader } from '../Card/Card';
-import { MenuItem, MenuLink, MenuSeparator } from '../Menu/Menu';
-import { GroupCard, GroupRow, InviteBanner, NewGroupTile } from './Group';
+import { Card, CardAction, CardFrame, CardHeader, CardTitle } from '../Card/Card';
+import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from '../Menu/Menu';
+import { ProgressBar } from '../Progress/Progress';
+import {
+ GroupCard,
+ GroupCardDescription,
+ GroupCardFooter,
+ GroupCardHeader,
+ GroupCardHeading,
+ GroupCardIcon,
+ GroupCardMeta,
+ GroupCardProgress,
+ GroupCardProgressLabel,
+ GroupCardTitle,
+ GroupRow,
+ GroupRowHeader,
+ GroupRowLink,
+ GroupRowName,
+ GroupRowProgress,
+ GroupRowStats,
+ InviteBanner,
+ InviteBannerActions,
+ InviteBannerText,
+ NewGroupTile,
+ NewGroupTileDescription,
+ NewGroupTileIcon,
+ NewGroupTileTitle,
+} from './Group';
const meta: Meta = {
- title: 'Gruppen/Gruppen',
+ title: 'Groups/Group',
component: GroupCard,
- args: { group: groups[0] },
- argTypes: { group: { control: false }, menu: { control: false } },
};
export default meta;
type Story = StoryObj;
const i = { size: 16, strokeWidth: 1.75 } as const;
+const pct = (g: GroupData) => (g.total ? Math.round((g.done / g.total) * 100) : 0);
-const groupMenu = (
- <>
- }>
- Gruppe öffnen
-
- }>Bearbeiten
- }>
- Mitglieder verwalten
-
-
- }>
- Gruppe verlassen
-
- >
-);
+function GroupMenu({ name }: { name: string }) {
+ return (
+
+ );
+}
-export const Karte: Story = {
- args: { menu: groupMenu },
- render: (args) => (
-
-
-
- ),
+/** One `GroupData` as a `GroupCard`. */
+function ExampleGroupCard({ g }: { g: GroupData }) {
+ const p = pct(g);
+ return (
+
+
+
+
+
+ {g.name}
+
+
+
+
+
+ {g.description}
+
+
+ Fortschritt
+
+ {p}% · {g.done}/{g.total} Aufgaben
+
+
+
+
+
+
+
+ {g.members.map((m) => (
+
+ ))}
+
+ {g.members.length} Mitglieder
+
+ {g.next && (
+
+
+ {g.next}
+
+ )}
+
+
+ );
+}
+
+export const Single: Story = {
+ render: () => ,
+ decorators: [(Story) => {Story()}
],
};
-export const Uebersicht: Story = {
- name: 'Übersicht',
+export const Overview: Story = {
render: () => (
{groups.map((g) => (
-
+
))}
-
+
+
+ Neue Gruppe erstellen
+
+ Lade dein Team ein und behaltet Aufgaben und Deadlines gemeinsam im Blick.
+
+
),
};
-export const Dashboardliste: Story = {
- name: 'Dashboard: Meine Gruppen',
+export const DashboardList: Story = {
render: () => (
-
-
-
-
- }
- />
-
- {groups.map((g) => (
-
- ))}
-
-
+
+
+
+
+
+ Meine Gruppen {groups.length}
+
+
+
+
+
+
+ {groups.map((g) => {
+ const p = pct(g);
+ return (
+
+
+
+
+ {g.name}
+
+ {g.members.map((m) => (
+
+ ))}
+
+
+
+
+
+
+ {p}% · {g.done}/{g.total}
+
+
+
+
+ );
+ })}
+
+
+
+
),
};
-export const Einladung: Story = {
+export const Invite: Story = {
render: function Render() {
const [state, setState] = useState('idle');
return (
- {
- setState('loading');
- setTimeout(() => setState('success'), 900);
- setTimeout(() => setState('idle'), 1700);
- }}
- />
+
+
+
+ {people.KB.name} hat dich in die Gruppe „Statistik Projekt“ eingeladen.
+
+
+
+
+
+
);
},
};
diff --git a/src/components/Group/Group.tsx b/src/components/Group/Group.tsx
index cdc2eeb..5a92eaf 100644
--- a/src/components/Group/Group.tsx
+++ b/src/components/Group/Group.tsx
@@ -1,188 +1,286 @@
-import type { ReactNode } from 'react';
-import { CalendarClock, ChevronRight, MoreHorizontal, Plus, Users } from 'lucide-react';
-import { Avatar, AvatarStack, type Person } from '../Avatar/Avatar';
-import { RoleBadge } from '../Badge/Badge';
-import { Button } from '../Button/Button';
-import { Card } from '../Card/Card';
-import { Menu } from '../Menu/Menu';
-import { ProgressBar } from '../Progress/Progress';
+import { createContext, useContext, useId, type ComponentProps, type CSSProperties } from 'react';
+import { Plus, Users } from 'lucide-react';
+import { Slot } from 'radix-ui';
+import { cn } from '../../lib/cn';
+import { Card, CardFrame } from '../Card/Card';
-export interface GroupData {
- id: string;
- name: string;
+/* ---------------------------------------------------------------- Row */
+
+/**
+ * Compact group entry on the dashboard.
+ *
+ *
+ *
+ * ……
+ * 56% · 9/16
+ *
+ *
+ */
+export function GroupRow({ className, ...props }: ComponentProps<'li'>) {
+ return ;
+}
+
+export interface GroupRowLinkProps extends ComponentProps<'a'> {
+ asChild?: boolean;
+}
+
+export function GroupRowLink({ asChild, className, ...props }: GroupRowLinkProps) {
+ const Comp = asChild ? Slot.Root : 'a';
+ return (
+
+ );
+}
+
+export function GroupRowHeader({ className, ...props }: ComponentProps<'div'>) {
+ return (
+ svg]:flex-none [&>svg]:text-fg-faint', className)}
+ {...props}
+ />
+ );
+}
+
+export function GroupRowName({ className, ...props }: ComponentProps<'span'>) {
+ return (
+
+ );
+}
+
+/** Bar and stats, indented under the name. */
+export function GroupRowProgress({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** e.g. "
56% · 9/16". */
+export function GroupRowStats({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/* ---------------------------------------------------------------- Card */
+
+const GroupCardContext = createContext
(undefined);
+
+/**
+ * Group overview card. Labelled by its `GroupCardTitle`. `className` goes to the frame.
+ *
+ *
+ *
+ *
+ * …
+ *
+ *
+ * …
+ * …
+ * ……
+ *
+ */
+export function GroupCard({ className, ...props }: ComponentProps<'article'>) {
+ const titleId = useId();
+ return (
+
+
+
+
+
+
+
+ );
+}
+
+export function GroupCardHeader({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+export interface GroupCardIconProps extends ComponentProps<'span'> {
color: string;
- members: Person[];
- done: number;
- total: number;
- description?: string;
- role?: 'admin' | 'member';
- /** Next deadline, e.g. "Nächste: Fr, 27. Nov". */
- next?: string;
}
-const pct = (g: Pick) => (g.total ? Math.round((g.done / g.total) * 100) : 0);
-
-export interface GroupRowProps {
- group: GroupData;
- href?: string;
-}
-
-/** Compact group entry with members and progress, used on the dashboard. */
-export function GroupRow({ group: g, href = '#' }: GroupRowProps) {
- const p = pct(g);
+/** 40px tile tinted with the group color; shows a people icon unless you pass children. */
+export function GroupCardIcon({ color, className, style, children, ...props }: GroupCardIconProps) {
return (
-
-
-
-
-
-
- {p}% · {g.done}/{g.total}
-
-
-
-
+
+ {children ?? }
+
);
}
-export interface GroupCardProps {
- group: GroupData;
- href?: string;
- /** Items of the "…" menu at the top right (`MenuItem`, `MenuLink`, `MenuSeparator`). */
- menu?: ReactNode;
+/** Title and role badge. */
+export function GroupCardHeading({ className, ...props }: ComponentProps<'div'>) {
+ return (
+ [data-slot=badge]]:mt-[5px]', className)}
+ {...props}
+ />
+ );
}
-/** Group overview card on the Gruppen page. */
-export function GroupCard({ group: g, href = '#', menu }: GroupCardProps) {
- const p = pct(g);
- const headingId = `gc-${g.id}`;
+/** `h2`; put the group link inside. */
+export function GroupCardTitle({ className, ...props }: ComponentProps<'h2'>) {
return (
-
-
-
-
-
-
- {menu && (
-
- )}
-
- {g.description !== undefined && (
- {g.description}
+
-
- Fortschritt
-
- {p}% · {g.done}/{g.total} Aufgaben
-
-
-
-
-
-
-
- {g.members.length} Mitglieder
-
- {g.next && (
-
-
- {g.next}
-
- )}
-
-
+ {...props}
+ />
);
}
-export interface NewGroupTileProps {
- onClick?: () => void;
- title?: string;
- description?: string;
+export function GroupCardDescription({ className, ...props }: ComponentProps<'p'>) {
+ return (
+
+ );
}
+/** A `GroupCardProgressLabel` above a `ProgressBar`. */
+export function GroupCardProgress({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+/** "Fortschritt" on the left, "56% · 9/16 Aufgaben" on the right. */
+export function GroupCardProgressLabel({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+export function GroupCardFooter({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Small muted item in the footer: members, next deadline. Wrap long text in ``. */
+export function GroupCardMeta({ className, ...props }: ComponentProps<'span'>) {
+ return (
+ svg]:flex-none', className)}
+ {...props}
+ />
+ );
+}
+
+/* ---------------------------------------------------------------- Others */
+
/** Dashed tile that starts creating a group. */
-export function NewGroupTile({
- onClick,
- title = 'Neue Gruppe erstellen',
- description = 'Lade dein Team ein und behaltet Aufgaben und Deadlines gemeinsam im Blick.',
-}: NewGroupTileProps) {
+export function NewGroupTile({ className, type = 'button', ...props }: ComponentProps<'button'>) {
return (
+ type={type}
+ data-slot="new-group-tile"
+ className={cn(
+ 'flex min-h-[260px] flex-col items-center justify-center gap-2.5 rounded-[18px] border-[1.5px] border-dashed border-line-heavy bg-transparent p-6 text-center text-fg-muted hover:border-line-hover hover:bg-hover-row',
+ className,
+ )}
+ {...props}
+ />
);
}
-export interface InviteBannerProps {
- from: Person;
- groupName: string;
- onAccept?: () => void;
- onDecline?: () => void;
- acceptState?: 'idle' | 'loading' | 'success';
- declineState?: 'idle' | 'loading' | 'success';
-}
-
-/** Pending group invitation, shown above the group grid. */
-export function InviteBanner({ from, groupName, onAccept, onDecline, acceptState, declineState }: InviteBannerProps) {
- const busy = acceptState === 'loading' || declineState === 'loading';
+/** Plus in a tile, unless you pass children. */
+export function NewGroupTileIcon({ className, children, ...props }: ComponentProps<'span'>) {
return (
-
-
-
- {from.name} hat dich in die Gruppe „{groupName}“{' '}
- eingeladen.
-
-
-
-
-
-
+
+ {children ?? }
+
);
}
+
+export function NewGroupTileTitle({ className, ...props }: ComponentProps<'span'>) {
+ return ;
+}
+
+export function NewGroupTileDescription({ className, ...props }: ComponentProps<'span'>) {
+ return (
+
+ );
+}
+
+/** Pending group invitation above the group grid: avatar, `InviteBannerText`, `InviteBannerActions`. */
+export function InviteBanner({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+
+
+ );
+}
+
+/** `` marks the person and group. */
+export function InviteBannerText({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+export function InviteBannerActions({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
diff --git a/src/components/Layout/Layout.stories.tsx b/src/components/Layout/Layout.stories.tsx
index ff0b42e..ca1f23b 100644
--- a/src/components/Layout/Layout.stories.tsx
+++ b/src/components/Layout/Layout.stories.tsx
@@ -1,43 +1,70 @@
import type { Meta, StoryObj } from '@storybook/react';
import { Plus, SquareCheck } from 'lucide-react';
import { Button } from '../Button/Button';
-import { EmptyState, PageHeader } from './Layout';
+import {
+ Empty,
+ EmptyAction,
+ EmptyDescription,
+ EmptyMedia,
+ EmptyTitle,
+ PageActions,
+ PageDescription,
+ PageEyebrow,
+ PageHeader,
+ PageHeading,
+ PageTitle,
+} from './Layout';
const meta: Meta = {
- title: 'Grundlagen/Seitenkopf',
+ title: 'Foundations/PageHeader',
component: PageHeader,
- args: {
- title: 'Aufgaben',
- description: '7 Aufgaben in 3 Gruppen · 1 überfällig',
- },
};
export default meta;
type Story = StoryObj;
-export const MitAktion: Story = {
- name: 'Mit Aktion',
- args: {
- actions: (
- }>
- Neue Aufgabe
-
- ),
- },
-};
-
-export const MitUeberzeile: Story = {
- name: 'Mit Überzeile',
- args: { eyebrow: 'Einstellungen', title: 'Allgemein', description: 'Darstellung, Sprache und wo Collabry für dich startet.' },
-};
-
-export const Leerzustand: Story = {
+export const WithAction: Story = {
render: () => (
- }
- title="Keine Aufgaben gefunden"
- description="Passe die Filter an oder lege eine neue Aufgabe an."
- action={}
- />
+
+
+ Aufgaben
+ 7 Aufgaben in 3 Gruppen · 1 überfällig
+
+
+
+
+
+ ),
+};
+
+export const WithEyebrow: Story = {
+ render: () => (
+
+
+ Einstellungen
+ Allgemein
+ Darstellung, Sprache und wo Collabry für dich startet.
+
+
+ ),
+};
+
+export const EmptyState: Story = {
+ render: () => (
+
+
+
+
+ Keine Aufgaben gefunden
+ Passe die Filter an oder lege eine neue Aufgabe an.
+
+
+
+
),
};
diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx
index 88de107..281556d 100644
--- a/src/components/Layout/Layout.tsx
+++ b/src/components/Layout/Layout.tsx
@@ -1,50 +1,86 @@
-import type { HTMLAttributes, ReactNode } from 'react';
+import type { ComponentProps } from 'react';
import { cn } from '../../lib/cn';
-export interface PageHeaderProps extends Omit, 'title'> {
- title: ReactNode;
- /** Small label above the title, e.g. "Einstellungen". */
- eyebrow?: ReactNode;
- description?: ReactNode;
- /** Right side, e.g. the primary page action. */
- actions?: ReactNode;
-}
-
-/** Page title block: 28px black heading with optional eyebrow, description and actions. */
-export function PageHeader({ title, eyebrow, description, actions, className, ...props }: PageHeaderProps) {
+/** Page title block: `PageHeading` on the left, `PageActions` on the right. */
+export function PageHeader({ className, ...props }: ComponentProps<'header'>) {
return (
-
-
- {eyebrow &&
{eyebrow}
}
-
{title}
- {description &&
{description}
}
-
- {actions && {actions}
}
-
+
);
}
-export interface EmptyStateProps {
- icon?: ReactNode;
- title: ReactNode;
- description?: ReactNode;
- action?: ReactNode;
- className?: string;
+/** Eyebrow, title and description, stacked. */
+export function PageHeading(props: ComponentProps<'div'>) {
+ return ;
+}
+
+/** Small label above the title, e.g. "Einstellungen". */
+export function PageEyebrow({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+/** 28px black page heading. */
+export function PageTitle({ className, ...props }: ComponentProps<'h1'>) {
+ return (
+
+ );
+}
+
+export function PageDescription({ className, ...props }: ComponentProps<'p'>) {
+ return ;
+}
+
+export function PageActions({ className, ...props }: ComponentProps<'div'>) {
+ return ;
}
/** Centered placeholder for empty lists and searches. */
-export function EmptyState({ icon, title, description, action, className }: EmptyStateProps) {
+export function Empty({ className, ...props }: ComponentProps<'div'>) {
return (
-
- {icon &&
{icon}}
-
{title}
- {description &&
{description}
}
- {action &&
{action}
}
-
+
);
}
+/** Icon above the title. */
+export function EmptyMedia({ className, ...props }: ComponentProps<'span'>) {
+ return ;
+}
+
+export function EmptyTitle({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+export function EmptyDescription({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+export function EmptyAction({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
/** Small section label inside lists ("Heute", "Früher"). */
-export function SectionLabel({ className, ...props }: HTMLAttributes) {
- return ;
+export function SectionLabel({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** "·" between items of a meta line. */
+export function MetaSeparator({ className, children = '·', ...props }: ComponentProps<'span'>) {
+ return (
+
+ {children}
+
+ );
}
diff --git a/src/components/Logo/Logo.tsx b/src/components/Logo/Logo.tsx
index 6b53c8e..3bd1f91 100644
--- a/src/components/Logo/Logo.tsx
+++ b/src/components/Logo/Logo.tsx
@@ -13,6 +13,10 @@ export interface LogoProps extends Omit, 'sr
export function Logo({ variant = 'wordmark', alt = 'Collabry', className, ...props }: LogoProps) {
const size =
- variant === 'wordmark' ? 'h-[26px] w-auto' : variant === 'mark' ? 'h-[34px] w-[34px]' : 'h-auto w-[min(260px,100%)]';
+ variant === 'wordmark'
+ ? 'h-[26px] w-auto'
+ : variant === 'mark'
+ ? 'h-[34px] w-[34px]'
+ : 'h-auto w-[min(260px,100%)]';
return
;
}
diff --git a/src/components/Menu/Menu.stories.tsx b/src/components/Menu/Menu.stories.tsx
index 5f7df2b..5dd0226 100644
--- a/src/components/Menu/Menu.stories.tsx
+++ b/src/components/Menu/Menu.stories.tsx
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react';
import { LogOut, MoreHorizontal, Pencil, SquareArrowOutUpRight, Users } from 'lucide-react';
import { Button } from '../Button/Button';
-import { Menu, MenuItem, MenuLink, MenuSeparator } from './Menu';
+import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from './Menu';
const icon = { size: 16, strokeWidth: 1.75 } as const;
@@ -13,30 +13,44 @@ export default meta;
type Story = StoryObj;
-export const Gruppenmenue: Story = {
- name: 'Gruppenmenü',
+export const GroupMenu: Story = {
render: () => (
),
diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx
index 8786199..eab16c4 100644
--- a/src/components/Menu/Menu.tsx
+++ b/src/components/Menu/Menu.tsx
@@ -1,116 +1,24 @@
-import { forwardRef, type AnchorHTMLAttributes, type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';
-import { cn } from '../../lib/cn';
-import {
- DropdownMenu,
- DropdownMenuContent,
- DropdownMenuItem,
- DropdownMenuLabel,
- DropdownMenuSeparator,
- DropdownMenuTrigger,
+/**
+ * Dropdown menu (Radix): keyboard navigation, typeahead, focus return.
+ *
+ *
+ */
+export {
+ DropdownMenu as Menu,
+ DropdownMenuTrigger as MenuTrigger,
+ DropdownMenuContent as MenuContent,
+ DropdownMenuGroup as MenuGroup,
+ DropdownMenuItem as MenuItem,
+ DropdownMenuDetail as MenuItemDetail,
+ DropdownMenuLabel as MenuLabel,
+ DropdownMenuSeparator as MenuSeparator,
} from '../ui/dropdown-menu';
-
-export interface MenuProps
- extends Pick, 'open' | 'defaultOpen' | 'onOpenChange' | 'modal'>,
- Pick, 'side' | 'align' | 'sideOffset' | 'alignOffset'> {
- /** The element that opens the menu, usually a `Button`. Must forward its ref. */
- trigger: ReactNode;
- /** Accessible name, e.g. "Konto". */
- label: string;
- /** `lg` for the account menu (40px items), `md` for card menus (38px). */
- size?: 'md' | 'lg';
- /** Classes for the menu surface. */
- className?: string;
- children: ReactNode;
-}
-
-/** Dropdown menu with keyboard navigation, anchored to its trigger. */
-export function Menu({
- trigger,
- label,
- size = 'md',
- className,
- children,
- open,
- defaultOpen,
- onOpenChange,
- modal,
- align = 'end',
- ...position
-}: MenuProps) {
- return (
-
- {trigger}
-
- {children}
-
-
- );
-}
-
-const itemClass =
- 'group-data-[size=lg]/menu:h-10 group-data-[size=lg]/menu:gap-3 group-data-[size=lg]/menu:rounded-[9px]';
-
-interface ItemContentProps {
- icon?: ReactNode;
- /** Right-aligned detail, e.g. the current theme "Dunkel ›". */
- detail?: ReactNode;
- danger?: boolean;
- children: ReactNode;
-}
-
-function ItemContent({ icon, detail, danger, children }: ItemContentProps) {
- return (
- <>
- {icon && {icon}}
- {children}
- {detail && {detail}}
- >
- );
-}
-
-export interface MenuItemProps
- extends Omit, 'variant' | 'children'>,
- Omit {
- children: ReactNode;
-}
-
-/** Menu action. Use `onSelect` (or `onClick`); the menu closes afterwards. */
-export function MenuItem({ icon, detail, danger, className, children, ...props }: MenuItemProps) {
- return (
-
-
- {children}
-
-
- );
-}
-
-export interface MenuLinkProps extends AnchorHTMLAttributes, Omit {}
-
-export const MenuLink = forwardRef(function MenuLink(
- { icon, detail, danger, className, children, ...props },
- ref,
-) {
- return (
-
-
-
- {children}
-
-
-
- );
-});
-
-export const MenuSeparator = DropdownMenuSeparator;
-
-/** Non-interactive header block, e.g. the signed-in user. */
-export function MenuHeader(props: HTMLAttributes) {
- return ;
-}
diff --git a/src/components/MobileNav/MobileNav.stories.tsx b/src/components/MobileNav/MobileNav.stories.tsx
index 40adc87..16714e0 100644
--- a/src/components/MobileNav/MobileNav.stories.tsx
+++ b/src/components/MobileNav/MobileNav.stories.tsx
@@ -1,9 +1,14 @@
import type { Meta, StoryObj } from '@storybook/react';
+import { Bell, Calendar, Kanban, LayoutDashboard, Search, SquareCheck, Sun, Users } from 'lucide-react';
import { me } from '../../stories/fixtures';
-import { MobileHeader, MobileTabBar } from './MobileNav';
+import { PersonAvatar } from '../Avatar/Avatar';
+import { IndicatorDot } from '../Badge/Badge';
+import { Card, CardFrame } from '../Card/Card';
+import { Logo } from '../Logo/Logo';
+import { MobileHeader, MobileHeaderActions, MobileHeaderButton, MobileTab, MobileTabBar } from './MobileNav';
const meta: Meta = {
- title: 'Navigation/Mobil',
+ title: 'Navigation/MobileNav',
component: MobileTabBar,
parameters: { layout: 'fullscreen', viewport: { defaultViewport: 'mobile2' } },
};
@@ -11,37 +16,82 @@ export default meta;
type Story = StoryObj;
-export const Bildschirm: Story = {
- render: (args) => (
+const tab = { size: 22, strokeWidth: 1.75, 'aria-hidden': true } as const;
+const tabs = [
+ { id: 'dashboard', label: 'Dashboard', icon: },
+ { id: 'tasks', label: 'Aufgaben', icon: },
+ { id: 'kanban', label: 'Kanban', icon: },
+ { id: 'calendar', label: 'Kalender', icon: },
+ { id: 'groups', label: 'Gruppen', icon: },
+];
+
+function Tabs({ active = 'dashboard' }: { active?: string }) {
+ return (
+
+ {tabs.map((t) => (
+
+ {t.icon}
+ {t.label}
+
+ ))}
+
+ );
+}
+
+function ExampleHeader() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export const Screen: Story = {
+ render: () => (
-
+
Hallo Niklas
{Array.from({ length: 6 }, (_, i) => (
-
+
+
+
))}
-
+
),
};
-export const Kopfzeile: Story = {
+export const Header: Story = {
render: () => (
-
+
),
};
-export const Tableiste: Story = {
- name: 'Tab-Leiste',
- args: { activeId: 'kalender' },
- render: (args) => (
+export const TabBar: Story = {
+ render: () => (
-
+
),
};
diff --git a/src/components/MobileNav/MobileNav.tsx b/src/components/MobileNav/MobileNav.tsx
index e96958b..0e3e983 100644
--- a/src/components/MobileNav/MobileNav.tsx
+++ b/src/components/MobileNav/MobileNav.tsx
@@ -1,114 +1,79 @@
-import type { ReactNode } from 'react';
-import { Bell, Calendar, Kanban, LayoutDashboard, Moon, Search, SquareCheck, Sun, Users } from 'lucide-react';
+import type { ComponentProps } from 'react';
+import { Slot } from 'radix-ui';
import { cn } from '../../lib/cn';
-import { Avatar, type Person } from '../Avatar/Avatar';
-import { Logo } from '../Logo/Logo';
-import type { NavItemData } from '../Sidebar/Sidebar';
-const tabIcon = { size: 22, strokeWidth: 1.75, 'aria-hidden': true } as const;
-
-export const defaultMobileTabs: NavItemData[] = [
- { id: 'dashboard', label: 'Dashboard', href: '#', icon: },
- { id: 'aufgaben', label: 'Aufgaben', href: '#', icon: },
- { id: 'kanban', label: 'Kanban', href: '#', icon: },
- { id: 'kalender', label: 'Kalender', href: '#', icon: },
- { id: 'gruppen', label: 'Gruppen', href: '#', icon: },
-];
-
-export interface MobileTabBarProps {
- items?: NavItemData[];
- activeId?: string;
- className?: string;
-}
-
-/** Sticky bottom navigation on phones. */
-export function MobileTabBar({ items = defaultMobileTabs, activeId = 'dashboard', className }: MobileTabBarProps) {
+/** Sticky bottom navigation on phones. Children are `MobileTab`s. */
+export function MobileTabBar({ className, ...props }: ComponentProps<'nav'>) {
return (
+ {...props}
+ />
);
}
-export interface MobileHeaderProps {
- user: Person;
- theme?: 'dark' | 'light';
- onToggleTheme?: () => void;
- onSearch?: () => void;
- unreadCount?: number;
- notificationsHref?: string;
- onProfile?: () => void;
- /** Replaces the logo, e.g. a back button and page title. */
- leading?: ReactNode;
- className?: string;
+export interface MobileTabProps extends ComponentProps<'a'> {
+ active?: boolean;
+ asChild?: boolean;
}
-/** Sticky glass header on phones: logo, theme, search, notifications, profile. */
-export function MobileHeader({
- user,
- theme = 'dark',
- onToggleTheme,
- onSearch,
- unreadCount = 0,
- notificationsHref = '#',
- onProfile,
- leading,
- className,
-}: MobileHeaderProps) {
- const btn = 'flex h-11 w-11 flex-none items-center justify-center rounded-[10px] text-fg-4 hover:bg-hover hover:text-fg';
- const themeLabel = theme === 'dark' ? 'Helles Design aktivieren' : 'Dunkles Design aktivieren';
+/** Icon over a label. */
+export function MobileTab({ active, asChild, className, ...props }: MobileTabProps) {
+ const Comp = asChild ? Slot.Root : 'a';
+ return (
+
+ );
+}
+
+/** Sticky glass header on phones: logo (or a back button and title), then `MobileHeaderActions`. */
+export function MobileHeader({ className, ...props }: ComponentProps<'header'>) {
return (
+ {...props}
+ />
+ );
+}
+
+export function MobileHeaderActions({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+export interface MobileHeaderButtonProps extends ComponentProps<'button'> {
+ asChild?: boolean;
+}
+
+/** 44px touch target for icons or the profile avatar. Holds an `IndicatorDot`. Give it an `aria-label`. */
+export function MobileHeaderButton({ asChild, className, ...props }: MobileHeaderButtonProps) {
+ const Comp = asChild ? Slot.Root : 'button';
+ return (
+
);
}
diff --git a/src/components/Notifications/Notifications.stories.tsx b/src/components/Notifications/Notifications.stories.tsx
index 65df595..f38aa25 100644
--- a/src/components/Notifications/Notifications.stories.tsx
+++ b/src/components/Notifications/Notifications.stories.tsx
@@ -1,69 +1,32 @@
import type { Meta, StoryObj } from '@storybook/react';
-import { useState } from 'react';
import { notificationsEarlier, notificationsToday } from '../../stories/fixtures';
-import type { ButtonState } from '../Button/Button';
-import { NotificationItem, NotificationPanel, type NotificationData } from './Notifications';
+import { NotificationEntry, NotificationsDemo } from '../../stories/examples';
+import { NotificationList, NotificationPanel } from './Notifications';
const meta: Meta = {
- title: 'Overlays/Benachrichtigungen',
+ title: 'Overlays/Notifications',
component: NotificationPanel,
};
export default meta;
type Story = StoryObj;
+/** Composition in `src/stories/examples.tsx`. */
export const Panel: Story = {
- render: function Render() {
- const [today, setToday] = useState(notificationsToday);
- const [earlier, setEarlier] = useState(notificationsEarlier);
- const [markAll, setMarkAll] = useState('idle');
- const [accept, setAccept] = useState('idle');
- const read = (list: NotificationData[], id?: string) => list.map((n) => (!id || n.id === id ? { ...n, unread: false } : n));
- return (
- undefined}
- markAllState={markAll}
- onMarkAllRead={() => {
- setMarkAll('loading');
- setTimeout(() => {
- setToday((l) => read(l));
- setEarlier((l) => read(l));
- setMarkAll('idle');
- }, 900);
- }}
- onOpen={(id) => {
- setToday((l) => read(l, id));
- setEarlier((l) => read(l, id));
- }}
- onAccept={(id) => {
- setAccept('loading');
- setTimeout(() => {
- setToday((l) => l.map((n) => (n.id === id ? { ...n, unread: false, inviteResult: 'joined' } : n)));
- setAccept('idle');
- }, 900);
- }}
- onDecline={(id) => setToday((l) => l.map((n) => (n.id === id ? { ...n, unread: false, inviteResult: 'declined' } : n)))}
- inviteStates={{ n3: { accept } }}
- />
- );
- },
+ render: () => undefined} />,
};
-export const AllesGelesen: Story = {
- name: 'Alles gelesen',
- args: { today: [], earlier: [] },
+export const AllRead: Story = {
+ render: () => ,
};
-export const Eintraege: Story = {
- name: 'Einträge',
+export const Items: Story = {
render: () => (
-
+
{[...notificationsToday, ...notificationsEarlier].map((n) => (
-
+
))}
-
-
+
+
),
};
diff --git a/src/components/Notifications/Notifications.tsx b/src/components/Notifications/Notifications.tsx
index 7effe0f..80028c4 100644
--- a/src/components/Notifications/Notifications.tsx
+++ b/src/components/Notifications/Notifications.tsx
@@ -1,282 +1,260 @@
-import { useState, type MouseEvent, type ReactNode } from 'react';
-import { AlertCircle, CheckCircle2, Clock, X } from 'lucide-react';
+import { createContext, useContext, type ComponentProps } from 'react';
+import { Slot } from 'radix-ui';
import { cn } from '../../lib/cn';
-import { Avatar, type Person } from '../Avatar/Avatar';
-import { CountBadge, Swatch } from '../Badge/Badge';
-import { Button, type ButtonState } from '../Button/Button';
-import { SegmentedControl } from '../SegmentedControl/SegmentedControl';
-export type NotificationKind = 'person' | 'deadline' | 'overdue';
+/* ---------------------------------------------------------------- Panel */
-export interface NotificationData {
- id: string;
- kind: NotificationKind;
- /** Who triggered it (for `person`). */
- person?: Person;
- /** Bold lead, e.g. "Lena Berger" or "Deadline morgen:". */
- actor: string;
- verb?: string;
- /** Bold object, e.g. „Login & Registrierung umsetzen“. */
- object?: string;
- tail?: string;
- /** Quoted comment text. */
- quote?: string;
- group?: { name: string; color: string };
- time: string;
- unread?: boolean;
- /** Group invitation with Beitreten / Ablehnen. */
- invite?: boolean;
- /** Result after accepting or declining an invite. */
- inviteResult?: 'joined' | 'declined';
-}
-
-export interface NotificationItemProps {
- notification: NotificationData;
- onOpen?: (id: string) => void;
- onAccept?: (id: string) => void;
- onDecline?: (id: string) => void;
- acceptState?: ButtonState;
- declineState?: ButtonState;
- href?: string;
-}
-
-function KindIcon({ kind, person }: Pick) {
- if (kind === 'person' && person) return ;
- return (
-
- {kind === 'deadline' ? (
-
- ) : (
-
- )}
-
- );
-}
-
-export function NotificationItem({
- notification: n,
- onOpen,
- onAccept,
- onDecline,
- acceptState,
- declineState,
- href = '#',
-}: NotificationItemProps) {
- const busy = acceptState === 'loading' || declineState === 'loading';
- return (
-
- {
- if (href === '#') e.preventDefault();
- onOpen?.(n.id);
- }}
- className="flex items-start gap-3 rounded-xl py-3 pr-3 pl-2.5 text-fg hover:bg-hover-menu hover:text-fg"
- >
-
-
-
- {n.actor}
- {n.verb && ` ${n.verb}`} {n.object && {n.object}}
- {n.tail}
-
- {n.quote && (
-
{n.quote}
- )}
-
- {n.group && (
- <>
-
- {n.group.name}
- ·
- >
- )}
- {n.time}
-
-
-
- {n.unread && Ungelesen}
-
- {n.invite && !n.inviteResult && (
-
-
-
-
- )}
- {n.invite && n.inviteResult && (
-
- {n.inviteResult === 'joined' ? '✓ Du bist der Gruppe beigetreten' : 'Einladung abgelehnt'}
-
- )}
-
- );
-}
-
-export interface NotificationPanelProps {
- today: NotificationData[];
- earlier: NotificationData[];
- onClose?: () => void;
- onMarkAllRead?: () => void;
- markAllState?: ButtonState;
- onOpen?: (id: string) => void;
- onAccept?: (id: string) => void;
- onDecline?: (id: string) => void;
- /** Loading/success feedback for invite buttons, by notification id. */
- inviteStates?: Record;
- settingsHref?: string;
- /** Extra classes; position the panel from the outside. */
- className?: string;
- /** Rendered without the popover frame (mobile full-screen page). */
+export interface NotificationPanelProps extends ComponentProps<'section'> {
+ /** Without the popover frame (full-screen page on mobile). */
bare?: boolean;
- /** Footer slot replaces the default settings link. */
- footer?: ReactNode;
}
-/** Notification popover: Alle / Ungelesen tabs, "Heute" and "Früher" sections. */
-export function NotificationPanel({
- today,
- earlier,
- onClose,
- onMarkAllRead,
- markAllState,
- onOpen,
- onAccept,
- onDecline,
- inviteStates = {},
- settingsHref = '#',
- className,
- bare = false,
- footer,
-}: NotificationPanelProps) {
- const [tab, setTab] = useState<'all' | 'unread'>('all');
- const all = [...today, ...earlier];
- const unread = all.filter((n) => n.unread).length;
- const filter = (list: NotificationData[]) => (tab === 'unread' ? list.filter((n) => n.unread) : list);
- const t = filter(today);
- const e = filter(earlier);
- const itemProps = { onOpen, onAccept, onDecline };
-
+/**
+ * Notification popover surface.
+ *
+ *
+ *
+ * ……
+ *
+ *
+ * Heute…
+ * …
+ *
+ */
+export function NotificationPanel({ bare = false, className, ...props }: NotificationPanelProps) {
return (
-
-
-
Benachrichtigungen
- {unread > 0 &&
{unread}}
-
- {onMarkAllRead && (
-
- )}
- {onClose && (
-
- )}
-
-
-
-
-
-
-
- {t.length > 0 && (
- <>
-
Heute
-
- {t.map((n) => (
-
- ))}
-
- >
- )}
- {e.length > 0 && (
- <>
-
Früher
-
- {e.map((n) => (
-
- ))}
-
- >
- )}
- {t.length + e.length === 0 && (
-
-
-
Alles gelesen
-
Neue Benachrichtigungen erscheinen hier.
-
- )}
-
-
-
+ {...props}
+ />
+ );
+}
+
+export function NotificationPanelHeader({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Title row: title, count, actions on the right. */
+export function NotificationPanelBar({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+export function NotificationPanelTitle({ className, ...props }: ComponentProps<'h2'>) {
+ return ;
+}
+
+export function NotificationPanelActions({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Scrolling list area. */
+export function NotificationPanelBody({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+export function NotificationPanelFooter({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Quiet link for the footer, e.g. "Benachrichtigungs-Einstellungen". */
+export function NotificationPanelLink({ className, ...props }: ComponentProps<'a'>) {
+ return (
+
+ );
+}
+
+/* ---------------------------------------------------------------- Items */
+
+export function NotificationList({ className, ...props }: ComponentProps<'ul'>) {
+ return ;
+}
+
+const NotificationContext = createContext({ unread: false });
+
+export interface NotificationItemProps extends ComponentProps<'li'> {
+ unread?: boolean;
+}
+
+/**
+ * One notification. Unread ones get a tint and a dot (`NotificationUnreadDot`).
+ *
+ *
+ *
+ * or
+ *
+ * Lena Berger hat dir … zugewiesen.
+ * …
+ * SWE · Collabryvor 12 Min.
+ *
+ *
+ *
+ * …
+ *
+ */
+export function NotificationItem({ unread = false, className, ...props }: NotificationItemProps) {
+ return (
+
+
+
+ );
+}
+
+export interface NotificationLinkProps extends ComponentProps<'a'> {
+ asChild?: boolean;
+}
+
+/** The clickable row: media, content, unread dot. */
+export function NotificationLink({ asChild, className, ...props }: NotificationLinkProps) {
+ const Comp = asChild ? Slot.Root : 'a';
+ return (
+
+ );
+}
+
+export interface NotificationIconProps extends ComponentProps<'span'> {
+ tone?: 'warning' | 'danger';
+}
+
+/** 36px tile for system notifications (deadline, overdue). For people use a 36px `PersonAvatar`. */
+export function NotificationIcon({ tone = 'warning', className, ...props }: NotificationIconProps) {
+ return (
+
+ );
+}
+
+export function NotificationContent({ className, ...props }: ComponentProps<'div'>) {
+ return ;
+}
+
+/** The sentence. `` marks the actor and object. */
+export function NotificationText({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Quoted comment text. */
+export function NotificationQuote({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Group and time, e.g. "■ SWE · Collabry · vor 12 Min.". */
+export function NotificationMeta({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+/** Accent dot (and "Ungelesen" for screen readers) while the item is unread. Keeps its space when read. */
+export function NotificationUnreadDot({ className, ...props }: ComponentProps<'span'>) {
+ const { unread } = useContext(NotificationContext);
+ return (
+ <>
+
+ {unread && Ungelesen}
+ >
+ );
+}
+
+/** Buttons under the text, e.g. Beitreten / Ablehnen; aligned with the text. */
+export function NotificationActions({ className, ...props }: ComponentProps<'div'>) {
+ return (
+
+ );
+}
+
+export interface NotificationResultProps extends ComponentProps<'div'> {
+ tone?: 'success' | 'muted';
+}
+
+/** Outcome that replaces the actions, e.g. "✓ Du bist der Gruppe beigetreten". */
+export function NotificationResult({ tone = 'success', className, ...props }: NotificationResultProps) {
+ return (
+
);
}
diff --git a/src/components/Progress/Progress.stories.tsx b/src/components/Progress/Progress.stories.tsx
index cd993bb..730e8fc 100644
--- a/src/components/Progress/Progress.stories.tsx
+++ b/src/components/Progress/Progress.stories.tsx
@@ -1,28 +1,32 @@
import type { Meta, StoryObj } from '@storybook/react';
import { swatches } from '../../lib/tokens';
-import { ProgressBar, StatusProgress } from './Progress';
+import { ProgressBar, StatusBar, StatusLegend, StatusProgress } from './Progress';
-const meta: Meta = {
- title: 'Anzeige/Fortschritt',
- component: StatusProgress,
- args: { counts: { done: 9, review: 2, doing: 3, open: 2 }, legend: true },
+const meta: Meta = {
+ title: 'Display/Progress',
+ component: StatusBar,
+ args: { counts: { done: 9, review: 2, doing: 3, open: 2 } },
};
export default meta;
-type Story = StoryObj;
+type Story = StoryObj;
-export const NachStatus: Story = {
- name: 'Nach Status',
- decorators: [(Story) => {Story()}
],
+export const ByStatus: Story = {
+ render: (args) => (
+
+
+
+
+ ),
};
-export const Balken: Story = {
+export const Bar: Story = {
render: () => (
),
};
diff --git a/src/components/Progress/Progress.tsx b/src/components/Progress/Progress.tsx
index 25b3b6f..06b1035 100644
--- a/src/components/Progress/Progress.tsx
+++ b/src/components/Progress/Progress.tsx
@@ -1,25 +1,20 @@
-import type { CSSProperties, HTMLAttributes } from 'react';
+import type { ComponentProps, CSSProperties } from 'react';
import { cn } from '../../lib/cn';
-import { Progress } from '../ui/progress';
import { taskStatusBar, taskStatusLabel, taskStatusOrder, type TaskStatus } from '../../lib/tokens';
+import { Progress } from '../ui/progress';
-export interface ProgressBarProps extends Omit, 'dir'> {
+export interface ProgressBarProps extends ComponentProps {
/** 0–100. */
value: number;
/** Fill color, usually the group color. Defaults to the accent. */
color?: string;
- /** Accessible label, e.g. "SWE · Collabry: 62 % erledigt". */
- label?: string;
}
-/** Thin 6px track used for group progress. */
-export function ProgressBar({ value, color, label, className, style, ...props }: ProgressBarProps) {
- const pct = Math.max(0, Math.min(100, value));
+/** Thin 6px track used for group progress. Give it an `aria-label`. */
+export function ProgressBar({ value, color, style, ...props }: ProgressBarProps) {
return (
@@ -28,41 +23,54 @@ export function ProgressBar({ value, color, label, className, style, ...props }:
export type StatusCounts = Partial>;
-export interface StatusProgressProps extends HTMLAttributes {
+const segmentsOf = (counts: StatusCounts) => {
+ const total = taskStatusOrder.reduce((n, k) => n + (counts[k] ?? 0), 0);
+ return taskStatusOrder
+ .filter((k) => (counts[k] ?? 0) > 0)
+ .map((k) => ({ key: k, count: counts[k] ?? 0, width: ((counts[k] ?? 0) / total) * 100 }));
+};
+
+export interface StatusCountsProps extends ComponentProps<'div'> {
counts: StatusCounts;
- /** Show the colored legend with counts below the bar. */
- legend?: boolean;
}
-/** Segmented bar that splits a project's tasks by status, with a legend. */
-export function StatusProgress({ counts, legend = true, className, ...props }: StatusProgressProps) {
- const total = taskStatusOrder.reduce((n, k) => n + (counts[k] ?? 0), 0);
- const segments = taskStatusOrder
- .filter((k) => (counts[k] ?? 0) > 0)
- .map((k) => ({ key: k, count: counts[k] ?? 0, w: total ? ((counts[k] ?? 0) / total) * 100 : 0 }));
- const barLabel = taskStatusOrder.map((k) => `${taskStatusLabel[k]}: ${counts[k] ?? 0}`).join(', ');
+/** Segmented bar that splits a project's tasks by status. */
+export function StatusBar({ counts, className, ...props }: StatusCountsProps) {
return (
-
-
- {segments.map((s) => (
-
- ))}
-
- {legend && (
-
- {segments.map((s) => (
-
-
- {taskStatusLabel[s.key]}
- {s.count}
-
- ))}
-
- )}
+
`${taskStatusLabel[k]}: ${counts[k] ?? 0}`).join(', ')}
+ data-slot="status-bar"
+ className={cn('flex h-2.5 gap-[3px]', className)}
+ {...props}
+ >
+ {segmentsOf(counts).map((s) => (
+
+ ))}
);
}
+
+/** Colored legend with counts per status, for under a `StatusBar`. */
+export function StatusLegend({ counts, className, ...props }: StatusCountsProps) {
+ return (
+
+ {segmentsOf(counts).map((s) => (
+
+
+ {taskStatusLabel[s.key]}
+ {s.count}
+
+ ))}
+
+ );
+}
+
+/** Stacks a `StatusBar` and a `StatusLegend` with the design's spacing. */
+export function StatusProgress({ className, ...props }: ComponentProps<'div'>) {
+ return
;
+}
diff --git a/src/components/SegmentedControl/SegmentedControl.stories.tsx b/src/components/SegmentedControl/SegmentedControl.stories.tsx
index 3938936..e6054e4 100644
--- a/src/components/SegmentedControl/SegmentedControl.stories.tsx
+++ b/src/components/SegmentedControl/SegmentedControl.stories.tsx
@@ -1,9 +1,9 @@
import type { Meta, StoryObj } from '@storybook/react';
import { useState } from 'react';
-import { SegmentedControl } from './SegmentedControl';
+import { SegmentedControl, SegmentedControlCount, SegmentedControlItem } from './SegmentedControl';
const meta: Meta
= {
- title: 'Formulare/SegmentedControl',
+ title: 'Forms/SegmentedControl',
component: SegmentedControl,
};
export default meta;
@@ -14,75 +14,54 @@ export const Filter: Story = {
render: function Render() {
const [value, setValue] = useState('all');
return (
-
+
+
+ Alle 7
+
+
+ Offen 6
+
+
+ Überfällig 1
+
+
+ Erledigt 1
+
+
);
},
};
-export const Ansicht: Story = {
- render: function Render() {
- const [value, setValue] = useState('month');
- return (
-
- );
- },
+export const View: Story = {
+ render: () => (
+
+ Monat
+ Woche
+
+ ),
};
-export const Einstellung: Story = {
- render: function Render() {
- const [value, setValue] = useState('off');
- return (
-
- );
- },
+export const Setting: Story = {
+ render: () => (
+
+ Aus
+ Leicht
+ Kräftig
+
+ ),
};
-export const Volle_Breite: Story = {
- name: 'Volle Breite',
- render: function Render() {
- const [value, setValue] = useState('all');
- return (
-
-
-
- );
- },
+export const FullWidth: Story = {
+ render: () => (
+
+
+
+ Alle 7
+
+
+ Ungelesen 4
+
+
+
+ ),
};
diff --git a/src/components/SegmentedControl/SegmentedControl.tsx b/src/components/SegmentedControl/SegmentedControl.tsx
index b5dd0de..62bcdca 100644
--- a/src/components/SegmentedControl/SegmentedControl.tsx
+++ b/src/components/SegmentedControl/SegmentedControl.tsx
@@ -1,60 +1,42 @@
+import type { ComponentProps } from 'react';
import { cn } from '../../lib/cn';
import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group';
-export interface SegmentedOption {
- value: T;
- label: string;
- /** Optional count shown after the label, e.g. "Offen 6". */
- count?: number;
-}
-
-export interface SegmentedControlProps {
- options: SegmentedOption[];
- value: T;
- onChange?: (value: T) => void;
- /** Accessible name of the group, e.g. "Filter". */
- label: string;
+export interface SegmentedControlProps extends Omit, 'defaultValue' | 'dir'> {
+ value?: string;
+ defaultValue?: string;
+ onValueChange?: (value: string) => void;
/** 30px for filters, 32px in settings rows and forms. */
size?: 'sm' | 'md';
- /** Stretch segments to fill the width (notification tabs). */
- fullWidth?: boolean;
- /** Minimum segment width in px, used in settings rows. */
- minSegmentWidth?: number;
- className?: string;
+ disabled?: boolean;
}
-/** Pill-group of toggle buttons used for filters, views and options. Arrow keys move between segments. */
-export function SegmentedControl({
- options,
- value,
- onChange,
- label,
- size = 'sm',
- fullWidth = false,
- minSegmentWidth,
- className,
-}: SegmentedControlProps) {
+/**
+ * Pill group of mutually exclusive segments for filters, views and options; arrow keys
+ * move between them. Give it an `aria-label`. Stretch segments with `className="*:flex-1"`.
+ */
+export function SegmentedControl({ size = 'sm', onValueChange, className, ...props }: SegmentedControlProps) {
return (
v && onChange?.(v as T)}
+ // Radix lets you deselect the active item; a segmented control always keeps one.
+ onValueChange={(v: string) => v && onValueChange?.(v)}
className={cn('gap-0.5 rounded-[10px] border border-line-subtle bg-inset p-[3px]', className)}
- >
- {options.map((o) => (
-
- {o.label}
- {o.count !== undefined && {o.count}}
-
- ))}
-
+ {...props}
+ />
+ );
+}
+
+export const SegmentedControlItem = ToggleGroupItem;
+
+/** Count after a segment label, e.g. "Offen 6". */
+export function SegmentedControlCount({ className, ...props }: ComponentProps<'span'>) {
+ return (
+
);
}
diff --git a/src/components/Settings/Settings.stories.tsx b/src/components/Settings/Settings.stories.tsx
index da74f91..5399726 100644
--- a/src/components/Settings/Settings.stories.tsx
+++ b/src/components/Settings/Settings.stories.tsx
@@ -3,23 +3,37 @@ import { Camera, CircleUser, Info, SlidersHorizontal, Trash2 } from 'lucide-reac
import { useId, useRef, useState } from 'react';
import { me } from '../../stories/fixtures';
import { colorSchemes } from '../../lib/tokens';
-import { Avatar } from '../Avatar/Avatar';
+import { PersonAvatar } from '../Avatar/Avatar';
import { Button } from '../Button/Button';
-import { Field, Input, Select } from '../Field/Field';
-import { PageHeader } from '../Layout/Layout';
-import { SegmentedControl } from '../SegmentedControl/SegmentedControl';
+import { Field, FieldDescription, FieldLabel, Input, Select, SelectOption } from '../Field/Field';
+import { PageActions, PageDescription, PageEyebrow, PageHeader, PageHeading, PageTitle } from '../Layout/Layout';
+import { SegmentedControl, SegmentedControlItem } from '../SegmentedControl/SegmentedControl';
import {
+ ColorSchemeOption,
ColorSchemePicker,
SaveStatus,
SettingsNav,
+ SettingsNavItem,
+ SettingsNavLabel,
SettingsRow,
+ SettingsRowControl,
+ SettingsRowDescription,
+ SettingsRowLabel,
+ SettingsRowText,
SettingsSection,
+ SettingsSectionDescription,
+ SettingsSectionFooter,
+ SettingsSectionHeader,
+ SettingsSectionTitle,
+ ThemeOption,
+ ThemeOptionLabel,
ThemePicker,
+ ThemePreview,
type ThemeChoice,
} from './Settings';
const meta: Meta = {
- title: 'Einstellungen/Einstellungen',
+ title: 'Settings/Settings',
component: SettingsSection,
};
export default meta;
@@ -27,15 +41,10 @@ export default meta;
type Story = StoryObj;
const ni = { size: 18, strokeWidth: 1.75 } as const;
-const navGroups = [
- {
- title: 'Persönlich',
- items: [
- { id: 'konto', label: 'Konto', href: '#', icon: },
- { id: 'allgemein', label: 'Allgemein', href: '#', icon: },
- ],
- },
- { title: 'App', items: [{ id: 'info', label: 'Info', href: '#', icon: }] },
+const themes: { value: ThemeChoice; label: string }[] = [
+ { value: 'light', label: 'Hell' },
+ { value: 'dark', label: 'Dunkel' },
+ { value: 'system', label: 'System' },
];
function useAutosave() {
@@ -44,108 +53,175 @@ function useAutosave() {
const save = () => {
timers.current.forEach(clearTimeout);
setState('saving');
- timers.current = [
- window.setTimeout(() => setState('saved'), 900),
- window.setTimeout(() => setState('idle'), 3100),
- ];
+ timers.current = [window.setTimeout(() => setState('saved'), 900), window.setTimeout(() => setState('idle'), 3100)];
};
return { state, save };
}
-export const Allgemein: Story = {
+function ExampleThemePicker(props: { value: string; onValueChange: (v: string) => void; className?: string }) {
+ return (
+
+ {themes.map((t) => (
+
+
+ {t.label}
+
+ ))}
+
+ );
+}
+
+function ExampleColorSchemePicker(props: {
+ value: string;
+ onValueChange: (v: string) => void;
+ 'aria-labelledby'?: string;
+}) {
+ return (
+
+ {colorSchemes.map((s) => (
+
+ {s.name}
+
+ ))}
+
+ );
+}
+
+export const General: Story = {
render: function Render() {
const { state, save } = useAutosave();
- const [theme, setTheme] = useState('dark');
- const [scheme, setScheme] = useState('violett');
+ const [theme, setTheme] = useState('dark');
+ const [scheme, setScheme] = useState('violet');
const [tint, setTint] = useState('off');
const [week, setWeek] = useState('mo');
const schemeLabelId = useId();
- const pick = (set: (v: T) => void) => (v: T) => {
+ const pick = (set: (v: string) => void) => (v: string) => {
set(v);
save();
};
return (
- }
- />
+
+
+ Einstellungen
+ Allgemein
+ Darstellung, Sprache und wo Collabry für dich startet.
+
+
+
+
+
-
+
+ Persönlich
+
+
+ Konto
+
+
+
+ Allgemein
+
+ App
+
+
+ Info
+
+
-
-
-
+
+
+ Darstellung
+ Wähle, wie Collabry für dich aussieht.
+
+
+
+
+
Farbschema
{colorSchemes.find((s) => s.id === scheme)?.name}
- }
- description="Akzentfarbe für Buttons, Links und Markierungen. Gilt für die ganze App."
- >
-
+
+ Akzentfarbe für Buttons, Links und Markierungen. Gilt für die ganze App.
+
+
+
+
+
-
-
+
+
+ Neutraltöne einfärben
+
+ Schwarz, Grau und Weiß bekommen einen Hauch der Akzentfarbe.
+
+
+
+
+ Aus
+ Leicht
+ Kräftig
+
+
-
-
-
+
+
+ Sprache & Region
+ Wie Texte, Daten und Kalender angezeigt werden.
+
+
+
+ Sprache
+ Sprache der Oberfläche.
+
+
+
+
-
-
+
+
+ Datumsformat
+ Zum Beispiel bei Deadlines.
+
+
+
+
-
-
+
+
+ Woche beginnt am
+ Gilt für den Kalender und die Wochenansicht.
+
+
+
+ Montag
+ Sonntag
+
+
@@ -155,78 +231,92 @@ export const Allgemein: Story = {
},
};
-export const Konto: Story = {
+export const Account: Story = {
render: function Render() {
const [first, setFirst] = useState('Niklas');
const [saved, setSaved] = useState(false);
const dirty = first !== 'Niklas';
return (
@@ -234,30 +324,25 @@ export const Konto: Story = {
},
};
-export const Designauswahl: Story = {
- name: 'Designauswahl',
+export const Themes: Story = {
render: function Render() {
- const [v, setV] = useState
('system');
- return (
-
-
-
- );
+ const [v, setV] = useState('system');
+ return ;
},
};
-export const Farbschema: Story = {
+export const ColorScheme: Story = {
render: function Render() {
- const [v, setV] = useState('petrol');
+ const [v, setV] = useState('teal');
return (
-
+
);
},
};
-export const Speicherstatus: Story = {
+export const Saving: Story = {
render: () => (
diff --git a/src/components/Settings/Settings.tsx b/src/components/Settings/Settings.tsx
index c756592..8f250e1 100644
--- a/src/components/Settings/Settings.tsx
+++ b/src/components/Settings/Settings.tsx
@@ -1,131 +1,223 @@
-import { useId, type ReactNode } from 'react';
+import { createContext, useContext, useId, type ComponentProps } from 'react';
import { Check } from 'lucide-react';
+import { Slot } from 'radix-ui';
import { cn } from '../../lib/cn';
-import { Card } from '../Card/Card';
-import { CardDescription, CardTitle } from '../ui/card';
+import { Card, CardFrame } from '../Card/Card';
import { Label } from '../ui/label';
import { RadioGroup, RadioGroupItem } from '../ui/radio-group';
import { Spinner } from '../Spinner/Spinner';
-import type { NavItemData } from '../Sidebar/Sidebar';
-export interface SettingsNavGroup {
- title: string;
- items: NavItemData[];
-}
+/* ---------------------------------------------------------------- Nav */
-export interface SettingsNavProps {
- groups: SettingsNavGroup[];
- activeId: string;
- className?: string;
-}
-
-/** Left-hand navigation between settings pages (Konto, Allgemein, Info). */
-export function SettingsNav({ groups, activeId, className }: SettingsNavProps) {
+/** Left-hand navigation between settings pages: `SettingsNavLabel`s and `SettingsNavItem`s. */
+export function SettingsNav({ className, ...props }: ComponentProps<'nav'>) {
return (
-
+
);
}
-export interface SettingsSectionProps {
- title: string;
- description?: ReactNode;
- children: ReactNode;
- /** Footer row, right-aligned (e.g. Verwerfen / Speichern). */
- footer?: ReactNode;
- className?: string;
-}
-
-/** A settings card: heading block, then rows separated by hairlines. */
-export function SettingsSection({ title, description, children, footer, className }: SettingsSectionProps) {
- const id = useId();
- return (
-
-
-
- {title}
-
- {description && {description}}
-
- {children}
- {footer && (
-
- {footer}
-
- )}
-
- );
-}
-
-export interface SettingsRowProps {
- label: ReactNode;
- description?: ReactNode;
- /** id of the control, so the label is a real