shadcn base
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
storybook-static
|
||||||
|
*.log
|
||||||
|
.DS_Store
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import type { StorybookConfig } from '@storybook/react-vite';
|
||||||
|
|
||||||
|
const config: StorybookConfig = {
|
||||||
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(ts|tsx)'],
|
||||||
|
addons: ['@storybook/addon-essentials', '@storybook/addon-a11y'],
|
||||||
|
framework: {
|
||||||
|
name: '@storybook/react-vite',
|
||||||
|
options: {},
|
||||||
|
},
|
||||||
|
staticDirs: ['../public'],
|
||||||
|
docs: {
|
||||||
|
defaultName: 'Dokumentation',
|
||||||
|
},
|
||||||
|
typescript: {
|
||||||
|
reactDocgen: 'react-docgen-typescript',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<style>
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
/* The theme decorator pads the canvas itself; match the body to the active theme. */
|
||||||
|
.sb-show-main.sb-main-padded {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
background: #050505;
|
||||||
|
}
|
||||||
|
body:has([data-cl-theme='light']) {
|
||||||
|
background: #f4f4f5;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import type { Decorator, Preview } from '@storybook/react';
|
||||||
|
import '../src/styles/fonts.css';
|
||||||
|
import '../src/styles/index.css';
|
||||||
|
import { ThemeProvider, type Theme, type Tint } from '../src/components/ThemeProvider/ThemeProvider';
|
||||||
|
import { colorSchemes } from '../src/lib/tokens';
|
||||||
|
|
||||||
|
const withTheme: Decorator = (Story, context) => {
|
||||||
|
const theme = (context.globals.theme ?? 'dark') as Theme;
|
||||||
|
const scheme = colorSchemes.find((s) => s.id === context.globals.scheme) ?? colorSchemes[0];
|
||||||
|
const tint = (context.globals.tint ?? 'off') as Tint;
|
||||||
|
const layout = context.parameters.layout ?? 'padded';
|
||||||
|
return (
|
||||||
|
<ThemeProvider
|
||||||
|
theme={theme}
|
||||||
|
accent={scheme.color}
|
||||||
|
tint={tint}
|
||||||
|
className={context.viewMode === 'docs' ? 'bg-app' : 'min-h-screen bg-app'}
|
||||||
|
style={{ padding: layout === 'fullscreen' ? 0 : 24 }}
|
||||||
|
>
|
||||||
|
<Story />
|
||||||
|
</ThemeProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const preview: Preview = {
|
||||||
|
decorators: [withTheme],
|
||||||
|
globalTypes: {
|
||||||
|
theme: {
|
||||||
|
description: 'Design',
|
||||||
|
toolbar: {
|
||||||
|
title: 'Design',
|
||||||
|
icon: 'contrast',
|
||||||
|
items: [
|
||||||
|
{ value: 'dark', title: 'Dunkel', icon: 'moon' },
|
||||||
|
{ value: 'light', title: 'Hell', icon: 'sun' },
|
||||||
|
],
|
||||||
|
dynamicTitle: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
scheme: {
|
||||||
|
description: 'Farbschema',
|
||||||
|
toolbar: {
|
||||||
|
title: 'Farbschema',
|
||||||
|
icon: 'paintbrush',
|
||||||
|
items: colorSchemes.map((s) => ({ value: s.id, title: s.name })),
|
||||||
|
dynamicTitle: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
tint: {
|
||||||
|
description: 'Neutraltöne einfärben',
|
||||||
|
toolbar: {
|
||||||
|
title: 'Tönung',
|
||||||
|
icon: 'mirror',
|
||||||
|
items: [
|
||||||
|
{ value: 'off', title: 'Aus' },
|
||||||
|
{ value: 'subtle', title: 'Leicht' },
|
||||||
|
{ value: 'strong', title: 'Kräftig' },
|
||||||
|
],
|
||||||
|
dynamicTitle: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
initialGlobals: {
|
||||||
|
theme: 'dark',
|
||||||
|
scheme: 'violett',
|
||||||
|
tint: 'off',
|
||||||
|
},
|
||||||
|
parameters: {
|
||||||
|
layout: 'padded',
|
||||||
|
backgrounds: { disable: true },
|
||||||
|
controls: {
|
||||||
|
matchers: { color: /(background|color)$/i },
|
||||||
|
sort: 'requiredFirst',
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
storySort: {
|
||||||
|
order: ['Einführung', 'Grundlagen', 'Formulare', 'Anzeige', 'Overlays', 'Navigation', 'Aufgaben', 'Gruppen', 'Kalender', 'Einstellungen', 'Anmeldung'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default preview;
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# @collabry/components
|
||||||
|
|
||||||
|
React + Tailwind CSS component library for the Collabry UI, built on [shadcn/ui](https://ui.shadcn.com) (Radix UI, cmdk, Sonner), with a Storybook catalogue.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
npm run storybook # http://localhost:6006
|
||||||
|
npm run build # library → dist/ (ESM, types, collabry.css)
|
||||||
|
npm run build-storybook # static Storybook → storybook-static/
|
||||||
|
npm run typecheck
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use in an app
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ThemeProvider, Button, Toaster } from '@collabry/components';
|
||||||
|
import '@collabry/components/styles.css';
|
||||||
|
import '@fontsource/lato/400.css';
|
||||||
|
import '@fontsource/lato/700.css';
|
||||||
|
import '@fontsource/lato/900.css';
|
||||||
|
|
||||||
|
<ThemeProvider theme="dark" accent="#6A5FCB" tint="off" className="min-h-screen bg-app">
|
||||||
|
<Button variant="primary">Neue Aufgabe</Button>
|
||||||
|
<Toaster /> {/* once, if you use toast() */}
|
||||||
|
</ThemeProvider>;
|
||||||
|
```
|
||||||
|
|
||||||
|
`react`, `react-dom` are peer dependencies; `radix-ui`, `cmdk`, `sonner`, `class-variance-authority`, `lucide-react`, `clsx` and `tailwind-merge` are installed with the package.
|
||||||
|
|
||||||
|
Dialogs, menus and popovers portal into the nearest `ThemeProvider` element, so they keep its theme, accent and tint.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
- `src/styles/tokens.css`: design tokens (`--cl-*`) for dark and light, with accent and tint derived via `color-mix`
|
||||||
|
- `src/styles/index.css`: Tailwind v4 theme mapping tokens to utilities (`bg-surface`, `text-fg-muted`, `border-line`, …)
|
||||||
|
- `src/components/ui/`: shadcn/ui primitives (`components.json`), restyled to the Collabry tokens. Accessibility, focus and keyboard handling come from Radix / cmdk.
|
||||||
|
- `src/components/<Name>/<Name>.tsx` + `<Name>.stories.tsx`: Collabry components composed from `ui/`
|
||||||
|
- `src/stories/`: introduction, token overview and sample data from the design
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
| Area | Components |
|
||||||
|
| --- | --- |
|
||||||
|
| Grundlagen | `ThemeProvider`, `Button`, `ButtonLink`, `Card`, `CardHeader`, `CardFooter`, `PageHeader`, `EmptyState`, `Spinner`, `Logo` |
|
||||||
|
| Formulare | `Field`, `Input`, `PasswordInput`, `Textarea`, `Select`, `Checkbox`, `TaskCheckbox`, `SegmentedControl` |
|
||||||
|
| Anzeige | `StatusBadge`, `CountBadge`, `RoleBadge`, `Swatch`, `Kbd`, `Avatar`, `AvatarStack`, `ProgressBar`, `StatusProgress` |
|
||||||
|
| Overlays | `Menu`, `Dialog`, `Drawer`, `Toast`, `Toaster`, `toast()`, `CommandPalette`, `SearchTrigger`, `NotificationPanel`, `NotificationItem` |
|
||||||
|
| Navigation | `Sidebar`, `NavItem`, `UserMenu`, `MobileHeader`, `MobileTabBar`, `SettingsNav` |
|
||||||
|
| Aufgaben | `TaskTable`, `TaskRow`, `TaskSectionHeader`, `PriorityLabel`, `DeadlineItem`, `DateTile`, `CommentItem`, `CommentComposer` |
|
||||||
|
| Gruppen | `GroupCard`, `GroupRow`, `NewGroupTile`, `InviteBanner` |
|
||||||
|
| Kalender | `CalendarMonth`, `CalendarToolbar`, `CalendarLegend`, `GroupFilterChip`, `DayEventItem` |
|
||||||
|
| Einstellungen | `SettingsSection`, `SettingsRow`, `ThemePicker`, `ColorSchemePicker`, `SaveStatus` |
|
||||||
|
| Anmeldung | `AuthBrandPanel`, `FeatureItem`, `PasswordRules` |
|
||||||
|
|
||||||
|
## Adding shadcn/ui components
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npx shadcn@latest add <component>
|
||||||
|
npm uninstall cn
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, in the new `src/components/ui/<component>.tsx`:
|
||||||
|
|
||||||
|
- change `import { cn } from "cn"` to `import { cn } from "@/lib/cn"` (the registry now imports shadcn's `cn` package; ours knows the custom text and shadow scales)
|
||||||
|
- pass `container={usePortalContainer()}` (from `@/lib/portal`) to every `*.Portal`
|
||||||
|
- shadcn token names (`bg-popover`, `text-muted-foreground`, `border-border`, …) map to Collabry colors, except `accent`, which is the brand color here: replace `focus:bg-accent` / `hover:bg-accent` with `bg-hover-menu`
|
||||||
|
- the `animate-in` / `fade-in-0` / `zoom-in-95` classes need `tw-animate-css`, which is not installed; use `data-[state=open]:animate-panel-in` instead
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://ui.shadcn.com/schema.json",
|
||||||
|
"style": "new-york",
|
||||||
|
"rsc": false,
|
||||||
|
"tsx": true,
|
||||||
|
"tailwind": {
|
||||||
|
"config": "",
|
||||||
|
"css": "src/styles/index.css",
|
||||||
|
"baseColor": "neutral",
|
||||||
|
"cssVariables": true,
|
||||||
|
"prefix": ""
|
||||||
|
},
|
||||||
|
"iconLibrary": "lucide",
|
||||||
|
"aliases": {
|
||||||
|
"components": "@/components",
|
||||||
|
"utils": "@/lib/cn",
|
||||||
|
"ui": "@/components/ui",
|
||||||
|
"lib": "@/lib",
|
||||||
|
"hooks": "@/hooks"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+8317
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,65 @@
|
|||||||
|
{
|
||||||
|
"name": "@collabry/components",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"description": "Collabry UI component library (React, Tailwind CSS)",
|
||||||
|
"type": "module",
|
||||||
|
"license": "UNLICENSED",
|
||||||
|
"private": true,
|
||||||
|
"sideEffects": [
|
||||||
|
"**/*.css"
|
||||||
|
],
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"module": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"import": "./dist/index.js"
|
||||||
|
},
|
||||||
|
"./styles.css": "./dist/collabry.css"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"dev": "storybook dev -p 6006",
|
||||||
|
"storybook": "storybook dev -p 6006",
|
||||||
|
"build-storybook": "storybook build",
|
||||||
|
"build": "tsc -p tsconfig.build.json && vite build",
|
||||||
|
"typecheck": "tsc --noEmit"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^18.2.0 || ^19.0.0",
|
||||||
|
"react-dom": "^18.2.0 || ^19.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"class-variance-authority": "0.7.1",
|
||||||
|
"clsx": "2.1.1",
|
||||||
|
"cmdk": "1.1.1",
|
||||||
|
"lucide-react": "0.469.0",
|
||||||
|
"radix-ui": "1.8.1",
|
||||||
|
"sonner": "2.0.8",
|
||||||
|
"tailwind-merge": "3.7.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@fontsource/lato": "5.1.1",
|
||||||
|
"@storybook/addon-a11y": "8.6.14",
|
||||||
|
"@storybook/addon-essentials": "8.6.14",
|
||||||
|
"@storybook/blocks": "8.6.14",
|
||||||
|
"@storybook/react": "8.6.14",
|
||||||
|
"@storybook/react-vite": "8.6.14",
|
||||||
|
"@storybook/test": "8.6.14",
|
||||||
|
"@tailwindcss/vite": "4.1.11",
|
||||||
|
"@types/node": "22.10.5",
|
||||||
|
"@types/react": "18.3.18",
|
||||||
|
"@types/react-dom": "18.3.5",
|
||||||
|
"@vitejs/plugin-react": "4.3.4",
|
||||||
|
"react": "18.3.1",
|
||||||
|
"react-dom": "18.3.1",
|
||||||
|
"storybook": "8.6.14",
|
||||||
|
"tailwindcss": "4.1.11",
|
||||||
|
"typescript": "5.7.3",
|
||||||
|
"vite": "6.0.7",
|
||||||
|
"vite-plugin-dts": "4.4.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 305 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="282" height="282" viewBox="35 14 282 282" role="img" aria-label="Collabry"><title>Collabry</title><defs><linearGradient id="word" x1="0" y1="0" x2="1" y2="0"><stop stop-color="#65cfff"></stop><stop offset=".5" stop-color="#a5a4ff"></stop><stop offset="1" stop-color="#eb62e9"></stop></linearGradient><linearGradient id="bird0" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#5942ff"></stop><stop offset="1" stop-color="#dc9aff"></stop></linearGradient><linearGradient id="bird1" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#0054e8"></stop><stop offset="1" stop-color="#70efff"></stop></linearGradient><linearGradient id="bird2" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#008f8e"></stop><stop offset="1" stop-color="#d8ff77"></stop></linearGradient><linearGradient id="bird3" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#ee330c"></stop><stop offset="1" stop-color="#ffe46b"></stop></linearGradient><linearGradient id="bird4" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#af19d1"></stop><stop offset="1" stop-color="#ff9adc"></stop></linearGradient></defs><g transform="translate(20 20) scale(1.12)"><g fill="url(#bird0)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g></svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="632" height="714" viewBox="64 59 632 714" role="img" aria-label="Collabry text-and-logo colour"><title>Collabry — text-and-logo — colour</title><defs><linearGradient id="word" x1="0" y1="0" x2="1" y2="0"><stop stop-color="#65cfff"></stop><stop offset=".5" stop-color="#a5a4ff"></stop><stop offset="1" stop-color="#eb62e9"></stop></linearGradient><linearGradient id="bird0" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#5942ff"></stop><stop offset="1" stop-color="#dc9aff"></stop></linearGradient><linearGradient id="bird1" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#0054e8"></stop><stop offset="1" stop-color="#70efff"></stop></linearGradient><linearGradient id="bird2" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#008f8e"></stop><stop offset="1" stop-color="#d8ff77"></stop></linearGradient><linearGradient id="bird3" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#ee330c"></stop><stop offset="1" stop-color="#ffe46b"></stop></linearGradient><linearGradient id="bird4" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#af19d1"></stop><stop offset="1" stop-color="#ff9adc"></stop></linearGradient></defs><g transform="translate(80 10)"><g transform="translate(300 300) rotate(-12) translate(-94 -274) scale(.88)"><g fill="url(#bird0)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g><g transform="translate(300 300) rotate(60) translate(-94 -274) scale(.88)"><g fill="url(#bird1)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g><g transform="translate(300 300) rotate(132) translate(-94 -274) scale(.88)"><g fill="url(#bird2)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g><g transform="translate(300 300) rotate(204) translate(-94 -274) scale(.88)"><g fill="url(#bird3)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g><g transform="translate(300 300) rotate(276) translate(-94 -274) scale(.88)"><g fill="url(#bird4)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g></g><g fill="url(#word)" transform="translate(70 625) scale(0.15151515151515152)"><path transform="translate(-30 752)" d="M599 -206C538 -143 487 -119 416 -119C279 -119 168 -233 168 -371C168 -431 191 -495 229 -539C274 -592 338 -620 413 -620C499 -620 557 -592 607 -527H760C731 -591 705 -626 655 -667C587 -722 500 -752 410 -752C201 -752 30 -581 30 -372C30 -158 203 13 419 13C571 13 702 -71 760 -206ZM1104 -567C943 -567 811 -436 811 -277C811 -117 943 13 1105 13C1266 13 1400 -117 1400 -273C1400 -438 1271 -567 1104 -567ZM1105 -445C1194 -445 1266 -370 1266 -277C1266 -184 1194 -109 1106 -109C1016 -109 945 -184 945 -279C945 -370 1017 -445 1105 -445ZM1475 0H1608V-739H1475ZM1715 0H1848V-739H1715ZM2516 -554H2394V-480C2348 -541 2293 -567 2213 -567C2049 -567 1931 -444 1931 -275C1931 -108 2048 13 2210 13C2288 13 2341 -11 2394 -72V0H2516ZM2227 -445C2322 -445 2390 -374 2390 -273C2390 -233 2374 -187 2350 -159C2323 -126 2280 -109 2229 -109C2132 -109 2065 -175 2065 -272C2065 -373 2132 -445 2227 -445ZM2615 0H2737V-71C2794 -10 2847 13 2929 13C3015 13 3083 -19 3134 -84C3176 -138 3199 -207 3199 -281C3199 -449 3080 -574 2920 -574C2847 -574 2800 -554 2748 -503V-739H2615ZM2901 -452C2996 -452 3065 -380 3065 -280C3065 -178 2999 -109 2904 -109C2807 -109 2740 -180 2740 -281C2740 -381 2807 -452 2901 -452ZM3275 0H3408V-308C3405 -390 3447 -436 3527 -439V-567H3517C3460 -567 3432 -551 3397 -500V-554H3275ZM3659 185H3802L4122 -554H3968L3835 -195L3712 -554H3560L3763 -52Z"></path></g></svg>
|
||||||
|
After Width: | Height: | Size: 4.7 KiB |
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="1114" height="250" viewBox="35 29 1114 250" role="img" aria-label="Collabry single-hummingbird colour"><title>Collabry — single-hummingbird — colour</title><defs><linearGradient id="word" x1="0" y1="0" x2="1" y2="0"><stop stop-color="#65cfff"></stop><stop offset=".5" stop-color="#a5a4ff"></stop><stop offset="1" stop-color="#eb62e9"></stop></linearGradient><linearGradient id="bird0" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#5942ff"></stop><stop offset="1" stop-color="#dc9aff"></stop></linearGradient><linearGradient id="bird1" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#0054e8"></stop><stop offset="1" stop-color="#70efff"></stop></linearGradient><linearGradient id="bird2" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#008f8e"></stop><stop offset="1" stop-color="#d8ff77"></stop></linearGradient><linearGradient id="bird3" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#ee330c"></stop><stop offset="1" stop-color="#ffe46b"></stop></linearGradient><linearGradient id="bird4" x1="0" y1="1" x2=".8" y2="0"><stop stop-color="#af19d1"></stop><stop offset="1" stop-color="#ff9adc"></stop></linearGradient></defs><g transform="translate(20 20) scale(1.12)"><g fill="url(#bird0)"><path d="M 33 12 C 83 28 119 63 142 109 C 151 99 156 85 172 83 C 184 80 193 87 198 91 L 260 77 L 201 100 C 187 105 183 119 170 133 C 151 154 128 153 113 166 C 94 183 78 202 61 227 C 65 194 80 165 102 146 C 69 159 39 147 21 124 C 49 121 72 125 94 135 C 59 122 32 101 17 76 C 53 77 82 94 110 119 C 73 88 46 49 33 12 Z"></path></g></g><g fill="url(#word)" transform="translate(335 88) scale(0.19794721407624633)"><path transform="translate(-30 752)" d="M599 -206C538 -143 487 -119 416 -119C279 -119 168 -233 168 -371C168 -431 191 -495 229 -539C274 -592 338 -620 413 -620C499 -620 557 -592 607 -527H760C731 -591 705 -626 655 -667C587 -722 500 -752 410 -752C201 -752 30 -581 30 -372C30 -158 203 13 419 13C571 13 702 -71 760 -206ZM1104 -567C943 -567 811 -436 811 -277C811 -117 943 13 1105 13C1266 13 1400 -117 1400 -273C1400 -438 1271 -567 1104 -567ZM1105 -445C1194 -445 1266 -370 1266 -277C1266 -184 1194 -109 1106 -109C1016 -109 945 -184 945 -279C945 -370 1017 -445 1105 -445ZM1475 0H1608V-739H1475ZM1715 0H1848V-739H1715ZM2516 -554H2394V-480C2348 -541 2293 -567 2213 -567C2049 -567 1931 -444 1931 -275C1931 -108 2048 13 2210 13C2288 13 2341 -11 2394 -72V0H2516ZM2227 -445C2322 -445 2390 -374 2390 -273C2390 -233 2374 -187 2350 -159C2323 -126 2280 -109 2229 -109C2132 -109 2065 -175 2065 -272C2065 -373 2132 -445 2227 -445ZM2615 0H2737V-71C2794 -10 2847 13 2929 13C3015 13 3083 -19 3134 -84C3176 -138 3199 -207 3199 -281C3199 -449 3080 -574 2920 -574C2847 -574 2800 -554 2748 -503V-739H2615ZM2901 -452C2996 -452 3065 -380 3065 -280C3065 -178 2999 -109 2904 -109C2807 -109 2740 -180 2740 -281C2740 -381 2807 -452 2901 -452ZM3275 0H3408V-308C3405 -390 3447 -436 3527 -439V-567H3517C3460 -567 3432 -551 3397 -500V-554H3275ZM3659 185H3802L4122 -554H3968L3835 -195L3712 -554H3560L3763 -52Z"></path></g></svg>
|
||||||
|
After Width: | Height: | Size: 3.0 KiB |
@@ -0,0 +1,178 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { useState, type FormEvent, type ReactNode } from 'react';
|
||||||
|
import { Button, type ButtonState } from '../Button/Button';
|
||||||
|
import { Checkbox } from '../Checkbox/Checkbox';
|
||||||
|
import { Field, Input, PasswordInput } from '../Field/Field';
|
||||||
|
import { AuthBrandPanel, PasswordRules, passwordRules } from './Auth';
|
||||||
|
|
||||||
|
const meta: Meta<typeof AuthBrandPanel> = {
|
||||||
|
title: 'Anmeldung/Anmeldung',
|
||||||
|
component: AuthBrandPanel,
|
||||||
|
parameters: { layout: 'fullscreen' },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof AuthBrandPanel>;
|
||||||
|
|
||||||
|
function FormCard({ label, onSubmit, children }: { label: string; onSubmit: (e: FormEvent) => void; children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<div className="rounded-[18px] border border-line-frame bg-frame p-[5px]">
|
||||||
|
<form
|
||||||
|
aria-label={label}
|
||||||
|
noValidate
|
||||||
|
onSubmit={onSubmit}
|
||||||
|
className="m-0 box-border flex flex-col gap-[18px] rounded-[13px] border border-line bg-surface p-[22px]"
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Login: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [email, setEmail] = useState('');
|
||||||
|
const [pw, setPw] = useState('');
|
||||||
|
const [tried, setTried] = useState(false);
|
||||||
|
const [state, setState] = useState<ButtonState>('idle');
|
||||||
|
const emailBad = tried && !/^\S+@\S+\.\S+$/.test(email);
|
||||||
|
const pwBad = tried && !pw;
|
||||||
|
const submit = (e: FormEvent) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setTried(true);
|
||||||
|
if (!/^\S+@\S+\.\S+$/.test(email) || !pw) return;
|
||||||
|
setState('loading');
|
||||||
|
setTimeout(() => setState('success'), 1100);
|
||||||
|
setTimeout(() => setState('idle'), 1900);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="flex min-h-[860px] flex-wrap">
|
||||||
|
<AuthBrandPanel />
|
||||||
|
<main className="box-border flex min-w-0 flex-[1_1_440px] items-center justify-center px-4 py-12">
|
||||||
|
<div className="flex w-full max-w-[400px] flex-col gap-6">
|
||||||
|
<div>
|
||||||
|
<h1 className="m-0 text-display font-black tracking-[-0.01em]">Willkommen zurück</h1>
|
||||||
|
<p className="mt-1.5 mb-0 text-fg-muted">Melde dich an, um mit deinem Team weiterzuarbeiten.</p>
|
||||||
|
</div>
|
||||||
|
<FormCard label="Anmelden" onSubmit={submit}>
|
||||||
|
<Field label="E-Mail" error={emailBad ? 'Bitte gib eine gültige E-Mail-Adresse ein.' : undefined}>
|
||||||
|
{({ id, invalid, describedBy }) => (
|
||||||
|
<Input
|
||||||
|
id={id}
|
||||||
|
size="lg"
|
||||||
|
autoComplete="email"
|
||||||
|
placeholder="du@beispiel.at"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
invalid={invalid}
|
||||||
|
aria-describedby={describedBy}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<Field
|
||||||
|
label="Passwort"
|
||||||
|
labelAside={<a href="#">Passwort vergessen?</a>}
|
||||||
|
error={pwBad ? 'Bitte gib dein Passwort ein.' : undefined}
|
||||||
|
>
|
||||||
|
{({ id, invalid, describedBy }) => (
|
||||||
|
<PasswordInput
|
||||||
|
id={id}
|
||||||
|
size="lg"
|
||||||
|
autoComplete="current-password"
|
||||||
|
value={pw}
|
||||||
|
onChange={(e) => setPw(e.target.value)}
|
||||||
|
invalid={invalid}
|
||||||
|
aria-describedby={describedBy}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<Checkbox label="Angemeldet bleiben" />
|
||||||
|
<Button type="submit" variant="primary" size="xl" fullWidth state={state}>
|
||||||
|
Anmelden
|
||||||
|
</Button>
|
||||||
|
</FormCard>
|
||||||
|
<p className="m-0 text-center text-fg-muted">
|
||||||
|
Noch kein Konto?{' '}
|
||||||
|
<a href="#" className="font-bold">
|
||||||
|
Registrieren
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Registrierung: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [pw, setPw] = useState('Collabry');
|
||||||
|
const [tried, setTried] = useState(false);
|
||||||
|
const rules = passwordRules(pw);
|
||||||
|
return (
|
||||||
|
<div className="flex min-h-[900px] flex-wrap">
|
||||||
|
<AuthBrandPanel />
|
||||||
|
<main className="box-border flex min-w-0 flex-[1_1_440px] items-center justify-center px-4 py-12">
|
||||||
|
<div className="flex w-full max-w-[400px] flex-col gap-6">
|
||||||
|
<div>
|
||||||
|
<h1 className="m-0 text-display font-black tracking-[-0.01em]">Konto erstellen</h1>
|
||||||
|
<p className="mt-1.5 mb-0 text-fg-muted">Sicher registrieren und direkt mit deinem Team loslegen.</p>
|
||||||
|
</div>
|
||||||
|
<FormCard
|
||||||
|
label="Registrieren"
|
||||||
|
onSubmit={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
setTried(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="grid grid-cols-2 gap-3">
|
||||||
|
<Field label="Vorname">{({ id }) => <Input id={id} size="lg" autoComplete="given-name" />}</Field>
|
||||||
|
<Field label="Nachname">{({ id }) => <Input id={id} size="lg" autoComplete="family-name" />}</Field>
|
||||||
|
</div>
|
||||||
|
<Field label="E-Mail">
|
||||||
|
{({ id }) => <Input id={id} size="lg" autoComplete="email" placeholder="du@beispiel.at" />}
|
||||||
|
</Field>
|
||||||
|
<div className="flex flex-col gap-1.5">
|
||||||
|
<Field label="Passwort">
|
||||||
|
{({ id }) => (
|
||||||
|
<PasswordInput
|
||||||
|
id={id}
|
||||||
|
size="lg"
|
||||||
|
autoComplete="new-password"
|
||||||
|
value={pw}
|
||||||
|
onChange={(e) => setPw(e.target.value)}
|
||||||
|
aria-describedby="reg-pw-rules"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<PasswordRules id="reg-pw-rules" rules={rules} showErrors={tried} />
|
||||||
|
</div>
|
||||||
|
<Button type="submit" variant="primary" size="xl" fullWidth>
|
||||||
|
Konto erstellen
|
||||||
|
</Button>
|
||||||
|
</FormCard>
|
||||||
|
<p className="m-0 text-center text-fg-muted">
|
||||||
|
Schon ein Konto?{' '}
|
||||||
|
<a href="#" className="font-bold">
|
||||||
|
Anmelden
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Passwortregeln: Story = {
|
||||||
|
parameters: { layout: 'padded' },
|
||||||
|
render: function Render() {
|
||||||
|
const [pw, setPw] = useState('abc');
|
||||||
|
return (
|
||||||
|
<div className="flex max-w-[400px] flex-col gap-1.5">
|
||||||
|
<PasswordInput aria-label="Passwort" value={pw} onChange={(e) => setPw(e.target.value)} />
|
||||||
|
<PasswordRules rules={passwordRules(pw)} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { Check, ListChecks, Target, Users } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Logo } from '../Logo/Logo';
|
||||||
|
|
||||||
|
export interface FeatureItemProps {
|
||||||
|
icon: ReactNode;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Icon tile + title + one line, used on the login brand panel. */
|
||||||
|
export function FeatureItem({ icon, title, description }: FeatureItemProps) {
|
||||||
|
return (
|
||||||
|
<li className="flex list-none items-start gap-3.5">
|
||||||
|
<span className="flex h-9 w-9 flex-none items-center justify-center rounded-[10px] border border-line-divider bg-feature text-accent-fg">
|
||||||
|
{icon}
|
||||||
|
</span>
|
||||||
|
<div>
|
||||||
|
<div className="leading-tight font-bold">{title}</div>
|
||||||
|
<div className="mt-0.5 leading-snug text-fg-muted">{description}</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const featureIcon = { size: 18, strokeWidth: 1.75, 'aria-hidden': true } as const;
|
||||||
|
|
||||||
|
export const defaultFeatures: FeatureItemProps[] = [
|
||||||
|
{ icon: <Users {...featureIcon} />, title: 'Alles an einem Ort', description: 'Team, Aufgaben und Deadlines. Endlich gebündelt!' },
|
||||||
|
{ icon: <ListChecks {...featureIcon} />, title: 'Immer im Bild', description: 'Wer macht was bis wann? Ein Blick genügt!' },
|
||||||
|
{ icon: <Target {...featureIcon} />, title: 'Mehr Fokus', description: 'Weniger Chaos, mehr Zeit fürs Wesentliche.' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export interface AuthBrandPanelProps {
|
||||||
|
headline?: string;
|
||||||
|
features?: FeatureItemProps[];
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Left half of the login and register screens. */
|
||||||
|
export function AuthBrandPanel({
|
||||||
|
headline = 'Gruppenarbeit, die einfach funktioniert!',
|
||||||
|
features = defaultFeatures,
|
||||||
|
className,
|
||||||
|
}: AuthBrandPanelProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'box-border flex min-w-0 flex-[1_1_520px] flex-col items-center justify-center gap-9 border-r border-line-shell bg-brand px-[clamp(24px,5vw,72px)] py-12',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Logo variant="stacked" />
|
||||||
|
<div className="flex w-full max-w-[420px] flex-col gap-7">
|
||||||
|
<p className="m-0 text-center text-[30px] leading-tight font-black tracking-[-0.01em] text-balance">{headline}</p>
|
||||||
|
<ul className="m-0 flex flex-col gap-[18px] p-0">
|
||||||
|
{features.map((f) => (
|
||||||
|
<FeatureItem key={f.title} {...f} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PasswordRule {
|
||||||
|
label: string;
|
||||||
|
met: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Checks a password against the design's three rules. */
|
||||||
|
export function passwordRules(pw: string): PasswordRule[] {
|
||||||
|
return [
|
||||||
|
{ label: 'Mindestens 8 Zeichen', met: pw.length >= 8 },
|
||||||
|
{ label: 'Groß- und Kleinbuchstaben', met: /[a-zäöü]/.test(pw) && /[A-ZÄÖÜ]/.test(pw) },
|
||||||
|
{ label: 'Mindestens eine Zahl', met: /\d/.test(pw) },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PasswordRulesProps {
|
||||||
|
rules: PasswordRule[];
|
||||||
|
id?: string;
|
||||||
|
/** Show unmet rules in red (after a submit attempt). */
|
||||||
|
showErrors?: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Live checklist under the password field. */
|
||||||
|
export function PasswordRules({ rules, id, showErrors, className }: PasswordRulesProps) {
|
||||||
|
return (
|
||||||
|
<ul id={id} aria-label="Passwort-Anforderungen" className={cn('m-0 mt-1 flex flex-col gap-1.5 p-0', className)}>
|
||||||
|
{rules.map((r) => (
|
||||||
|
<li
|
||||||
|
key={r.label}
|
||||||
|
className={cn(
|
||||||
|
'flex list-none items-center gap-2 text-xs',
|
||||||
|
r.met ? 'text-fg-muted' : showErrors ? 'text-danger-fg' : 'text-fg-subtle',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{r.met ? (
|
||||||
|
<span className="flex h-4 w-4 flex-none items-center justify-center rounded-full bg-success text-on-color">
|
||||||
|
<Check size={10} strokeWidth={4} aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'box-border h-4 w-4 flex-none rounded-full border-[1.5px]',
|
||||||
|
showErrors ? 'border-danger-fg' : 'border-line-control',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{r.label}
|
||||||
|
<span className="sr-only">{r.met ? 'erfüllt' : 'nicht erfüllt'}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { me, people } from '../../stories/fixtures';
|
||||||
|
import { Avatar, AvatarStack } from './Avatar';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Avatar> = {
|
||||||
|
title: 'Anzeige/Avatar',
|
||||||
|
component: Avatar,
|
||||||
|
args: { person: people.LB, size: 36 },
|
||||||
|
argTypes: { person: { control: false } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Avatar>;
|
||||||
|
|
||||||
|
export const Initialen: Story = {};
|
||||||
|
|
||||||
|
export const MitFoto: Story = {
|
||||||
|
name: 'Mit Foto',
|
||||||
|
args: { person: me, size: 64 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Groessen: Story = {
|
||||||
|
name: 'Größen',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
{[22, 24, 26, 30, 32, 36].map((s) => (
|
||||||
|
<Avatar key={s} person={people.PM} size={s} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Stapel: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<AvatarStack people={Object.values(people)} />
|
||||||
|
<AvatarStack people={Object.values(people)} size={26} max={4} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
import type { HTMLAttributes } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Avatar as UiAvatar, AvatarFallback, AvatarImage } from '../ui/avatar';
|
||||||
|
|
||||||
|
export interface Person {
|
||||||
|
name: string;
|
||||||
|
/** Two-letter initials, shown when there is no image. */
|
||||||
|
initials: string;
|
||||||
|
/** Background color for the initials avatar. */
|
||||||
|
color: string;
|
||||||
|
image?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AvatarProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
person: Person;
|
||||||
|
/** Diameter in px. The design uses 22, 24, 26, 30, 32 and 36. */
|
||||||
|
size?: number;
|
||||||
|
/** Ring that separates stacked avatars. */
|
||||||
|
ring?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fontSizeFor(size: number) {
|
||||||
|
if (size <= 22) return 8;
|
||||||
|
if (size <= 26) return 10;
|
||||||
|
if (size <= 30) return 11;
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Avatar({ person, size = 32, ring = false, className, style, ...props }: AvatarProps) {
|
||||||
|
return (
|
||||||
|
<UiAvatar
|
||||||
|
role="img"
|
||||||
|
aria-label={person.name}
|
||||||
|
title={person.name}
|
||||||
|
className={cn(
|
||||||
|
ring ? 'shadow-[0_0_0_2px_var(--cl-surface)]' : person.image && 'shadow-[0_0_0_1px_var(--cl-line-heavy)]',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
style={{ width: size, height: size, ...style }}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{person.image && <AvatarImage src={person.image} alt="" />}
|
||||||
|
<AvatarFallback style={{ background: person.color, fontSize: fontSizeFor(size) }}>
|
||||||
|
<span aria-hidden="true">{person.initials}</span>
|
||||||
|
</AvatarFallback>
|
||||||
|
</UiAvatar>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AvatarStackProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
people: Person[];
|
||||||
|
size?: number;
|
||||||
|
/** Show at most this many, then "+n". */
|
||||||
|
max?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Overlapping avatars for group members. */
|
||||||
|
export function AvatarStack({ people, size = 22, max = 5, className, ...props }: AvatarStackProps) {
|
||||||
|
const shown = people.slice(0, max);
|
||||||
|
const rest = people.length - shown.length;
|
||||||
|
return (
|
||||||
|
<span className={cn('flex flex-none pl-1.5', className)} {...props}>
|
||||||
|
{shown.map((p) => (
|
||||||
|
<Avatar key={p.name} person={p} size={size} ring className="-ml-1.5" />
|
||||||
|
))}
|
||||||
|
{rest > 0 && (
|
||||||
|
<span
|
||||||
|
className="-ml-1.5 inline-flex flex-none items-center justify-center rounded-full bg-chip font-bold text-fg-3 shadow-[0_0_0_2px_var(--cl-surface)]"
|
||||||
|
style={{ width: size, height: size, fontSize: fontSizeFor(size) }}
|
||||||
|
>
|
||||||
|
+{rest}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { swatches } from '../../lib/tokens';
|
||||||
|
import { CountBadge, Kbd, RoleBadge, StatusBadge, Swatch } from './Badge';
|
||||||
|
|
||||||
|
const meta: Meta<typeof StatusBadge> = {
|
||||||
|
title: 'Anzeige/Badges',
|
||||||
|
component: StatusBadge,
|
||||||
|
args: { status: 'doing' },
|
||||||
|
argTypes: { status: { control: 'inline-radio', options: ['done', 'review', 'doing', 'open'] } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof StatusBadge>;
|
||||||
|
|
||||||
|
export const Status: Story = {};
|
||||||
|
|
||||||
|
export const AlleStatus: Story = {
|
||||||
|
name: 'Alle Status',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
<StatusBadge status="done" />
|
||||||
|
<StatusBadge status="review" />
|
||||||
|
<StatusBadge status="doing" />
|
||||||
|
<StatusBadge status="open" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Zaehler: Story = {
|
||||||
|
name: 'Zähler & Rollen',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<span className="text-md font-bold">Meine Aufgaben</span>
|
||||||
|
<CountBadge>6</CountBadge>
|
||||||
|
</span>
|
||||||
|
<span className="flex items-center gap-2">
|
||||||
|
<span className="text-md font-bold">Benachrichtigungen</span>
|
||||||
|
<CountBadge tone="accent">4</CountBadge>
|
||||||
|
</span>
|
||||||
|
<RoleBadge role="admin" />
|
||||||
|
<RoleBadge role="member" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Farbfelder: Story = {
|
||||||
|
name: 'Farbfelder & Tasten',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Swatch color={swatches.violet} size={10} />
|
||||||
|
<Swatch color={swatches.cyan} />
|
||||||
|
<Swatch color={swatches.pink} />
|
||||||
|
<span className="flex items-center gap-[7px] text-xs text-fg-muted">
|
||||||
|
<Swatch color={swatches.violet} />
|
||||||
|
SWE · Collabry
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
<Kbd>⌘</Kbd>
|
||||||
|
<Kbd>K</Kbd>
|
||||||
|
<span className="ml-3 flex items-center gap-1.5 text-xs text-fg-subtle">
|
||||||
|
<Kbd size="sm">↵</Kbd>
|
||||||
|
Öffnen
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import type { HTMLAttributes, ReactNode } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Badge } from '../ui/badge';
|
||||||
|
import { Kbd as UiKbd } from '../ui/kbd';
|
||||||
|
import { taskStatusLabel, type TaskStatus } from '../../lib/tokens';
|
||||||
|
|
||||||
|
const statusStyles: Record<TaskStatus, string> = {
|
||||||
|
done: 'text-success-fg bg-[rgba(74,222,128,0.08)] border-[rgba(74,222,128,0.22)]',
|
||||||
|
review: 'text-warning-fg bg-[rgba(251,191,36,0.08)] border-[rgba(251,191,36,0.22)]',
|
||||||
|
doing: 'text-info-fg bg-[rgba(96,165,250,0.09)] border-[rgba(96,165,250,0.25)]',
|
||||||
|
open: 'text-fg-open bg-status-open border-line-strong',
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface StatusBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
status: TaskStatus;
|
||||||
|
/** Overrides the default German label. */
|
||||||
|
label?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Task status tag: Erledigt, Review, In Arbeit, Offen. */
|
||||||
|
export function StatusBadge({ status, label, className, ...props }: StatusBadgeProps) {
|
||||||
|
return (
|
||||||
|
<Badge variant="status" className={cn(statusStyles[status], className)} {...props}>
|
||||||
|
{label ?? taskStatusLabel[status]}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CountBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
children: ReactNode;
|
||||||
|
/** `accent` is used for unread counts. */
|
||||||
|
tone?: 'neutral' | 'accent';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Small pill showing a count next to a heading. */
|
||||||
|
export function CountBadge({ tone = 'neutral', className, children, ...props }: CountBadgeProps) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant="count"
|
||||||
|
className={cn(tone === 'accent' ? 'bg-accent font-bold text-on-accent' : 'bg-chip font-normal text-fg-3', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoleBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
role?: 'admin' | 'member';
|
||||||
|
children?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Admin" / "Mitglied" tag on group cards and member lists. */
|
||||||
|
export function RoleBadge({ role = 'member', className, children, ...props }: RoleBadgeProps) {
|
||||||
|
return (
|
||||||
|
<Badge
|
||||||
|
variant="tag"
|
||||||
|
className={cn(role === 'admin' ? 'bg-accent-chip text-accent-fg' : 'bg-chip text-fg-muted', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children ?? (role === 'admin' ? 'Admin' : 'Mitglied')}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SwatchProps extends HTMLAttributes<HTMLSpanElement> {
|
||||||
|
color: string;
|
||||||
|
/** 8px in meta lines, 10px next to headings. */
|
||||||
|
size?: 8 | 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Colored square that identifies a group. */
|
||||||
|
export function Swatch({ color, size = 8, className, style, ...props }: SwatchProps) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn('inline-block flex-none', size === 8 ? 'h-2 w-2 rounded-[2px]' : 'h-2.5 w-2.5 rounded-[3px]', className)}
|
||||||
|
style={{ background: color, ...style }}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface KbdProps extends HTMLAttributes<HTMLElement> {
|
||||||
|
size?: 'sm' | 'md';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keyboard key hint, e.g. ⌘ K. */
|
||||||
|
export function Kbd({ size = 'md', className, ...props }: KbdProps) {
|
||||||
|
return (
|
||||||
|
<UiKbd className={cn(size === 'sm' && 'h-5 min-w-5 border-line-strong text-2xs', className)} {...props} />
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { fn } from '@storybook/test';
|
||||||
|
import { ChevronRight, MoreHorizontal, Plus, Trash2 } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Button, ButtonLink, type ButtonState } from './Button';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Button> = {
|
||||||
|
title: 'Grundlagen/Button',
|
||||||
|
component: Button,
|
||||||
|
args: { children: 'Neue Aufgabe', variant: 'primary', size: 'lg', onClick: fn() },
|
||||||
|
argTypes: {
|
||||||
|
variant: { control: 'inline-radio', options: ['primary', 'secondary', 'ghost', 'danger', 'danger-outline'] },
|
||||||
|
size: { control: 'inline-radio', options: ['xs', 'sm', 'md', 'lg', 'xl'] },
|
||||||
|
state: { control: 'inline-radio', options: ['idle', 'loading', 'success'] },
|
||||||
|
icon: { control: false },
|
||||||
|
iconEnd: { control: false },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Button>;
|
||||||
|
|
||||||
|
export const Primary: Story = {
|
||||||
|
args: { icon: <Plus size={16} strokeWidth={2.25} /> },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Varianten: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<Button variant="primary" size="lg" icon={<Plus size={16} strokeWidth={2.25} />}>
|
||||||
|
Neue Aufgabe
|
||||||
|
</Button>
|
||||||
|
<Button variant="secondary">Abbrechen</Button>
|
||||||
|
<Button variant="ghost">Filter zurücksetzen</Button>
|
||||||
|
<Button variant="danger">Löschen</Button>
|
||||||
|
<Button variant="danger-outline" icon={<Trash2 size={16} strokeWidth={1.75} />}>
|
||||||
|
Konto löschen
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Groessen: Story = {
|
||||||
|
name: 'Größen',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
{(['xs', 'sm', 'md', 'lg', 'xl'] as const).map((s) => (
|
||||||
|
<Button key={s} variant="primary" size={s}>
|
||||||
|
Anmelden ({s})
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const NurIcon: Story = {
|
||||||
|
name: 'Nur Icon',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Button variant="ghost" size="xs" iconOnly aria-label="Mehr Optionen" className="text-fg-subtle">
|
||||||
|
<MoreHorizontal size={16} strokeWidth={2.5} />
|
||||||
|
</Button>
|
||||||
|
<Button variant="ghost" size="xs" iconOnly aria-label="Gruppe erstellen" className="text-fg-subtle">
|
||||||
|
<Plus size={16} strokeWidth={2} />
|
||||||
|
</Button>
|
||||||
|
<Button variant="secondary" iconOnly aria-label="Weiter">
|
||||||
|
<ChevronRight size={16} strokeWidth={1.75} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Ladezustand: Story = {
|
||||||
|
name: 'Laden & Erfolg',
|
||||||
|
render: function Render() {
|
||||||
|
const [state, setState] = useState<ButtonState>('idle');
|
||||||
|
const run = () => {
|
||||||
|
setState('loading');
|
||||||
|
setTimeout(() => setState('success'), 1100);
|
||||||
|
setTimeout(() => setState('idle'), 1900);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
<Button variant="primary" size="xl" state={state} onClick={run} className="w-[200px]">
|
||||||
|
Anmelden
|
||||||
|
</Button>
|
||||||
|
<Button variant="primary" state="loading">
|
||||||
|
Speichern
|
||||||
|
</Button>
|
||||||
|
<Button variant="secondary" state="success">
|
||||||
|
Ablehnen
|
||||||
|
</Button>
|
||||||
|
<Button variant="primary" disabled>
|
||||||
|
Deaktiviert
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AlsLink: Story = {
|
||||||
|
name: 'Als Link',
|
||||||
|
render: () => (
|
||||||
|
<ButtonLink href="#" variant="secondary" size="sm" className="h-[34px]" iconEnd={<ChevronRight size={14} strokeWidth={1.75} />}>
|
||||||
|
Alle Aufgaben
|
||||||
|
</ButtonLink>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { forwardRef, type AnchorHTMLAttributes, type ButtonHTMLAttributes, type ReactNode } from 'react';
|
||||||
|
import type { VariantProps } from 'class-variance-authority';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Button as UiButton, buttonVariants } from '../ui/button';
|
||||||
|
import { Spinner, SuccessCheck } from '../Spinner/Spinner';
|
||||||
|
|
||||||
|
export { buttonVariants };
|
||||||
|
|
||||||
|
export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'danger' | 'danger-outline';
|
||||||
|
export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
||||||
|
export type ButtonState = 'idle' | 'loading' | 'success';
|
||||||
|
|
||||||
|
/** Options of `buttonVariants`, for anything that should look like a button. */
|
||||||
|
export type ButtonStyleOptions = VariantProps<typeof buttonVariants>;
|
||||||
|
|
||||||
|
const spinnerSize: Record<ButtonSize, number> = { xs: 12, sm: 14, md: 14, lg: 16, xl: 18 };
|
||||||
|
|
||||||
|
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, ButtonStyleOptions {
|
||||||
|
/** Icon before the label. */
|
||||||
|
icon?: ReactNode;
|
||||||
|
/** Icon after the label. */
|
||||||
|
iconEnd?: ReactNode;
|
||||||
|
/** Async feedback: the label hides behind a spinner, then a checkmark. */
|
||||||
|
state?: ButtonState;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
||||||
|
{ size = 'md', icon, iconEnd, state = 'idle', disabled, type = 'button', className, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
const busy = state !== 'idle';
|
||||||
|
const spinner = spinnerSize[size ?? 'md'];
|
||||||
|
return (
|
||||||
|
<UiButton
|
||||||
|
ref={ref}
|
||||||
|
type={type}
|
||||||
|
size={size}
|
||||||
|
disabled={disabled || busy}
|
||||||
|
aria-busy={state === 'loading' || undefined}
|
||||||
|
className={cn(disabled && !busy && 'opacity-50 hover:brightness-100', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className={cn('inline-flex items-center justify-center gap-[inherit]', busy && 'invisible')}>
|
||||||
|
{icon}
|
||||||
|
{children}
|
||||||
|
{iconEnd}
|
||||||
|
</span>
|
||||||
|
{state !== 'idle' && (
|
||||||
|
<span className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
||||||
|
{state === 'loading' ? <Spinner size={spinner} /> : <SuccessCheck size={spinner} />}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className="sr-only" aria-live="polite">
|
||||||
|
{state === 'loading' ? 'Wird ausgeführt …' : state === 'success' ? 'Erledigt' : ''}
|
||||||
|
</span>
|
||||||
|
</UiButton>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface ButtonLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement>, ButtonStyleOptions {
|
||||||
|
icon?: ReactNode;
|
||||||
|
iconEnd?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A link styled as a button, e.g. "Alle Aufgaben ›". */
|
||||||
|
export const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(function ButtonLink(
|
||||||
|
{ variant, size, iconOnly, fullWidth, icon, iconEnd, className, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<UiButton asChild variant={variant} size={size} iconOnly={iconOnly} fullWidth={fullWidth} className={className}>
|
||||||
|
<a ref={ref} {...props}>
|
||||||
|
{icon}
|
||||||
|
{children}
|
||||||
|
{iconEnd}
|
||||||
|
</a>
|
||||||
|
</UiButton>
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { useMemo, useState } from 'react';
|
||||||
|
import { groupRefs, people } from '../../stories/fixtures';
|
||||||
|
import { Card } from '../Card/Card';
|
||||||
|
import { SegmentedControl } from '../SegmentedControl/SegmentedControl';
|
||||||
|
import {
|
||||||
|
CalendarLegend,
|
||||||
|
CalendarMonth,
|
||||||
|
CalendarToolbar,
|
||||||
|
DayEventItem,
|
||||||
|
GroupFilterChip,
|
||||||
|
type CalendarDay,
|
||||||
|
type CalendarEvent,
|
||||||
|
} from './Calendar';
|
||||||
|
|
||||||
|
const meta: Meta<typeof CalendarMonth> = {
|
||||||
|
title: 'Kalender/Kalender',
|
||||||
|
component: CalendarMonth,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof CalendarMonth>;
|
||||||
|
|
||||||
|
type GroupKey = keyof typeof groupRefs;
|
||||||
|
const ev = (id: string, title: string, g: GroupKey, kind: CalendarEvent['kind'], extra: Partial<CalendarEvent> = {}): CalendarEvent & { g: GroupKey } => ({
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
color: groupRefs[g].color,
|
||||||
|
group: groupRefs[g].name,
|
||||||
|
kind,
|
||||||
|
g,
|
||||||
|
...extra,
|
||||||
|
});
|
||||||
|
|
||||||
|
/** Events in November 2026, keyed by day of month. */
|
||||||
|
const EVENTS: Record<number, (CalendarEvent & { g: GroupKey })[]> = {
|
||||||
|
2: [ev('e1', 'ER-Diagramm finalisieren', 'db', 'task', { status: 'Offen', statusColor: 'var(--cl-fg-open)', assignee: people.PM })],
|
||||||
|
4: [ev('e2', 'Login & Registrierung umsetzen', 'swe', 'task', { status: 'In Arbeit', statusColor: 'var(--cl-info-fg)', assignee: people.NH })],
|
||||||
|
5: [
|
||||||
|
ev('e3', 'Präsentation Marktanalyse', 'mk', 'milestone'),
|
||||||
|
ev('e4', 'Dashboard-UI entwerfen', 'swe', 'task', { status: 'Review', statusColor: 'var(--cl-warning-fg)', assignee: people.KB }),
|
||||||
|
],
|
||||||
|
6: [ev('e5', 'Kanban-Board: API-Endpunkte', 'swe', 'task', { assignee: people.LK })],
|
||||||
|
9: [ev('e6', 'Git-Branching-Regeln dokumentieren', 'swe', 'task', { assignee: people.LK })],
|
||||||
|
11: [ev('e7', 'Umfrage-Ergebnisse auswerten', 'mk', 'task', { assignee: people.KB })],
|
||||||
|
13: [
|
||||||
|
ev('e8', 'Normalisierung Übung 4', 'db', 'task'),
|
||||||
|
ev('e9', 'Testkonzept', 'swe', 'task'),
|
||||||
|
ev('e10', 'Abgabe Übungsblatt', 'db', 'milestone'),
|
||||||
|
ev('e11', 'Sprint-Review vorbereiten', 'swe', 'task'),
|
||||||
|
],
|
||||||
|
27: [ev('e12', 'Abgabe Iteration 2', 'swe', 'milestone')],
|
||||||
|
};
|
||||||
|
const OCT_EVENTS: Record<number, (CalendarEvent & { g: GroupKey })[]> = {
|
||||||
|
30: [ev('e0', 'Gruppen-Einladung per Link', 'swe', 'task', { overdue: true, assignee: people.NH })],
|
||||||
|
31: [ev('e00', 'Review Iteration 1 schreiben', 'swe', 'task', { done: true, assignee: people.LB })],
|
||||||
|
};
|
||||||
|
|
||||||
|
/** November 2026 starts on a Sunday; Monday-first grid from 26 Oct to 6 Dec. */
|
||||||
|
function buildNovember(active: Record<GroupKey, boolean>): CalendarDay[] {
|
||||||
|
const days: CalendarDay[] = [];
|
||||||
|
const start = new Date(2026, 9, 26);
|
||||||
|
for (let i = 0; i < 42; i++) {
|
||||||
|
const d = new Date(start);
|
||||||
|
d.setDate(start.getDate() + i);
|
||||||
|
const inMonth = d.getMonth() === 10;
|
||||||
|
const src = inMonth ? EVENTS : d.getMonth() === 9 ? OCT_EVENTS : {};
|
||||||
|
const events = (src[d.getDate()] ?? []).filter((e) => active[e.g]);
|
||||||
|
days.push({
|
||||||
|
date: `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`,
|
||||||
|
day: d.getDate(),
|
||||||
|
inMonth,
|
||||||
|
weekend: d.getDay() === 0 || d.getDay() === 6,
|
||||||
|
today: inMonth && d.getDate() === 1,
|
||||||
|
events,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Monat: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [active, setActive] = useState<Record<GroupKey, boolean>>({ swe: true, db: true, mk: true });
|
||||||
|
const days = useMemo(() => buildNovember(active), [active]);
|
||||||
|
const [selected, setSelected] = useState(days.find((d) => d.inMonth && d.day === 5)!.date);
|
||||||
|
const [view, setView] = useState('month');
|
||||||
|
const day = days.find((d) => d.date === selected);
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-5">
|
||||||
|
<div className="flex flex-wrap items-center gap-4">
|
||||||
|
<h1 className="m-0 text-display font-black tracking-[-0.01em]">Kalender</h1>
|
||||||
|
<CalendarToolbar rangeLabel="November 2026" />
|
||||||
|
<SegmentedControl
|
||||||
|
label="Ansicht"
|
||||||
|
className="ml-auto"
|
||||||
|
value={view}
|
||||||
|
onChange={setView}
|
||||||
|
options={[
|
||||||
|
{ value: 'month', label: 'Monat' },
|
||||||
|
{ value: 'week', label: 'Woche' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div role="group" aria-label="Gruppen filtern" className="flex flex-wrap gap-1.5">
|
||||||
|
{(Object.keys(groupRefs) as GroupKey[]).map((k) => (
|
||||||
|
<GroupFilterChip
|
||||||
|
key={k}
|
||||||
|
name={groupRefs[k].name}
|
||||||
|
color={groupRefs[k].color}
|
||||||
|
on={active[k]}
|
||||||
|
onToggle={() => setActive((a) => ({ ...a, [k]: !a[k] }))}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap items-start gap-5">
|
||||||
|
<Card padding="none" className="min-w-0 flex-[999_1_640px]" innerClassName="overflow-hidden" aria-label="November 2026">
|
||||||
|
<CalendarMonth days={days} selected={selected} onSelect={setSelected} label="November 2026" />
|
||||||
|
<CalendarLegend />
|
||||||
|
</Card>
|
||||||
|
<Card as="aside" padding="none" aria-label="Tagesansicht" className="min-w-0 max-w-[380px] flex-[1_1_300px]">
|
||||||
|
<div className="px-[18px] pt-4 pb-3.5">
|
||||||
|
<div className="text-xs font-bold text-fg-subtle">{day?.today ? 'Heute' : 'Ausgewählter Tag'}</div>
|
||||||
|
<h2 className="mt-0.5 mb-0 text-lg font-bold">{day ? `${day.day}. November` : ''}</h2>
|
||||||
|
</div>
|
||||||
|
<ul className="m-0 p-0">
|
||||||
|
{day?.events.map((e) => (
|
||||||
|
<DayEventItem key={e.id} event={e} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
{day && day.events.length === 0 && (
|
||||||
|
<div className="border-t border-line-subtle px-[18px] py-4 text-sm text-fg-subtle">Keine Deadlines</div>
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Filterchips: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex gap-1.5">
|
||||||
|
<GroupFilterChip name="SWE · Collabry" color={groupRefs.swe.color} on />
|
||||||
|
<GroupFilterChip name="Datenbanken Übung" color={groupRefs.db.color} on={false} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,262 @@
|
|||||||
|
import { ChevronLeft, ChevronRight, Flag, SquareCheck } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Avatar, type Person } from '../Avatar/Avatar';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
import { Toggle } from '../ui/toggle';
|
||||||
|
|
||||||
|
export interface CalendarEvent {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
/** Group color. */
|
||||||
|
color: string;
|
||||||
|
group: string;
|
||||||
|
/** `milestone` = Abgabe der Gruppe, `task` = Aufgaben-Deadline. */
|
||||||
|
kind: 'milestone' | 'task';
|
||||||
|
done?: boolean;
|
||||||
|
overdue?: boolean;
|
||||||
|
/** Status label for the day list, e.g. "In Arbeit". */
|
||||||
|
status?: string;
|
||||||
|
statusColor?: string;
|
||||||
|
assignee?: Person;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CalendarDay {
|
||||||
|
/** ISO date, used as key and for callbacks. */
|
||||||
|
date: string;
|
||||||
|
day: number;
|
||||||
|
inMonth: boolean;
|
||||||
|
weekend?: boolean;
|
||||||
|
today?: boolean;
|
||||||
|
events: CalendarEvent[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const kindLabel = { milestone: 'Abgabe', task: 'Aufgabe' } as const;
|
||||||
|
|
||||||
|
/** Event pill inside a month cell. */
|
||||||
|
export function CalendarChip({ event: e }: { event: CalendarEvent }) {
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'box-border flex h-[22px] min-w-0 items-center gap-[5px] rounded-md px-1.5 text-xs leading-none',
|
||||||
|
e.done ? 'text-fg-subtle line-through' : 'text-fg',
|
||||||
|
e.kind === 'milestone' ? 'font-bold' : 'font-normal',
|
||||||
|
)}
|
||||||
|
style={{ background: `color-mix(in srgb, ${e.color} 16%, transparent)` }}
|
||||||
|
>
|
||||||
|
{e.kind === 'milestone' ? (
|
||||||
|
<Flag size={11} strokeWidth={1.75} aria-hidden="true" className="flex-none fill-current" style={{ color: e.color }} />
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
className="h-1.5 w-1.5 flex-none rounded-full"
|
||||||
|
style={{ background: e.overdue ? 'var(--cl-danger)' : 'var(--cl-fg-muted)' }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<span className="truncate">{e.title}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CalendarMonthProps {
|
||||||
|
/** 35 or 42 days, Monday first. */
|
||||||
|
days: CalendarDay[];
|
||||||
|
weekdays?: string[];
|
||||||
|
selected?: string;
|
||||||
|
onSelect?: (date: string) => void;
|
||||||
|
/** Accessible name, e.g. "November 2026". */
|
||||||
|
label: string;
|
||||||
|
/** Events shown per cell before "+n". */
|
||||||
|
maxPerCell?: number;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultWeekdays = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
|
||||||
|
|
||||||
|
/** Month grid with event chips; the selected day gets an accent ring. */
|
||||||
|
export function CalendarMonth({
|
||||||
|
days,
|
||||||
|
weekdays = defaultWeekdays,
|
||||||
|
selected,
|
||||||
|
onSelect,
|
||||||
|
label,
|
||||||
|
maxPerCell = 3,
|
||||||
|
className,
|
||||||
|
}: CalendarMonthProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn('overflow-x-auto', className)}>
|
||||||
|
<div
|
||||||
|
role="grid"
|
||||||
|
aria-label={label}
|
||||||
|
className="grid min-w-[640px] grid-cols-7 gap-px border-t border-line-subtle bg-grid"
|
||||||
|
>
|
||||||
|
{weekdays.map((w) => (
|
||||||
|
<div key={w} role="columnheader" className="bg-surface px-2.5 pt-2.5 pb-2 text-xs font-bold text-fg-subtle">
|
||||||
|
{w}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{days.map((d) => {
|
||||||
|
const isSel = d.date === selected;
|
||||||
|
const shown = d.events.slice(0, maxPerCell);
|
||||||
|
const more = d.events.length - shown.length;
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={d.date}
|
||||||
|
type="button"
|
||||||
|
role="gridcell"
|
||||||
|
aria-selected={isSel}
|
||||||
|
aria-label={`${d.day}., ${d.events.length} Einträge`}
|
||||||
|
onClick={() => onSelect?.(d.date)}
|
||||||
|
className={cn(
|
||||||
|
'box-border flex min-h-[116px] min-w-0 flex-col gap-1.5 border-0 p-2 text-left text-inherit hover:brightness-[1.18]',
|
||||||
|
!d.inMonth ? 'bg-outside' : d.weekend ? 'bg-weekend' : 'bg-surface',
|
||||||
|
isSel && 'shadow-[inset_0_0_0_2px_var(--cl-accent)]',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="flex items-center justify-between gap-1.5">
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'box-border inline-flex h-[26px] min-w-[26px] items-center justify-center rounded-full px-1.5 text-sm tabular-nums',
|
||||||
|
d.today ? 'bg-accent font-bold text-on-accent' : d.inMonth ? 'text-fg' : 'text-fg-faint',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{d.day}
|
||||||
|
</span>
|
||||||
|
{more > 0 && <span className="text-2xs text-fg-subtle">+{more}</span>}
|
||||||
|
</span>
|
||||||
|
<span className="flex min-w-0 flex-col gap-[3px]">
|
||||||
|
{shown.map((e) => (
|
||||||
|
<CalendarChip key={e.id} event={e} />
|
||||||
|
))}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Legend under the calendar grid. */
|
||||||
|
export function CalendarLegend({ className }: { className?: string }) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex flex-wrap items-center gap-x-[18px] gap-y-2 border-t border-line-subtle px-4 py-3 text-xs text-fg-subtle',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<Flag size={12} strokeWidth={1.75} aria-hidden="true" className="fill-current text-fg-muted" />
|
||||||
|
Abgabe der Gruppe
|
||||||
|
</span>
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<span className="h-1.5 w-1.5 rounded-full bg-fg-muted" />
|
||||||
|
Aufgaben-Deadline
|
||||||
|
</span>
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<span className="h-1.5 w-1.5 rounded-full bg-danger" />
|
||||||
|
Überfällig
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CalendarToolbarProps {
|
||||||
|
/** e.g. "November 2026" or "2. – 8. Nov". */
|
||||||
|
rangeLabel: string;
|
||||||
|
onPrev?: () => void;
|
||||||
|
onNext?: () => void;
|
||||||
|
onToday?: () => void;
|
||||||
|
prevLabel?: string;
|
||||||
|
nextLabel?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ‹ › range switcher and "Heute" button. */
|
||||||
|
export function CalendarToolbar({
|
||||||
|
rangeLabel,
|
||||||
|
onPrev,
|
||||||
|
onNext,
|
||||||
|
onToday,
|
||||||
|
prevLabel = 'Vorheriger Monat',
|
||||||
|
nextLabel = 'Nächster Monat',
|
||||||
|
}: CalendarToolbarProps) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-wrap items-center gap-4">
|
||||||
|
<div className="flex items-center gap-1.5">
|
||||||
|
<Button iconOnly onClick={onPrev} aria-label={prevLabel}>
|
||||||
|
<ChevronLeft size={16} strokeWidth={1.75} />
|
||||||
|
</Button>
|
||||||
|
<Button iconOnly onClick={onNext} aria-label={nextLabel}>
|
||||||
|
<ChevronRight size={16} strokeWidth={1.75} />
|
||||||
|
</Button>
|
||||||
|
<span aria-live="polite" className="min-w-[190px] pl-1.5 text-[18px] font-bold">
|
||||||
|
{rangeLabel}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Button onClick={onToday}>Heute</Button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupFilterChipProps {
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
on: boolean;
|
||||||
|
onToggle?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Toggleable group pill above the calendar. */
|
||||||
|
export function GroupFilterChip({ name, color, on, onToggle }: GroupFilterChipProps) {
|
||||||
|
return (
|
||||||
|
<Toggle variant="chip" pressed={on} onPressedChange={() => onToggle?.()}>
|
||||||
|
<span
|
||||||
|
className="h-2.5 w-2.5 rounded-[3px]"
|
||||||
|
style={{ background: on ? color : 'transparent', boxShadow: `inset 0 0 0 1.5px ${color}` }}
|
||||||
|
/>
|
||||||
|
{name}
|
||||||
|
</Toggle>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Row in the day panel next to the calendar. */
|
||||||
|
export function DayEventItem({ event: e }: { event: CalendarEvent }) {
|
||||||
|
return (
|
||||||
|
<li className="flex list-none gap-3 border-t border-line-subtle px-[18px] py-3.5">
|
||||||
|
<span
|
||||||
|
className="box-border flex h-8 w-8 flex-none items-center justify-center rounded-[9px] border"
|
||||||
|
style={{
|
||||||
|
borderColor: `color-mix(in srgb, ${e.color} 40%, transparent)`,
|
||||||
|
background: `color-mix(in srgb, ${e.color} 16%, transparent)`,
|
||||||
|
color: e.color,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{e.kind === 'milestone' ? (
|
||||||
|
<Flag size={15} strokeWidth={1.75} aria-hidden="true" className="fill-current" />
|
||||||
|
) : (
|
||||||
|
<SquareCheck size={15} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0 flex-auto">
|
||||||
|
<span className={cn('block leading-snug font-bold', e.done ? 'text-fg-subtle line-through' : 'text-fg')}>
|
||||||
|
{e.title}
|
||||||
|
</span>
|
||||||
|
<span className="mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-subtle">
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<span className="h-2 w-2 rounded-[2px]" style={{ background: e.color }} />
|
||||||
|
{e.group}
|
||||||
|
</span>
|
||||||
|
<span>·</span>
|
||||||
|
<span>{kindLabel[e.kind]}</span>
|
||||||
|
{e.status && (
|
||||||
|
<>
|
||||||
|
<span>·</span>
|
||||||
|
<span className="font-bold" style={{ color: e.statusColor }}>
|
||||||
|
{e.status}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
{e.assignee && <Avatar person={e.assignee} size={26} />}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { ChevronRight, MoreHorizontal } from 'lucide-react';
|
||||||
|
import { swatches } from '../../lib/tokens';
|
||||||
|
import { Swatch } from '../Badge/Badge';
|
||||||
|
import { Button, ButtonLink } from '../Button/Button';
|
||||||
|
import { StatusProgress } from '../Progress/Progress';
|
||||||
|
import { Card, CardFooter, CardHeader } from './Card';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Card> = {
|
||||||
|
title: 'Grundlagen/Card',
|
||||||
|
component: Card,
|
||||||
|
argTypes: { padding: { control: 'inline-radio', options: ['none', 'sm', 'md'] } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Card>;
|
||||||
|
|
||||||
|
const more = (
|
||||||
|
<Button variant="ghost" size="xs" iconOnly aria-label="Mehr Optionen" className="text-fg-subtle">
|
||||||
|
<MoreHorizontal size={16} strokeWidth={2.5} />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Leer: Story = {
|
||||||
|
args: { padding: 'md', children: 'Inhalt' },
|
||||||
|
decorators: [(Story) => <div className="max-w-[420px]">{Story()}</div>],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Projektfortschritt: Story = {
|
||||||
|
render: () => (
|
||||||
|
<Card aria-labelledby="h-progress" innerClassName="gap-5">
|
||||||
|
<CardHeader
|
||||||
|
titleId="h-progress"
|
||||||
|
title="Projektfortschritt"
|
||||||
|
subtitle={
|
||||||
|
<span className="flex items-center gap-2 text-fg-muted">
|
||||||
|
<Swatch color={swatches.violet} size={10} />
|
||||||
|
SWE · Collabry <span className="text-fg-subtle">Iteration 2</span>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
actions={more}
|
||||||
|
className="items-start"
|
||||||
|
/>
|
||||||
|
<div className="flex flex-wrap items-center gap-x-12 gap-y-5">
|
||||||
|
<div className="flex-none">
|
||||||
|
<div className="text-hero font-bold tracking-[-0.03em] tabular-nums">56%</div>
|
||||||
|
<div className="mt-2 text-fg-muted">
|
||||||
|
<strong className="text-fg">9 von 16</strong> Aufgaben erledigt
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<StatusProgress counts={{ done: 9, review: 2, doing: 3, open: 2 }} className="flex-[1_1_320px]" />
|
||||||
|
<div className="flex-none">
|
||||||
|
<div className="text-sm text-fg-subtle">Abgabe Iteration 2</div>
|
||||||
|
<div className="mt-0.5 text-[17px] font-bold">Fr, 27. November</div>
|
||||||
|
<div className="mt-0.5 font-bold text-accent-fg">noch 26 Tage</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MitFusszeile: Story = {
|
||||||
|
name: 'Mit Fußzeile',
|
||||||
|
render: () => (
|
||||||
|
<div className="max-w-[420px]">
|
||||||
|
<Card aria-labelledby="h-dl" innerClassName="min-h-[220px]">
|
||||||
|
<CardHeader titleId="h-dl" title="Anstehende Deadlines" count={6} actions={more} />
|
||||||
|
<p className="m-0 text-fg-muted">Listeninhalt …</p>
|
||||||
|
<CardFooter>
|
||||||
|
<ButtonLink href="#" size="sm" className="h-[34px]" iconEnd={<ChevronRight size={14} strokeWidth={1.75} />}>
|
||||||
|
Zum Kalender
|
||||||
|
</ButtonLink>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import {
|
||||||
|
Card as UiCard,
|
||||||
|
CardAction,
|
||||||
|
CardDescription,
|
||||||
|
CardFooter as UiCardFooter,
|
||||||
|
CardHeader as UiCardHeader,
|
||||||
|
CardTitle,
|
||||||
|
} from '../ui/card';
|
||||||
|
import { CountBadge } from '../Badge/Badge';
|
||||||
|
|
||||||
|
export interface CardProps extends HTMLAttributes<HTMLElement> {
|
||||||
|
/** Element to render as; `section` for dashboard panels, `article` for group cards. */
|
||||||
|
as?: 'div' | 'section' | 'article' | 'form' | 'aside';
|
||||||
|
/** Inner padding. `none` lets rows run edge to edge (settings, task list). */
|
||||||
|
padding?: 'none' | 'sm' | 'md';
|
||||||
|
/** Classes for the inner surface. */
|
||||||
|
innerClassName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The design's signature double frame: a dark 5px rim around a raised surface.
|
||||||
|
* Use it for dashboard panels, settings sections, auth forms and group cards.
|
||||||
|
*/
|
||||||
|
export const Card = forwardRef<HTMLElement, CardProps>(function Card(
|
||||||
|
{ as: Tag = 'section', padding = 'md', className, innerClassName, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
ref={ref as never}
|
||||||
|
className={cn('flex min-w-0 rounded-[18px] border border-line-frame bg-frame p-[5px]', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<UiCard
|
||||||
|
className={cn(
|
||||||
|
padding === 'md' && 'gap-3.5 px-[22px] py-5',
|
||||||
|
padding === 'sm' && 'gap-4 px-[18px] pt-[18px] pb-4',
|
||||||
|
innerClassName,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</UiCard>
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface CardHeaderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {
|
||||||
|
title: ReactNode;
|
||||||
|
/** id for the heading, so the card can be `aria-labelledby` it. */
|
||||||
|
titleId?: string;
|
||||||
|
count?: ReactNode;
|
||||||
|
/** Secondary line under the title. */
|
||||||
|
subtitle?: ReactNode;
|
||||||
|
/** Right side: filters, "more" button, add button. */
|
||||||
|
actions?: ReactNode;
|
||||||
|
/** Heading level. */
|
||||||
|
level?: 2 | 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function CardHeader({ title, titleId, count, subtitle, actions, level = 2, ...props }: CardHeaderProps) {
|
||||||
|
const H = level === 2 ? 'h2' : 'h3';
|
||||||
|
return (
|
||||||
|
<UiCardHeader {...props}>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<CardTitle asChild>
|
||||||
|
<H id={titleId}>{title}</H>
|
||||||
|
</CardTitle>
|
||||||
|
{count !== undefined && <CountBadge>{count}</CountBadge>}
|
||||||
|
</div>
|
||||||
|
{subtitle && <CardDescription className="mt-1">{subtitle}</CardDescription>}
|
||||||
|
</div>
|
||||||
|
{actions && <CardAction>{actions}</CardAction>}
|
||||||
|
</UiCardHeader>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Footer row that pins its content to the bottom of a card. */
|
||||||
|
export const CardFooter = UiCardFooter;
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Checkbox, TaskCheckbox } from './Checkbox';
|
||||||
|
|
||||||
|
const meta: Meta<typeof TaskCheckbox> = {
|
||||||
|
title: 'Formulare/Checkbox',
|
||||||
|
component: TaskCheckbox,
|
||||||
|
args: { checked: false, taskTitle: 'ER-Diagramm finalisieren', loading: false },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof TaskCheckbox>;
|
||||||
|
|
||||||
|
export const Aufgabe: Story = {
|
||||||
|
render: function Render(args) {
|
||||||
|
const [checked, setChecked] = useState(args.checked);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
return (
|
||||||
|
<TaskCheckbox
|
||||||
|
{...args}
|
||||||
|
checked={checked}
|
||||||
|
loading={loading || args.loading}
|
||||||
|
onToggle={() => {
|
||||||
|
setLoading(true);
|
||||||
|
setTimeout(() => {
|
||||||
|
setChecked((c) => !c);
|
||||||
|
setLoading(false);
|
||||||
|
}, 900);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Zustaende: Story = {
|
||||||
|
name: 'Zustände',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<TaskCheckbox checked={false} taskTitle="Offen" />
|
||||||
|
<TaskCheckbox checked taskTitle="Erledigt" />
|
||||||
|
<TaskCheckbox checked={false} loading taskTitle="Lädt" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Formular: Story = {
|
||||||
|
render: () => <Checkbox label="Angemeldet bleiben" defaultChecked />,
|
||||||
|
};
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
||||||
|
import { Check } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Checkbox as UiCheckbox } from '../ui/checkbox';
|
||||||
|
import { Label } from '../ui/label';
|
||||||
|
import { Toggle } from '../ui/toggle';
|
||||||
|
import { Spinner } from '../Spinner/Spinner';
|
||||||
|
|
||||||
|
export interface CheckboxProps extends ComponentPropsWithoutRef<typeof UiCheckbox> {
|
||||||
|
label: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Plain form checkbox, e.g. "Angemeldet bleiben". Use `checked` / `onCheckedChange`. */
|
||||||
|
export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(function Checkbox(
|
||||||
|
{ label, className, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<Label className={cn('flex cursor-pointer items-center gap-2.5 text-fg-4', className)}>
|
||||||
|
<UiCheckbox ref={ref} {...props} />
|
||||||
|
{label}
|
||||||
|
</Label>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface TaskCheckboxProps {
|
||||||
|
checked: boolean;
|
||||||
|
onToggle?: () => void;
|
||||||
|
loading?: boolean;
|
||||||
|
/** Title of the task, used for the accessible label. */
|
||||||
|
taskTitle: string;
|
||||||
|
/** Hit area: 36px in the dashboard, 40px in the task list. */
|
||||||
|
size?: 36 | 40;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The rounded-square toggle that completes or reopens a task. */
|
||||||
|
export function TaskCheckbox({ checked, onToggle, loading, taskTitle, size = 36, className }: TaskCheckboxProps) {
|
||||||
|
return (
|
||||||
|
<Toggle
|
||||||
|
variant="bare"
|
||||||
|
pressed={checked}
|
||||||
|
onPressedChange={() => onToggle?.()}
|
||||||
|
aria-busy={loading || undefined}
|
||||||
|
aria-label={checked ? `${taskTitle} wieder öffnen` : `${taskTitle} als erledigt markieren`}
|
||||||
|
disabled={loading}
|
||||||
|
className={cn('group flex-none rounded-lg', size === 36 ? 'h-9 w-9' : 'h-10 w-10', className)}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'box-border flex h-5 w-5 items-center justify-center rounded-md border text-on-color shadow-bevel transition-colors',
|
||||||
|
loading
|
||||||
|
? 'border-accent bg-transparent'
|
||||||
|
: checked
|
||||||
|
? 'border-success bg-success'
|
||||||
|
: 'border-line-control bg-raised group-hover:border-line-hover',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{loading ? (
|
||||||
|
<Spinner size={14} className="text-accent" />
|
||||||
|
) : (
|
||||||
|
checked && <Check size={12} strokeWidth={3.5} aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</Toggle>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Clock, FileText, LogOut, Moon, Plus, Settings, SquareCheck, Users } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Stage, groups, tasks } from '../../stories/fixtures';
|
||||||
|
import { CommandPalette, SearchTrigger, type CommandSection } from './CommandPalette';
|
||||||
|
|
||||||
|
const meta: Meta<typeof CommandPalette> = {
|
||||||
|
title: 'Overlays/CommandPalette',
|
||||||
|
component: CommandPalette,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof CommandPalette>;
|
||||||
|
|
||||||
|
const i = { size: 16, strokeWidth: 1.75 } as const;
|
||||||
|
|
||||||
|
const taskItems = tasks.map((t) => ({ id: t.id, label: t.title, meta: `${t.group.name} · ${t.due}`, icon: <SquareCheck {...i} /> }));
|
||||||
|
const actions = [
|
||||||
|
{ id: 'a-new', label: 'Neue Aufgabe erstellen', meta: 'Aktion', icon: <Plus {...i} /> },
|
||||||
|
{ id: 'a-group', label: 'Gruppe erstellen', meta: 'Aktion', icon: <Users {...i} /> },
|
||||||
|
{ id: 'a-theme', label: 'Zu hellem Design wechseln', meta: 'Aktion', icon: <Moon {...i} /> },
|
||||||
|
{ id: 'a-logout', label: 'Abmelden', meta: 'Aktion', icon: <LogOut {...i} /> },
|
||||||
|
];
|
||||||
|
const pages = [
|
||||||
|
{ id: 'p-dash', label: 'Dashboard', meta: 'Seite', icon: <FileText {...i} /> },
|
||||||
|
{ id: 'p-tasks', label: 'Aufgaben', meta: 'Seite', icon: <FileText {...i} /> },
|
||||||
|
{ id: 'p-kanban', label: 'Kanban', meta: 'Seite', icon: <FileText {...i} /> },
|
||||||
|
{ id: 'p-cal', label: 'Kalender', meta: 'Seite', icon: <FileText {...i} /> },
|
||||||
|
{ id: 'p-acc', label: 'Einstellungen: Konto', meta: 'Seite', icon: <Settings {...i} /> },
|
||||||
|
{ id: 'p-gen', label: 'Einstellungen: Allgemein', meta: 'Seite', icon: <Settings {...i} /> },
|
||||||
|
];
|
||||||
|
|
||||||
|
const initial: CommandSection[] = [
|
||||||
|
{ title: 'Zuletzt geöffnet', items: taskItems.slice(0, 3).map((t) => ({ ...t, id: `r-${t.id}`, icon: <Clock {...i} /> })) },
|
||||||
|
{ title: 'Aktionen', items: actions },
|
||||||
|
{ title: 'Seiten', items: pages.slice(0, 5) },
|
||||||
|
];
|
||||||
|
const search: CommandSection[] = [
|
||||||
|
{ title: 'Aufgaben', items: taskItems },
|
||||||
|
{ title: 'Gruppen', items: groups.map((g) => ({ id: g.id, label: g.name, meta: `${g.members.length} Mitglieder`, color: g.color })) },
|
||||||
|
{ title: 'Seiten', items: pages },
|
||||||
|
{ title: 'Aktionen', items: actions },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const Suche: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [open, setOpen] = useState(true);
|
||||||
|
return (
|
||||||
|
<Stage height={680}>
|
||||||
|
<div className="p-6">
|
||||||
|
<SearchTrigger onClick={() => setOpen(true)} className="max-w-[520px]" />
|
||||||
|
</div>
|
||||||
|
<CommandPalette
|
||||||
|
open={open}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
sections={initial}
|
||||||
|
searchSections={search}
|
||||||
|
/>
|
||||||
|
</Stage>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Ausloeser: Story = {
|
||||||
|
name: 'Auslöser (⌘K)',
|
||||||
|
render: () => <SearchTrigger className="max-w-[520px]" />,
|
||||||
|
};
|
||||||
@@ -0,0 +1,167 @@
|
|||||||
|
import { useEffect, useMemo, useState, type ReactNode } from 'react';
|
||||||
|
import { CornerDownLeft, Search } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import {
|
||||||
|
CommandDialog,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem as CommandEntry,
|
||||||
|
CommandList,
|
||||||
|
} from '../ui/command';
|
||||||
|
import { DialogClose } from '../ui/dialog';
|
||||||
|
import { Kbd } from '../Badge/Badge';
|
||||||
|
|
||||||
|
export interface CommandItem {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
/** Right-aligned context, e.g. "SWE · Collabry · Mi, 4. Nov" or "Aktion". */
|
||||||
|
meta?: string;
|
||||||
|
/** Icon in the 30px tile. */
|
||||||
|
icon?: ReactNode;
|
||||||
|
/** Group color; renders a swatch instead of an icon. */
|
||||||
|
color?: string;
|
||||||
|
/** Extra words to match against. */
|
||||||
|
keywords?: string;
|
||||||
|
href?: string;
|
||||||
|
onSelect?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommandSection {
|
||||||
|
title: string;
|
||||||
|
items: CommandItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommandPaletteProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose?: () => void;
|
||||||
|
/** Sections shown while the query is empty, e.g. "Zuletzt geöffnet". */
|
||||||
|
sections: CommandSection[];
|
||||||
|
/** Sections searched when the user types. Defaults to `sections`. */
|
||||||
|
searchSections?: CommandSection[];
|
||||||
|
placeholder?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ⌘K search across tasks, groups, pages and actions, with keyboard navigation. */
|
||||||
|
export function CommandPalette({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
sections,
|
||||||
|
searchSections,
|
||||||
|
placeholder = 'Suche nach Aufgaben, Gruppen, Seiten …',
|
||||||
|
}: CommandPaletteProps) {
|
||||||
|
const [query, setQuery] = useState('');
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (open) setQuery('');
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
const visible = useMemo(() => {
|
||||||
|
const q = query.trim().toLowerCase();
|
||||||
|
if (!q) return sections.filter((s) => s.items.length > 0);
|
||||||
|
return (searchSections ?? sections)
|
||||||
|
.map((s) => ({
|
||||||
|
...s,
|
||||||
|
items: s.items.filter((it) => `${it.label} ${it.meta ?? ''} ${it.keywords ?? ''}`.toLowerCase().includes(q)),
|
||||||
|
}))
|
||||||
|
.filter((s) => s.items.length > 0);
|
||||||
|
}, [query, sections, searchSections]);
|
||||||
|
|
||||||
|
const run = (it: CommandItem) => {
|
||||||
|
it.onSelect?.();
|
||||||
|
if (it.href) window.location.assign(it.href);
|
||||||
|
onClose?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
// Filtering stays ours (empty query shows other sections); cmdk handles keyboard and selection.
|
||||||
|
<CommandDialog
|
||||||
|
open={open}
|
||||||
|
onOpenChange={(next) => !next && onClose?.()}
|
||||||
|
commandProps={{ shouldFilter: false, loop: true, label: 'Suche' }}
|
||||||
|
>
|
||||||
|
<CommandInput aria-label="Suche" placeholder={placeholder} value={query} onValueChange={setQuery}>
|
||||||
|
<DialogClose aria-label="Schließen" className="h-[26px] flex-none rounded-md border border-line-strong bg-elevated px-[7px] text-2xs font-bold text-fg-muted">
|
||||||
|
Esc
|
||||||
|
</DialogClose>
|
||||||
|
</CommandInput>
|
||||||
|
<CommandList aria-label="Ergebnisse">
|
||||||
|
{visible.map((sec) => (
|
||||||
|
<CommandGroup key={sec.title} heading={sec.title}>
|
||||||
|
{sec.items.map((it) => (
|
||||||
|
<CommandEntry key={it.id} value={`${sec.title}-${it.id}`} onSelect={() => run(it)}>
|
||||||
|
<span className="box-border flex h-[30px] w-[30px] flex-none items-center justify-center rounded-lg border border-line-strong bg-elevated text-fg-muted">
|
||||||
|
{it.color ? <span className="h-2.5 w-2.5 rounded-[3px]" style={{ background: it.color }} /> : it.icon}
|
||||||
|
</span>
|
||||||
|
<span className="min-w-0 flex-auto truncate text-fg">{it.label}</span>
|
||||||
|
<span className="flex flex-none items-center gap-1.5 text-xs text-fg-subtle">
|
||||||
|
{it.meta}
|
||||||
|
<CornerDownLeft
|
||||||
|
size={14}
|
||||||
|
strokeWidth={1.75}
|
||||||
|
aria-hidden="true"
|
||||||
|
className="hidden text-fg-muted group-data-[selected=true]/item:block"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</CommandEntry>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
))}
|
||||||
|
<CommandEmpty>
|
||||||
|
<div className="font-bold text-fg">Keine Ergebnisse</div>
|
||||||
|
<div className="mt-1 text-sm">Nichts gefunden für „{query}“.</div>
|
||||||
|
</CommandEmpty>
|
||||||
|
</CommandList>
|
||||||
|
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-line-divider px-4 py-2.5 text-xs text-fg-subtle">
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<Kbd size="sm">↑</Kbd>
|
||||||
|
<Kbd size="sm">↓</Kbd>
|
||||||
|
Navigieren
|
||||||
|
</span>
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<Kbd size="sm">↵</Kbd>
|
||||||
|
Öffnen
|
||||||
|
</span>
|
||||||
|
<span className="flex items-center gap-1.5">
|
||||||
|
<Kbd size="sm">Esc</Kbd>
|
||||||
|
Schließen
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</CommandDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchTriggerProps {
|
||||||
|
onClick?: () => void;
|
||||||
|
placeholder?: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Fake search field that opens the command palette; shows the ⌘K hint. */
|
||||||
|
export function SearchTrigger({ onClick, placeholder = 'Aufgaben oder Gruppen suchen', className }: SearchTriggerProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn('box-border min-w-0 rounded-[14px] border border-line-frame bg-frame p-1', className)}>
|
||||||
|
<span className="relative flex items-center">
|
||||||
|
<Search
|
||||||
|
size={16}
|
||||||
|
strokeWidth={1.75}
|
||||||
|
aria-hidden="true"
|
||||||
|
className="pointer-events-none absolute left-3 text-fg-subtle"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClick}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
aria-label="Suche öffnen (⌘K)"
|
||||||
|
className="box-border block h-[38px] w-full cursor-text rounded-[10px] border border-line bg-surface pr-[76px] pl-[38px] text-left text-fg-subtle outline-none hover:border-line-hover focus-visible:shadow-focus"
|
||||||
|
>
|
||||||
|
{placeholder}
|
||||||
|
</button>
|
||||||
|
<span aria-hidden="true" className="pointer-events-none absolute right-2 flex gap-1">
|
||||||
|
<Kbd>⌘</Kbd>
|
||||||
|
<Kbd>K</Kbd>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
import { useId, type KeyboardEvent } from 'react';
|
||||||
|
import { SendHorizontal } from 'lucide-react';
|
||||||
|
import { Avatar, type Person } from '../Avatar/Avatar';
|
||||||
|
import { Button, type ButtonState } from '../Button/Button';
|
||||||
|
import { Textarea } from '../Field/Field';
|
||||||
|
|
||||||
|
export interface CommentData {
|
||||||
|
id: string;
|
||||||
|
author: Person;
|
||||||
|
/** e.g. "vor 2 Std." */
|
||||||
|
when: string;
|
||||||
|
text: string;
|
||||||
|
mine?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommentItemProps {
|
||||||
|
comment: CommentData;
|
||||||
|
onDelete?: (id: string) => void;
|
||||||
|
deleteState?: ButtonState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chat-style comment with avatar, name, time and a bubble. */
|
||||||
|
export function CommentItem({ comment: c, onDelete, deleteState }: CommentItemProps) {
|
||||||
|
return (
|
||||||
|
<li className="flex list-none gap-2.5">
|
||||||
|
<Avatar person={c.author} size={30} aria-hidden="true" />
|
||||||
|
<div className="min-w-0 flex-auto">
|
||||||
|
<div className="flex items-baseline gap-2">
|
||||||
|
<span className="text-sm font-bold">{c.author.name}</span>
|
||||||
|
<span className="text-xs text-fg-subtle">{c.when}</span>
|
||||||
|
{c.mine && onDelete && (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="xs"
|
||||||
|
className="ml-auto h-6 px-1.5 text-xs text-fg-subtle"
|
||||||
|
aria-label="Kommentar löschen"
|
||||||
|
state={deleteState}
|
||||||
|
onClick={() => onDelete(c.id)}
|
||||||
|
>
|
||||||
|
Löschen
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="mt-1 rounded-[4px_12px_12px_12px] bg-soft px-3 py-[9px] text-base leading-normal [overflow-wrap:anywhere] whitespace-pre-wrap text-fg-2">
|
||||||
|
{c.text}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CommentComposerProps {
|
||||||
|
me: Person;
|
||||||
|
value: string;
|
||||||
|
onChange?: (value: string) => void;
|
||||||
|
onSend?: () => void;
|
||||||
|
sendState?: ButtonState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Comment input with ⌘ + Enter to send. */
|
||||||
|
export function CommentComposer({ me, value, onChange, onSend, sendState }: CommentComposerProps) {
|
||||||
|
const id = useId();
|
||||||
|
const empty = value.trim() === '';
|
||||||
|
const onKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
|
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey) && !empty) {
|
||||||
|
e.preventDefault();
|
||||||
|
onSend?.();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex items-end gap-2.5">
|
||||||
|
<Avatar person={me} size={30} className="mb-1" aria-hidden="true" />
|
||||||
|
<label htmlFor={id} className="sr-only">
|
||||||
|
Kommentar schreiben
|
||||||
|
</label>
|
||||||
|
<Textarea
|
||||||
|
id={id}
|
||||||
|
rows={2}
|
||||||
|
placeholder="Kommentar schreiben …"
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => onChange?.(e.target.value)}
|
||||||
|
onKeyDown={onKeyDown}
|
||||||
|
className="min-w-0 flex-auto resize-none py-[9px]"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="md"
|
||||||
|
iconOnly
|
||||||
|
aria-label="Kommentar senden"
|
||||||
|
className={empty ? 'h-[38px] w-[38px] opacity-50' : 'h-[38px] w-[38px]'}
|
||||||
|
aria-disabled={empty}
|
||||||
|
state={sendState}
|
||||||
|
onClick={() => !empty && onSend?.()}
|
||||||
|
>
|
||||||
|
<SendHorizontal size={16} strokeWidth={2} />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div className="mt-1.5 pl-10 text-2xs text-fg-subtle">Mit ⌘ + Enter senden</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,216 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Trash2 } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Stage, me, people, tasks } from '../../stories/fixtures';
|
||||||
|
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';
|
||||||
|
|
||||||
|
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' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const NeueAufgabe: Story = {
|
||||||
|
name: 'Neue Aufgabe',
|
||||||
|
render: function Render() {
|
||||||
|
const [open, setOpen] = useState(true);
|
||||||
|
const [prio, setPrio] = useState('Mittel');
|
||||||
|
const [title, setTitle] = useState('');
|
||||||
|
const [tried, setTried] = useState(false);
|
||||||
|
const [state, setState] = useState<ButtonState>('idle');
|
||||||
|
const submit = () => {
|
||||||
|
setTried(true);
|
||||||
|
if (!title.trim()) return;
|
||||||
|
setState('loading');
|
||||||
|
setTimeout(() => setState('success'), 900);
|
||||||
|
setTimeout(() => {
|
||||||
|
setState('idle');
|
||||||
|
setOpen(false);
|
||||||
|
}, 1600);
|
||||||
|
};
|
||||||
|
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>
|
||||||
|
<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>
|
||||||
|
</Dialog>
|
||||||
|
</Stage>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Bestaetigung: Story = {
|
||||||
|
name: 'Bestätigung',
|
||||||
|
render: function Render() {
|
||||||
|
const [open, setOpen] = useState(true);
|
||||||
|
return (
|
||||||
|
<Stage height={360}>
|
||||||
|
<div className="p-6">
|
||||||
|
<Button variant="danger-outline" onClick={() => setOpen(true)}>
|
||||||
|
Aufgabe löschen
|
||||||
|
</Button>
|
||||||
|
</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>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Aufgabendetails: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [open, setOpen] = useState(true);
|
||||||
|
const [draft, setDraft] = useState('');
|
||||||
|
const [prio, setPrio] = useState('Hoch');
|
||||||
|
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>
|
||||||
|
</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>
|
||||||
|
</Drawer>
|
||||||
|
</Stage>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { X } from 'lucide-react';
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
} from '../ui/alert-dialog';
|
||||||
|
import {
|
||||||
|
Dialog as UiDialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogTitle,
|
||||||
|
} from '../ui/dialog';
|
||||||
|
import { Sheet, SheetClose, SheetContent, SheetFooter, SheetHeader, SheetTitle } from '../ui/sheet';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
|
||||||
|
/** Focus the first form field when a dialog opens (instead of the close button); Radix returns focus on close. */
|
||||||
|
function focusFirstField(e: Event) {
|
||||||
|
const field = (e.currentTarget as HTMLElement).querySelector<HTMLElement>('[autofocus], input, textarea, select');
|
||||||
|
if (!field) return;
|
||||||
|
e.preventDefault();
|
||||||
|
field.focus({ preventScroll: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Radix warns about a missing description unless `aria-describedby` is explicitly unset. */
|
||||||
|
const noDescription = (description: ReactNode) => (description ? {} : { 'aria-describedby': undefined });
|
||||||
|
|
||||||
|
const closeButton = (
|
||||||
|
<Button variant="ghost" size="sm" iconOnly aria-label="Schließen" className="text-fg-subtle">
|
||||||
|
<X size={16} strokeWidth={1.75} />
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
|
||||||
|
export interface DialogProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose?: () => void;
|
||||||
|
title: ReactNode;
|
||||||
|
description?: ReactNode;
|
||||||
|
children?: ReactNode;
|
||||||
|
/** Footer actions, right-aligned. */
|
||||||
|
footer?: ReactNode;
|
||||||
|
/** Panel width in px. */
|
||||||
|
width?: number;
|
||||||
|
/** `alert` is a confirmation without a close button (role="alertdialog"); it ignores clicks on the backdrop. */
|
||||||
|
kind?: 'dialog' | 'alert';
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Centered modal panel, e.g. "Neue Aufgabe" or "Aufgabe löschen?". */
|
||||||
|
export function Dialog({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
children,
|
||||||
|
footer,
|
||||||
|
width = 560,
|
||||||
|
kind = 'dialog',
|
||||||
|
className,
|
||||||
|
}: DialogProps) {
|
||||||
|
const onOpenChange = (next: boolean) => !next && onClose?.();
|
||||||
|
const body = children && <div className="flex flex-col gap-4 px-[22px] pt-4 pb-5">{children}</div>;
|
||||||
|
|
||||||
|
if (kind === 'alert') {
|
||||||
|
return (
|
||||||
|
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<AlertDialogContent className={className} style={{ width }} {...noDescription(description)}>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
||||||
|
{description && <AlertDialogDescription>{description}</AlertDialogDescription>}
|
||||||
|
</AlertDialogHeader>
|
||||||
|
{body}
|
||||||
|
{footer && <AlertDialogFooter>{footer}</AlertDialogFooter>}
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<UiDialog open={open} onOpenChange={onOpenChange}>
|
||||||
|
<DialogContent
|
||||||
|
showCloseButton={false}
|
||||||
|
onOpenAutoFocus={focusFirstField}
|
||||||
|
className={className}
|
||||||
|
style={{ width }}
|
||||||
|
{...noDescription(description)}
|
||||||
|
>
|
||||||
|
<div className="flex items-start gap-3 pt-5 pr-4 pb-1 pl-[22px]">
|
||||||
|
<div className="flex-auto">
|
||||||
|
<DialogTitle>{title}</DialogTitle>
|
||||||
|
{description && <DialogDescription className="mt-1">{description}</DialogDescription>}
|
||||||
|
</div>
|
||||||
|
<DialogClose asChild>{closeButton}</DialogClose>
|
||||||
|
</div>
|
||||||
|
{body}
|
||||||
|
{footer && <DialogFooter>{footer}</DialogFooter>}
|
||||||
|
</DialogContent>
|
||||||
|
</UiDialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DrawerProps {
|
||||||
|
open: boolean;
|
||||||
|
onClose?: () => void;
|
||||||
|
/** Accessible name of the drawer. */
|
||||||
|
label: string;
|
||||||
|
/** Header content left of the actions, e.g. the group of a task. */
|
||||||
|
header?: ReactNode;
|
||||||
|
/** Extra header buttons before the close button. */
|
||||||
|
actions?: ReactNode;
|
||||||
|
children: ReactNode;
|
||||||
|
/** Sticky footer, e.g. a comment composer. */
|
||||||
|
footer?: ReactNode;
|
||||||
|
width?: number;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Side sheet that slides in from the right, e.g. task details. */
|
||||||
|
export function Drawer({ open, onClose, label, header, actions, children, footer, width = 460, className }: DrawerProps) {
|
||||||
|
return (
|
||||||
|
<Sheet open={open} onOpenChange={(next) => !next && onClose?.()}>
|
||||||
|
<SheetContent
|
||||||
|
showCloseButton={false}
|
||||||
|
onOpenAutoFocus={focusFirstField}
|
||||||
|
aria-describedby={undefined}
|
||||||
|
className={className}
|
||||||
|
style={{ width }}
|
||||||
|
>
|
||||||
|
<SheetTitle className="sr-only">{label}</SheetTitle>
|
||||||
|
<SheetHeader>
|
||||||
|
<div className="min-w-0 flex-auto">{header}</div>
|
||||||
|
<div className="ml-auto flex gap-0.5">
|
||||||
|
{actions}
|
||||||
|
<SheetClose asChild>{closeButton}</SheetClose>
|
||||||
|
</div>
|
||||||
|
</SheetHeader>
|
||||||
|
<div className="flex flex-auto flex-col gap-[18px] overflow-y-auto px-5 pt-[18px] pb-6">{children}</div>
|
||||||
|
{footer && <SheetFooter>{footer}</SheetFooter>}
|
||||||
|
</SheetContent>
|
||||||
|
</Sheet>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Search } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Field, Input, PasswordInput, Select, Textarea } from './Field';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Input> = {
|
||||||
|
title: 'Formulare/Felder',
|
||||||
|
component: Input,
|
||||||
|
args: { placeholder: 'du@beispiel.at', size: 'lg' },
|
||||||
|
argTypes: { size: { control: 'inline-radio', options: ['md', 'lg'] } },
|
||||||
|
decorators: [(Story) => <div className="max-w-[400px]">{Story()}</div>],
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Input>;
|
||||||
|
|
||||||
|
export const Eingabe: Story = {};
|
||||||
|
|
||||||
|
export const MitLabel: Story = {
|
||||||
|
name: 'Mit Label & Fehler',
|
||||||
|
render: function Render() {
|
||||||
|
const [email, setEmail] = useState('niklas@');
|
||||||
|
const invalid = !/^\S+@\S+\.\S+$/.test(email);
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-[18px]">
|
||||||
|
<Field label="E-Mail" error={invalid ? 'Bitte gib eine gültige E-Mail-Adresse ein.' : undefined}>
|
||||||
|
{({ id, describedBy, invalid: inv }) => (
|
||||||
|
<Input
|
||||||
|
id={id}
|
||||||
|
size="lg"
|
||||||
|
type="text"
|
||||||
|
autoComplete="email"
|
||||||
|
placeholder="du@beispiel.at"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
|
invalid={inv}
|
||||||
|
aria-describedby={describedBy}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<Field label="Passwort" labelAside={<a href="#">Passwort vergessen?</a>}>
|
||||||
|
{({ id }) => <PasswordInput id={id} size="lg" autoComplete="current-password" defaultValue="geheim123" />}
|
||||||
|
</Field>
|
||||||
|
<Field label="E-Mail" hint="Wird für die Anmeldung und Benachrichtigungen verwendet.">
|
||||||
|
{({ id, describedBy }) => <Input id={id} defaultValue="niklas@beispiel.at" aria-describedby={describedBy} />}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Suche: Story = {
|
||||||
|
render: () => <Input placeholder="Filtern …" leadingIcon={<Search size={16} strokeWidth={1.75} />} aria-label="Aufgaben filtern" />,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Auswahl: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-col gap-4">
|
||||||
|
<Select
|
||||||
|
aria-label="Gruppe"
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'Alle Gruppen' },
|
||||||
|
{ value: 'swe', label: 'SWE · Collabry' },
|
||||||
|
{ value: 'db', label: 'Datenbanken Übung' },
|
||||||
|
{ value: 'mk', label: 'Marketing Seminar' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
aria-label="Sprache"
|
||||||
|
size="settings"
|
||||||
|
className="w-[220px]"
|
||||||
|
options={[
|
||||||
|
{ value: 'de', label: 'Deutsch' },
|
||||||
|
{ value: 'en', label: 'English' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Textfeld: Story = {
|
||||||
|
render: () => (
|
||||||
|
<Field label="Beschreibung" labelNote="(optional)">
|
||||||
|
{({ id }) => <Textarea id={id} rows={4} placeholder="Details, Links oder Akzeptanzkriterien …" />}
|
||||||
|
</Field>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Datum: Story = {
|
||||||
|
render: () => (
|
||||||
|
<Field label="Fällig am">
|
||||||
|
{({ id }) => <Input id={id} type="date" defaultValue="2026-11-04" />}
|
||||||
|
</Field>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
import {
|
||||||
|
forwardRef,
|
||||||
|
useId,
|
||||||
|
useState,
|
||||||
|
type InputHTMLAttributes,
|
||||||
|
type ReactNode,
|
||||||
|
type SelectHTMLAttributes,
|
||||||
|
type TextareaHTMLAttributes,
|
||||||
|
} from 'react';
|
||||||
|
import { AlertCircle, Eye, EyeOff } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Input as UiInput } from '../ui/input';
|
||||||
|
import { Label } from '../ui/label';
|
||||||
|
import { NativeSelect, NativeSelectOption } from '../ui/native-select';
|
||||||
|
import { Textarea as UiTextarea } from '../ui/textarea';
|
||||||
|
|
||||||
|
export type FieldSize = 'md' | 'lg';
|
||||||
|
const heights: Record<FieldSize, string> = { md: 'h-[38px]', lg: 'h-[42px]' };
|
||||||
|
|
||||||
|
export interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> {
|
||||||
|
invalid?: boolean;
|
||||||
|
/** 38px (filters, dialogs) or 42px (auth forms). */
|
||||||
|
size?: FieldSize;
|
||||||
|
/** Icon inside the field on the left, e.g. a search glass. */
|
||||||
|
leadingIcon?: ReactNode;
|
||||||
|
/** Element inside the field on the right, e.g. a reveal button. */
|
||||||
|
trailing?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
||||||
|
{ invalid, size = 'md', leadingIcon, trailing, className, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
const input = (
|
||||||
|
<UiInput
|
||||||
|
ref={ref}
|
||||||
|
aria-invalid={invalid || undefined}
|
||||||
|
className={cn(
|
||||||
|
heights[size],
|
||||||
|
leadingIcon && 'pl-[34px]',
|
||||||
|
trailing && 'pr-12',
|
||||||
|
!leadingIcon && !trailing && className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
if (!leadingIcon && !trailing) return input;
|
||||||
|
return (
|
||||||
|
<span className={cn('relative flex items-center', className)}>
|
||||||
|
{leadingIcon && (
|
||||||
|
<span className="pointer-events-none absolute left-[11px] flex text-fg-subtle">{leadingIcon}</span>
|
||||||
|
)}
|
||||||
|
{input}
|
||||||
|
{trailing && <span className="absolute right-[5px] flex">{trailing}</span>}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const PasswordInput = forwardRef<HTMLInputElement, Omit<InputProps, 'type' | 'trailing'>>(
|
||||||
|
function PasswordInput(props, ref) {
|
||||||
|
const [visible, setVisible] = useState(false);
|
||||||
|
const label = visible ? 'Passwort verbergen' : 'Passwort anzeigen';
|
||||||
|
return (
|
||||||
|
<Input
|
||||||
|
ref={ref}
|
||||||
|
type={visible ? 'text' : 'password'}
|
||||||
|
trailing={
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => 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 ? <EyeOff size={18} strokeWidth={1.75} /> : <Eye size={18} strokeWidth={1.75} />}
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
|
||||||
|
invalid?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(function Textarea(
|
||||||
|
{ invalid, rows = 3, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return <UiTextarea ref={ref} rows={rows} aria-invalid={invalid || undefined} {...props} />;
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface SelectOption {
|
||||||
|
value: string;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SelectProps extends Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> {
|
||||||
|
options: SelectOption[];
|
||||||
|
invalid?: boolean;
|
||||||
|
size?: FieldSize | 'settings';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Native select with the design's chevron. */
|
||||||
|
export const Select = forwardRef<HTMLSelectElement, SelectProps>(function Select(
|
||||||
|
{ options, invalid, size = 'md', ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<NativeSelect ref={ref} size={size} aria-invalid={invalid || undefined} {...props}>
|
||||||
|
{options.map((o) => (
|
||||||
|
<NativeSelectOption key={o.value} value={o.value}>
|
||||||
|
{o.label}
|
||||||
|
</NativeSelectOption>
|
||||||
|
))}
|
||||||
|
</NativeSelect>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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 (
|
||||||
|
<div className={cn('flex min-w-0 flex-col gap-1.5', className)}>
|
||||||
|
<div className="flex items-baseline justify-between gap-3">
|
||||||
|
<Label htmlFor={id} className="text-sm font-bold">
|
||||||
|
{label}
|
||||||
|
{labelNote && <span className="font-normal text-fg-subtle"> {labelNote}</span>}
|
||||||
|
</Label>
|
||||||
|
{labelAside && <span className="text-sm">{labelAside}</span>}
|
||||||
|
</div>
|
||||||
|
{children({ id, describedBy: hasMsg ? msgId : undefined, invalid: Boolean(error) })}
|
||||||
|
{error ? (
|
||||||
|
<FieldError id={msgId}>{error}</FieldError>
|
||||||
|
) : hint ? (
|
||||||
|
<div id={msgId} className="text-xs text-fg-subtle">
|
||||||
|
{hint}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function FieldError({ id, children }: { id?: string; children: ReactNode }) {
|
||||||
|
return (
|
||||||
|
<div id={id} className="flex items-center gap-1.5 text-xs text-danger-fg">
|
||||||
|
<AlertCircle size={14} strokeWidth={1.75} aria-hidden="true" className="flex-none" />
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { LogOut, Pencil, Plus, SquareArrowOutUpRight, Users } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { groups, people } from '../../stories/fixtures';
|
||||||
|
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';
|
||||||
|
|
||||||
|
const meta: Meta<typeof GroupCard> = {
|
||||||
|
title: 'Gruppen/Gruppen',
|
||||||
|
component: GroupCard,
|
||||||
|
args: { group: groups[0] },
|
||||||
|
argTypes: { group: { control: false }, menu: { control: false } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof GroupCard>;
|
||||||
|
|
||||||
|
const i = { size: 16, strokeWidth: 1.75 } as const;
|
||||||
|
|
||||||
|
const groupMenu = (
|
||||||
|
<>
|
||||||
|
<MenuLink href="#" icon={<SquareArrowOutUpRight {...i} />}>
|
||||||
|
Gruppe öffnen
|
||||||
|
</MenuLink>
|
||||||
|
<MenuItem icon={<Pencil {...i} />}>Bearbeiten</MenuItem>
|
||||||
|
<MenuLink href="#" icon={<Users {...i} />}>
|
||||||
|
Mitglieder verwalten
|
||||||
|
</MenuLink>
|
||||||
|
<MenuSeparator />
|
||||||
|
<MenuItem danger icon={<LogOut {...i} />}>
|
||||||
|
Gruppe verlassen
|
||||||
|
</MenuItem>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Karte: Story = {
|
||||||
|
args: { menu: groupMenu },
|
||||||
|
render: (args) => (
|
||||||
|
<div className="max-w-[380px]">
|
||||||
|
<GroupCard {...args} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Uebersicht: Story = {
|
||||||
|
name: 'Übersicht',
|
||||||
|
render: () => (
|
||||||
|
<div className="grid grid-cols-[repeat(auto-fill,minmax(min(320px,100%),1fr))] items-stretch gap-5">
|
||||||
|
{groups.map((g) => (
|
||||||
|
<GroupCard key={g.id} group={g} menu={groupMenu} />
|
||||||
|
))}
|
||||||
|
<NewGroupTile />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Dashboardliste: Story = {
|
||||||
|
name: 'Dashboard: Meine Gruppen',
|
||||||
|
render: () => (
|
||||||
|
<Card aria-labelledby="h-groups" innerClassName="gap-2">
|
||||||
|
<CardHeader
|
||||||
|
titleId="h-groups"
|
||||||
|
title="Meine Gruppen"
|
||||||
|
count={groups.length}
|
||||||
|
actions={
|
||||||
|
<Button variant="ghost" size="xs" iconOnly aria-label="Gruppe erstellen" className="text-fg-subtle">
|
||||||
|
<Plus size={16} strokeWidth={2} />
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<ul className="m-0 grid grid-cols-[repeat(auto-fit,minmax(min(280px,100%),1fr))] gap-x-10 p-0">
|
||||||
|
{groups.map((g) => (
|
||||||
|
<GroupRow key={g.id} group={g} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</Card>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Einladung: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [state, setState] = useState<ButtonState>('idle');
|
||||||
|
return (
|
||||||
|
<InviteBanner
|
||||||
|
from={people.KB}
|
||||||
|
groupName="Statistik Projekt"
|
||||||
|
acceptState={state}
|
||||||
|
onAccept={() => {
|
||||||
|
setState('loading');
|
||||||
|
setTimeout(() => setState('success'), 900);
|
||||||
|
setTimeout(() => setState('idle'), 1700);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
export interface GroupData {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
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<GroupData, 'done' | 'total'>) => (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);
|
||||||
|
return (
|
||||||
|
<li className="list-none">
|
||||||
|
<a href={href} className="-mx-2.5 block rounded-lg px-2.5 py-4 text-fg hover:bg-hover-row hover:text-fg">
|
||||||
|
<div className="flex items-center gap-2.5">
|
||||||
|
<span className="h-2.5 w-2.5 flex-none rounded-[3px]" style={{ background: g.color }} />
|
||||||
|
<span className="min-w-0 flex-auto truncate font-bold">{g.name}</span>
|
||||||
|
<AvatarStack people={g.members} size={22} />
|
||||||
|
<ChevronRight size={16} strokeWidth={1.75} aria-hidden="true" className="text-fg-faint" />
|
||||||
|
</div>
|
||||||
|
<div className="mt-3 flex items-center gap-3 pl-5">
|
||||||
|
<ProgressBar value={p} color={g.color} label={`${g.name}: ${p} % erledigt`} className="flex-auto" />
|
||||||
|
<div className="w-[84px] flex-none text-right text-xs text-fg-muted tabular-nums">
|
||||||
|
<strong className="text-fg">{p}%</strong> · {g.done}/{g.total}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface GroupCardProps {
|
||||||
|
group: GroupData;
|
||||||
|
href?: string;
|
||||||
|
/** Items of the "…" menu at the top right (`MenuItem`, `MenuLink`, `MenuSeparator`). */
|
||||||
|
menu?: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Group overview card on the Gruppen page. */
|
||||||
|
export function GroupCard({ group: g, href = '#', menu }: GroupCardProps) {
|
||||||
|
const p = pct(g);
|
||||||
|
const headingId = `gc-${g.id}`;
|
||||||
|
return (
|
||||||
|
<Card as="article" aria-labelledby={headingId} padding="sm">
|
||||||
|
<div className="flex items-start gap-3">
|
||||||
|
<span
|
||||||
|
className="box-border flex h-10 w-10 flex-none items-center justify-center rounded-[11px] border"
|
||||||
|
style={{
|
||||||
|
borderColor: `color-mix(in srgb, ${g.color} 45%, transparent)`,
|
||||||
|
background: `color-mix(in srgb, ${g.color} 18%, transparent)`,
|
||||||
|
color: g.color,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Users size={18} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
<div className="min-w-0 flex-auto">
|
||||||
|
<h2 id={headingId} className="m-0 truncate text-[16px] leading-tight font-bold">
|
||||||
|
<a href={href} className="text-inherit hover:text-inherit">
|
||||||
|
{g.name}
|
||||||
|
</a>
|
||||||
|
</h2>
|
||||||
|
<RoleBadge role={g.role} className="mt-[5px]" />
|
||||||
|
</div>
|
||||||
|
{menu && (
|
||||||
|
<Menu
|
||||||
|
label={`Aktionen für ${g.name}`}
|
||||||
|
trigger={
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
iconOnly
|
||||||
|
aria-label={`Aktionen für ${g.name}`}
|
||||||
|
className="text-fg-subtle data-[state=open]:bg-hover"
|
||||||
|
>
|
||||||
|
<MoreHorizontal size={16} strokeWidth={2.5} />
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{menu}
|
||||||
|
</Menu>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{g.description !== undefined && (
|
||||||
|
<p className="m-0 min-h-[39px] text-sm leading-normal text-fg-muted">{g.description}</p>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<div className="flex items-baseline justify-between gap-2 text-xs text-fg-subtle">
|
||||||
|
<span>Fortschritt</span>
|
||||||
|
<span>
|
||||||
|
<strong className="text-sm text-fg">{p}%</strong> · {g.done}/{g.total} Aufgaben
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<ProgressBar value={p} color={g.color} label={`${p} % erledigt`} className="mt-2" />
|
||||||
|
</div>
|
||||||
|
<div className="mt-auto flex items-center justify-between gap-3 border-t border-line-subtle pt-3.5">
|
||||||
|
<span className="flex items-center gap-2 text-xs text-fg-subtle">
|
||||||
|
<AvatarStack people={g.members} size={26} max={4} />
|
||||||
|
{g.members.length} Mitglieder
|
||||||
|
</span>
|
||||||
|
{g.next && (
|
||||||
|
<span className="flex min-w-0 items-center gap-1.5 text-xs text-fg-subtle">
|
||||||
|
<CalendarClock size={14} strokeWidth={1.75} aria-hidden="true" className="flex-none" />
|
||||||
|
<span className="truncate">{g.next}</span>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewGroupTileProps {
|
||||||
|
onClick?: () => void;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClick}
|
||||||
|
className="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"
|
||||||
|
>
|
||||||
|
<span className="flex h-11 w-11 items-center justify-center rounded-xl border border-line-strong bg-surface text-fg">
|
||||||
|
<Plus size={20} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
</span>
|
||||||
|
<span className="font-bold text-fg">{title}</span>
|
||||||
|
<span className="max-w-[240px] text-sm leading-normal">{description}</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
return (
|
||||||
|
<Card as="div" padding="none" innerClassName="flex-row flex-wrap items-center gap-3.5 px-4 py-3.5">
|
||||||
|
<Avatar person={from} size={36} aria-hidden="true" />
|
||||||
|
<div className="min-w-0 flex-[1_1_280px] text-base text-fg-muted">
|
||||||
|
<strong className="text-fg">{from.name}</strong> hat dich in die Gruppe <strong className="text-fg">„{groupName}“</strong>{' '}
|
||||||
|
eingeladen.
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button variant="secondary" onClick={onDecline} state={declineState} disabled={busy}>
|
||||||
|
Ablehnen
|
||||||
|
</Button>
|
||||||
|
<Button variant="primary" onClick={onAccept} state={acceptState} disabled={busy}>
|
||||||
|
Beitreten
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Plus, SquareCheck } from 'lucide-react';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
import { EmptyState, PageHeader } from './Layout';
|
||||||
|
|
||||||
|
const meta: Meta<typeof PageHeader> = {
|
||||||
|
title: 'Grundlagen/Seitenkopf',
|
||||||
|
component: PageHeader,
|
||||||
|
args: {
|
||||||
|
title: 'Aufgaben',
|
||||||
|
description: '7 Aufgaben in 3 Gruppen · 1 überfällig',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof PageHeader>;
|
||||||
|
|
||||||
|
export const MitAktion: Story = {
|
||||||
|
name: 'Mit Aktion',
|
||||||
|
args: {
|
||||||
|
actions: (
|
||||||
|
<Button variant="primary" size="lg" className="text-sm" icon={<Plus size={16} strokeWidth={2.25} />}>
|
||||||
|
Neue Aufgabe
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
render: () => (
|
||||||
|
<EmptyState
|
||||||
|
icon={<SquareCheck size={28} strokeWidth={1.75} />}
|
||||||
|
title="Keine Aufgaben gefunden"
|
||||||
|
description="Passe die Filter an oder lege eine neue Aufgabe an."
|
||||||
|
action={<Button variant="ghost" size="sm">Filter zurücksetzen</Button>}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import type { HTMLAttributes, ReactNode } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
|
||||||
|
export interface PageHeaderProps extends Omit<HTMLAttributes<HTMLElement>, '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) {
|
||||||
|
return (
|
||||||
|
<header className={cn('flex flex-wrap items-end justify-between gap-x-6 gap-y-3', className)} {...props}>
|
||||||
|
<div>
|
||||||
|
{eyebrow && <div className="text-sm font-bold text-fg-subtle">{eyebrow}</div>}
|
||||||
|
<h1 className={cn('m-0 text-display font-black tracking-[-0.01em]', eyebrow && 'mt-1')}>{title}</h1>
|
||||||
|
{description && <p className="mt-1.5 mb-0 text-fg-muted">{description}</p>}
|
||||||
|
</div>
|
||||||
|
{actions && <div className="flex items-center gap-2.5">{actions}</div>}
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface EmptyStateProps {
|
||||||
|
icon?: ReactNode;
|
||||||
|
title: ReactNode;
|
||||||
|
description?: ReactNode;
|
||||||
|
action?: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Centered placeholder for empty lists and searches. */
|
||||||
|
export function EmptyState({ icon, title, description, action, className }: EmptyStateProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn('flex flex-col items-center gap-2 px-4 py-12 text-center text-fg-subtle', className)}>
|
||||||
|
{icon && <span className="flex text-fg-faint">{icon}</span>}
|
||||||
|
<div className="font-bold text-fg">{title}</div>
|
||||||
|
{description && <div className="text-sm">{description}</div>}
|
||||||
|
{action && <div className="mt-1.5">{action}</div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Small section label inside lists ("Heute", "Früher"). */
|
||||||
|
export function SectionLabel({ className, ...props }: HTMLAttributes<HTMLDivElement>) {
|
||||||
|
return <div className={cn('px-2.5 pt-2.5 pb-1.5 text-xs font-bold text-fg-subtle', className)} {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import type { ImgHTMLAttributes } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import wordmark from '../../assets/logo-wordmark.svg';
|
||||||
|
import mark from '../../assets/logo-mark.svg';
|
||||||
|
import stacked from '../../assets/logo-stacked.svg';
|
||||||
|
|
||||||
|
const sources = { wordmark, mark, stacked };
|
||||||
|
|
||||||
|
export interface LogoProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 'src'> {
|
||||||
|
/** `wordmark` (sidebar, 26px high), `mark` (collapsed sidebar), `stacked` (login brand panel). */
|
||||||
|
variant?: keyof typeof sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
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%)]';
|
||||||
|
return <img src={sources[variant]} alt={alt} className={cn('block flex-none', size, className)} {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const icon = { size: 16, strokeWidth: 1.75 } as const;
|
||||||
|
|
||||||
|
const meta: Meta<typeof Menu> = {
|
||||||
|
title: 'Overlays/Menu',
|
||||||
|
component: Menu,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Menu>;
|
||||||
|
|
||||||
|
export const Gruppenmenue: Story = {
|
||||||
|
name: 'Gruppenmenü',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex h-[280px] justify-center">
|
||||||
|
<Menu
|
||||||
|
label="Aktionen für SWE · Collabry"
|
||||||
|
defaultOpen
|
||||||
|
trigger={
|
||||||
|
<Button variant="ghost" size="sm" iconOnly aria-label="Aktionen für SWE · Collabry" className="text-fg-subtle">
|
||||||
|
<MoreHorizontal size={16} strokeWidth={2.5} />
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<MenuLink href="#" icon={<SquareArrowOutUpRight {...icon} />}>
|
||||||
|
Gruppe öffnen
|
||||||
|
</MenuLink>
|
||||||
|
<MenuItem icon={<Pencil {...icon} />}>Bearbeiten</MenuItem>
|
||||||
|
<MenuLink href="#" icon={<Users {...icon} />}>
|
||||||
|
Mitglieder verwalten
|
||||||
|
</MenuLink>
|
||||||
|
<MenuSeparator />
|
||||||
|
<MenuItem danger icon={<LogOut {...icon} />}>
|
||||||
|
Gruppe verlassen
|
||||||
|
</MenuItem>
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
import { forwardRef, type AnchorHTMLAttributes, type ComponentProps, type HTMLAttributes, type ReactNode } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuLabel,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from '../ui/dropdown-menu';
|
||||||
|
|
||||||
|
export interface MenuProps
|
||||||
|
extends Pick<ComponentProps<typeof DropdownMenu>, 'open' | 'defaultOpen' | 'onOpenChange' | 'modal'>,
|
||||||
|
Pick<ComponentProps<typeof DropdownMenuContent>, '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 (
|
||||||
|
<DropdownMenu open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} modal={modal}>
|
||||||
|
<DropdownMenuTrigger asChild>{trigger}</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent
|
||||||
|
aria-label={label}
|
||||||
|
data-size={size}
|
||||||
|
align={align}
|
||||||
|
className={cn('group/menu', size === 'lg' ? 'w-72 rounded-[14px] shadow-menu' : 'w-[220px]', className)}
|
||||||
|
{...position}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 && <span className={cn('flex', danger ? 'text-danger-fg' : 'text-fg-muted')}>{icon}</span>}
|
||||||
|
<span className="flex-auto">{children}</span>
|
||||||
|
{detail && <span className="flex items-center gap-1 text-sm text-fg-subtle">{detail}</span>}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MenuItemProps
|
||||||
|
extends Omit<ComponentProps<typeof DropdownMenuItem>, 'variant' | 'children'>,
|
||||||
|
Omit<ItemContentProps, 'children'> {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Menu action. Use `onSelect` (or `onClick`); the menu closes afterwards. */
|
||||||
|
export function MenuItem({ icon, detail, danger, className, children, ...props }: MenuItemProps) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem variant={danger ? 'destructive' : 'default'} className={cn(itemClass, className)} {...props}>
|
||||||
|
<ItemContent icon={icon} detail={detail} danger={danger}>
|
||||||
|
{children}
|
||||||
|
</ItemContent>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MenuLinkProps extends AnchorHTMLAttributes<HTMLAnchorElement>, Omit<ItemContentProps, 'children'> {}
|
||||||
|
|
||||||
|
export const MenuLink = forwardRef<HTMLAnchorElement, MenuLinkProps>(function MenuLink(
|
||||||
|
{ icon, detail, danger, className, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuItem asChild variant={danger ? 'destructive' : 'default'} className={cn(itemClass, className)}>
|
||||||
|
<a ref={ref} {...props}>
|
||||||
|
<ItemContent icon={icon} detail={detail} danger={danger}>
|
||||||
|
{children}
|
||||||
|
</ItemContent>
|
||||||
|
</a>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export const MenuSeparator = DropdownMenuSeparator;
|
||||||
|
|
||||||
|
/** Non-interactive header block, e.g. the signed-in user. */
|
||||||
|
export function MenuHeader(props: HTMLAttributes<HTMLDivElement>) {
|
||||||
|
return <DropdownMenuLabel {...props} />;
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { me } from '../../stories/fixtures';
|
||||||
|
import { MobileHeader, MobileTabBar } from './MobileNav';
|
||||||
|
|
||||||
|
const meta: Meta<typeof MobileTabBar> = {
|
||||||
|
title: 'Navigation/Mobil',
|
||||||
|
component: MobileTabBar,
|
||||||
|
parameters: { layout: 'fullscreen', viewport: { defaultViewport: 'mobile2' } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof MobileTabBar>;
|
||||||
|
|
||||||
|
export const Bildschirm: Story = {
|
||||||
|
render: (args) => (
|
||||||
|
<div className="mx-auto flex h-[720px] w-full max-w-[390px] flex-col border-x border-line-subtle bg-app">
|
||||||
|
<MobileHeader user={me} unreadCount={4} />
|
||||||
|
<main className="flex flex-auto flex-col gap-4 overflow-y-auto px-4 pt-5 pb-7">
|
||||||
|
<h1 className="m-0 text-display font-black">Hallo Niklas</h1>
|
||||||
|
{Array.from({ length: 6 }, (_, i) => (
|
||||||
|
<div key={i} className="h-24 flex-none rounded-[18px] border border-line-frame bg-frame p-[5px]">
|
||||||
|
<div className="h-full rounded-[13px] border border-line bg-surface" />
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</main>
|
||||||
|
<MobileTabBar {...args} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Kopfzeile: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="max-w-[390px]">
|
||||||
|
<MobileHeader user={me} unreadCount={4} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Tableiste: Story = {
|
||||||
|
name: 'Tab-Leiste',
|
||||||
|
args: { activeId: 'kalender' },
|
||||||
|
render: (args) => (
|
||||||
|
<div className="max-w-[390px]">
|
||||||
|
<MobileTabBar {...args} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { Bell, Calendar, Kanban, LayoutDashboard, Moon, Search, SquareCheck, Sun, Users } from 'lucide-react';
|
||||||
|
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: <LayoutDashboard {...tabIcon} /> },
|
||||||
|
{ id: 'aufgaben', label: 'Aufgaben', href: '#', icon: <SquareCheck {...tabIcon} /> },
|
||||||
|
{ id: 'kanban', label: 'Kanban', href: '#', icon: <Kanban {...tabIcon} /> },
|
||||||
|
{ id: 'kalender', label: 'Kalender', href: '#', icon: <Calendar {...tabIcon} /> },
|
||||||
|
{ id: 'gruppen', label: 'Gruppen', href: '#', icon: <Users {...tabIcon} /> },
|
||||||
|
];
|
||||||
|
|
||||||
|
export interface MobileTabBarProps {
|
||||||
|
items?: NavItemData[];
|
||||||
|
activeId?: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sticky bottom navigation on phones. */
|
||||||
|
export function MobileTabBar({ items = defaultMobileTabs, activeId = 'dashboard', className }: MobileTabBarProps) {
|
||||||
|
return (
|
||||||
|
<nav
|
||||||
|
aria-label="Hauptnavigation"
|
||||||
|
className={cn(
|
||||||
|
'sticky bottom-0 z-[5] box-border flex border-t border-line-shell bg-glass-2 px-1.5 pt-1.5 pb-[calc(8px+env(safe-area-inset-bottom))] backdrop-blur-md',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{items.map((it) => {
|
||||||
|
const active = it.id === activeId;
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={it.id}
|
||||||
|
href={it.href}
|
||||||
|
aria-current={active ? 'page' : undefined}
|
||||||
|
className={cn(
|
||||||
|
'flex h-[52px] min-w-0 flex-1 basis-0 flex-col items-center justify-center gap-1 rounded-[10px] text-2xs font-bold',
|
||||||
|
active ? 'text-accent-fg hover:text-accent-fg' : 'text-fg-subtle hover:text-fg',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{it.icon}
|
||||||
|
{it.label}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 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';
|
||||||
|
return (
|
||||||
|
<header
|
||||||
|
className={cn(
|
||||||
|
'sticky top-0 z-[5] box-border flex h-14 items-center gap-2.5 border-b border-line-shell bg-glass pr-2 pl-4 backdrop-blur-md',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{leading ?? <Logo className="h-6" />}
|
||||||
|
<div className="ml-auto flex items-center">
|
||||||
|
<button type="button" onClick={onToggleTheme} aria-label={themeLabel} title={themeLabel} className={btn}>
|
||||||
|
{theme === 'dark' ? <Sun size={18} strokeWidth={1.75} /> : <Moon size={18} strokeWidth={1.75} />}
|
||||||
|
</button>
|
||||||
|
<button type="button" onClick={onSearch} aria-label="Suchen" className={btn}>
|
||||||
|
<Search size={20} strokeWidth={1.75} />
|
||||||
|
</button>
|
||||||
|
<a href={notificationsHref} aria-label={`Benachrichtigungen, ${unreadCount} ungelesen`} className={cn(btn, 'relative')}>
|
||||||
|
<Bell size={20} strokeWidth={1.75} />
|
||||||
|
{unreadCount > 0 && (
|
||||||
|
<span className="absolute top-[11px] right-3 h-[7px] w-[7px] rounded-full bg-danger shadow-[0_0_0_2px_var(--cl-app)]" />
|
||||||
|
)}
|
||||||
|
</a>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onProfile}
|
||||||
|
aria-label="Profil und Einstellungen"
|
||||||
|
className="flex h-11 w-11 items-center justify-center p-0"
|
||||||
|
>
|
||||||
|
<Avatar person={user} size={30} aria-hidden="true" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
const meta: Meta<typeof NotificationPanel> = {
|
||||||
|
title: 'Overlays/Benachrichtigungen',
|
||||||
|
component: NotificationPanel,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof NotificationPanel>;
|
||||||
|
|
||||||
|
export const Panel: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [today, setToday] = useState(notificationsToday);
|
||||||
|
const [earlier, setEarlier] = useState(notificationsEarlier);
|
||||||
|
const [markAll, setMarkAll] = useState<ButtonState>('idle');
|
||||||
|
const [accept, setAccept] = useState<ButtonState>('idle');
|
||||||
|
const read = (list: NotificationData[], id?: string) => list.map((n) => (!id || n.id === id ? { ...n, unread: false } : n));
|
||||||
|
return (
|
||||||
|
<NotificationPanel
|
||||||
|
today={today}
|
||||||
|
earlier={earlier}
|
||||||
|
onClose={() => 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 } }}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AllesGelesen: Story = {
|
||||||
|
name: 'Alles gelesen',
|
||||||
|
args: { today: [], earlier: [] },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Eintraege: Story = {
|
||||||
|
name: 'Einträge',
|
||||||
|
render: () => (
|
||||||
|
<ul className="m-0 flex w-[400px] flex-col gap-0.5 p-0">
|
||||||
|
{[...notificationsToday, ...notificationsEarlier].map((n) => (
|
||||||
|
<NotificationItem key={n.id} notification={n} />
|
||||||
|
))}
|
||||||
|
<NotificationItem notification={{ ...notificationsToday[2], inviteResult: 'joined', unread: false }} />
|
||||||
|
</ul>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,282 @@
|
|||||||
|
import { useState, type MouseEvent, type ReactNode } from 'react';
|
||||||
|
import { AlertCircle, CheckCircle2, Clock, X } from 'lucide-react';
|
||||||
|
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';
|
||||||
|
|
||||||
|
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<NotificationData, 'kind' | 'person'>) {
|
||||||
|
if (kind === 'person' && person) return <Avatar person={person} size={36} aria-hidden="true" />;
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'box-border flex h-9 w-9 flex-none items-center justify-center rounded-[10px] border border-line-strong bg-elevated',
|
||||||
|
kind === 'deadline' ? 'text-warning-fg' : 'text-danger-fg',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{kind === 'deadline' ? (
|
||||||
|
<Clock size={18} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
) : (
|
||||||
|
<AlertCircle size={18} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NotificationItem({
|
||||||
|
notification: n,
|
||||||
|
onOpen,
|
||||||
|
onAccept,
|
||||||
|
onDecline,
|
||||||
|
acceptState,
|
||||||
|
declineState,
|
||||||
|
href = '#',
|
||||||
|
}: NotificationItemProps) {
|
||||||
|
const busy = acceptState === 'loading' || declineState === 'loading';
|
||||||
|
return (
|
||||||
|
<li className={cn('list-none rounded-xl', n.unread ? 'bg-accent-soft' : 'bg-transparent')}>
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
onClick={(e: MouseEvent) => {
|
||||||
|
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"
|
||||||
|
>
|
||||||
|
<KindIcon kind={n.kind} person={n.person} />
|
||||||
|
<div className="min-w-0 flex-auto">
|
||||||
|
<div className="text-base leading-normal text-fg-muted">
|
||||||
|
<strong className="font-bold text-fg">{n.actor}</strong>
|
||||||
|
{n.verb && ` ${n.verb}`} {n.object && <strong className="font-bold text-fg">{n.object}</strong>}
|
||||||
|
{n.tail}
|
||||||
|
</div>
|
||||||
|
{n.quote && (
|
||||||
|
<div className="mt-2 rounded-lg bg-elevated px-2.5 py-2 text-sm leading-normal text-fg-4">{n.quote}</div>
|
||||||
|
)}
|
||||||
|
<div className="mt-1.5 flex flex-wrap items-center gap-x-[7px] gap-y-1 text-xs text-fg-subtle">
|
||||||
|
{n.group && (
|
||||||
|
<>
|
||||||
|
<Swatch color={n.group.color} />
|
||||||
|
<span>{n.group.name}</span>
|
||||||
|
<span className="text-fg-dim">·</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<span>{n.time}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn('mt-1.5 h-2 w-2 flex-none rounded-full', n.unread ? 'bg-accent' : 'bg-transparent')}
|
||||||
|
/>
|
||||||
|
{n.unread && <span className="sr-only">Ungelesen</span>}
|
||||||
|
</a>
|
||||||
|
{n.invite && !n.inviteResult && (
|
||||||
|
<div className="flex gap-2 pr-3 pb-3 pl-[58px]">
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
size="sm"
|
||||||
|
className="h-[34px] px-3.5 shadow-primary-flat"
|
||||||
|
state={acceptState}
|
||||||
|
disabled={busy}
|
||||||
|
onClick={() => onAccept?.(n.id)}
|
||||||
|
>
|
||||||
|
Beitreten
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
size="sm"
|
||||||
|
className="h-[34px] px-3.5"
|
||||||
|
state={declineState}
|
||||||
|
disabled={busy}
|
||||||
|
onClick={() => onDecline?.(n.id)}
|
||||||
|
>
|
||||||
|
Ablehnen
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{n.invite && n.inviteResult && (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex items-center gap-1.5 pr-3 pb-3 pl-[58px] text-sm font-bold',
|
||||||
|
n.inviteResult === 'joined' ? 'text-success-fg' : 'text-fg-subtle',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{n.inviteResult === 'joined' ? '✓ Du bist der Gruppe beigetreten' : 'Einladung abgelehnt'}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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<string, { accept?: ButtonState; decline?: ButtonState }>;
|
||||||
|
settingsHref?: string;
|
||||||
|
/** Extra classes; position the panel from the outside. */
|
||||||
|
className?: string;
|
||||||
|
/** Rendered without the popover frame (mobile full-screen page). */
|
||||||
|
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 };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section
|
||||||
|
aria-label="Benachrichtigungen"
|
||||||
|
className={cn(
|
||||||
|
'box-border flex flex-col overflow-hidden',
|
||||||
|
!bare && 'max-h-[min(700px,calc(100vh-24px))] w-[400px] max-w-full rounded-2xl border border-line-strong bg-raised shadow-popover',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="flex flex-col gap-3 border-b border-line-divider pt-3.5 pr-2.5 pb-3 pl-4">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<h2 className="m-0 text-md font-bold">Benachrichtigungen</h2>
|
||||||
|
{unread > 0 && <CountBadge tone="accent">{unread}</CountBadge>}
|
||||||
|
<div className="ml-auto flex items-center gap-0.5">
|
||||||
|
{onMarkAllRead && (
|
||||||
|
<Button variant="ghost" size="sm" className="px-2.5" state={markAllState} onClick={onMarkAllRead}>
|
||||||
|
Alle gelesen
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{onClose && (
|
||||||
|
<Button variant="ghost" size="sm" iconOnly aria-label="Schließen" onClick={onClose} className="text-fg-subtle">
|
||||||
|
<X size={16} strokeWidth={1.75} />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="pr-1.5">
|
||||||
|
<SegmentedControl
|
||||||
|
label="Filter"
|
||||||
|
fullWidth
|
||||||
|
value={tab}
|
||||||
|
onChange={setTab}
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'Alle', count: all.length },
|
||||||
|
{ value: 'unread', label: 'Ungelesen', count: unread },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="min-h-0 flex-auto overflow-y-auto px-1.5 pt-1 pb-2">
|
||||||
|
{t.length > 0 && (
|
||||||
|
<>
|
||||||
|
<div className="px-2.5 pt-2.5 pb-1.5 text-xs font-bold text-fg-subtle">Heute</div>
|
||||||
|
<ul className="m-0 flex flex-col gap-0.5 p-0">
|
||||||
|
{t.map((n) => (
|
||||||
|
<NotificationItem
|
||||||
|
key={n.id}
|
||||||
|
notification={n}
|
||||||
|
acceptState={inviteStates[n.id]?.accept}
|
||||||
|
declineState={inviteStates[n.id]?.decline}
|
||||||
|
{...itemProps}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{e.length > 0 && (
|
||||||
|
<>
|
||||||
|
<div className="px-2.5 pt-2.5 pb-1.5 text-xs font-bold text-fg-subtle">Früher</div>
|
||||||
|
<ul className="m-0 flex flex-col gap-0.5 p-0">
|
||||||
|
{e.map((n) => (
|
||||||
|
<NotificationItem
|
||||||
|
key={n.id}
|
||||||
|
notification={n}
|
||||||
|
acceptState={inviteStates[n.id]?.accept}
|
||||||
|
declineState={inviteStates[n.id]?.decline}
|
||||||
|
{...itemProps}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{t.length + e.length === 0 && (
|
||||||
|
<div className="flex flex-col items-center gap-2 px-4 py-12 text-center text-fg-subtle">
|
||||||
|
<CheckCircle2 size={28} strokeWidth={1.75} aria-hidden="true" className="text-success-fg" />
|
||||||
|
<div className="font-bold text-fg">Alles gelesen</div>
|
||||||
|
<div className="text-sm">Neue Benachrichtigungen erscheinen hier.</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="flex border-t border-line-divider px-3 py-2.5">
|
||||||
|
{footer ?? (
|
||||||
|
<a
|
||||||
|
href={settingsHref}
|
||||||
|
className="flex h-8 items-center gap-2 rounded-lg px-2 text-sm font-bold text-fg-muted hover:bg-hover hover:text-fg"
|
||||||
|
>
|
||||||
|
Benachrichtigungs-Einstellungen
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { swatches } from '../../lib/tokens';
|
||||||
|
import { ProgressBar, StatusProgress } from './Progress';
|
||||||
|
|
||||||
|
const meta: Meta<typeof StatusProgress> = {
|
||||||
|
title: 'Anzeige/Fortschritt',
|
||||||
|
component: StatusProgress,
|
||||||
|
args: { counts: { done: 9, review: 2, doing: 3, open: 2 }, legend: true },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof StatusProgress>;
|
||||||
|
|
||||||
|
export const NachStatus: Story = {
|
||||||
|
name: 'Nach Status',
|
||||||
|
decorators: [(Story) => <div className="max-w-[640px]">{Story()}</div>],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Balken: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex max-w-[480px] flex-col gap-4">
|
||||||
|
<ProgressBar value={56} color={swatches.violet} label="SWE · Collabry: 56 % erledigt" />
|
||||||
|
<ProgressBar value={40} color={swatches.cyan} label="Datenbanken Übung: 40 % erledigt" />
|
||||||
|
<ProgressBar value={86} color={swatches.pink} label="Marketing Seminar: 86 % erledigt" />
|
||||||
|
<ProgressBar value={30} label="Akzentfarbe" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import type { CSSProperties, HTMLAttributes } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Progress } from '../ui/progress';
|
||||||
|
import { taskStatusBar, taskStatusLabel, taskStatusOrder, type TaskStatus } from '../../lib/tokens';
|
||||||
|
|
||||||
|
export interface ProgressBarProps extends Omit<HTMLAttributes<HTMLDivElement>, 'dir'> {
|
||||||
|
/** 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));
|
||||||
|
return (
|
||||||
|
<Progress
|
||||||
|
value={pct}
|
||||||
|
aria-label={label}
|
||||||
|
className={className}
|
||||||
|
style={{ '--progress-fill': color, ...style } as CSSProperties}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StatusCounts = Partial<Record<TaskStatus, number>>;
|
||||||
|
|
||||||
|
export interface StatusProgressProps extends HTMLAttributes<HTMLDivElement> {
|
||||||
|
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(', ');
|
||||||
|
return (
|
||||||
|
<div className={cn('min-w-0', className)} {...props}>
|
||||||
|
<div role="img" aria-label={barLabel} className="flex h-2.5 gap-[3px]">
|
||||||
|
{segments.map((s) => (
|
||||||
|
<div key={s.key} className="rounded-full" style={{ width: `${s.w}%`, background: taskStatusBar[s.key] }} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{legend && (
|
||||||
|
<div className="mt-3.5 flex flex-wrap gap-x-[22px] gap-y-2">
|
||||||
|
{segments.map((s) => (
|
||||||
|
<div key={s.key} className="flex items-center gap-2 text-fg-muted">
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className="h-2 w-2 flex-none rounded-[2px]"
|
||||||
|
style={{ background: taskStatusBar[s.key] }}
|
||||||
|
/>
|
||||||
|
{taskStatusLabel[s.key]}
|
||||||
|
<strong className="text-fg tabular-nums">{s.count}</strong>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { SegmentedControl } from './SegmentedControl';
|
||||||
|
|
||||||
|
const meta: Meta<typeof SegmentedControl> = {
|
||||||
|
title: 'Formulare/SegmentedControl',
|
||||||
|
component: SegmentedControl,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof SegmentedControl>;
|
||||||
|
|
||||||
|
export const Filter: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [value, setValue] = useState('all');
|
||||||
|
return (
|
||||||
|
<SegmentedControl
|
||||||
|
label="Filter"
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'Alle', count: 7 },
|
||||||
|
{ value: 'open', label: 'Offen', count: 6 },
|
||||||
|
{ value: 'late', label: 'Überfällig', count: 1 },
|
||||||
|
{ value: 'done', label: 'Erledigt', count: 1 },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Ansicht: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [value, setValue] = useState('month');
|
||||||
|
return (
|
||||||
|
<SegmentedControl
|
||||||
|
label="Ansicht"
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
options={[
|
||||||
|
{ value: 'month', label: 'Monat' },
|
||||||
|
{ value: 'week', label: 'Woche' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Einstellung: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [value, setValue] = useState('off');
|
||||||
|
return (
|
||||||
|
<SegmentedControl
|
||||||
|
label="Neutraltöne einfärben"
|
||||||
|
size="md"
|
||||||
|
minSegmentWidth={84}
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
options={[
|
||||||
|
{ value: 'off', label: 'Aus' },
|
||||||
|
{ value: 'subtle', label: 'Leicht' },
|
||||||
|
{ value: 'strong', label: 'Kräftig' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Volle_Breite: Story = {
|
||||||
|
name: 'Volle Breite',
|
||||||
|
render: function Render() {
|
||||||
|
const [value, setValue] = useState('all');
|
||||||
|
return (
|
||||||
|
<div className="w-[380px]">
|
||||||
|
<SegmentedControl
|
||||||
|
label="Filter"
|
||||||
|
fullWidth
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'Alle', count: 7 },
|
||||||
|
{ value: 'unread', label: 'Ungelesen', count: 4 },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group';
|
||||||
|
|
||||||
|
export interface SegmentedOption<T extends string = string> {
|
||||||
|
value: T;
|
||||||
|
label: string;
|
||||||
|
/** Optional count shown after the label, e.g. "Offen 6". */
|
||||||
|
count?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SegmentedControlProps<T extends string = string> {
|
||||||
|
options: SegmentedOption<T>[];
|
||||||
|
value: T;
|
||||||
|
onChange?: (value: T) => void;
|
||||||
|
/** Accessible name of the group, e.g. "Filter". */
|
||||||
|
label: string;
|
||||||
|
/** 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pill-group of toggle buttons used for filters, views and options. Arrow keys move between segments. */
|
||||||
|
export function SegmentedControl<T extends string = string>({
|
||||||
|
options,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
label,
|
||||||
|
size = 'sm',
|
||||||
|
fullWidth = false,
|
||||||
|
minSegmentWidth,
|
||||||
|
className,
|
||||||
|
}: SegmentedControlProps<T>) {
|
||||||
|
return (
|
||||||
|
<ToggleGroup
|
||||||
|
type="single"
|
||||||
|
aria-label={label}
|
||||||
|
size={size}
|
||||||
|
value={value}
|
||||||
|
// Radix allows deselecting the active item; a segmented control always has one.
|
||||||
|
onValueChange={(v) => v && onChange?.(v as T)}
|
||||||
|
className={cn('gap-0.5 rounded-[10px] border border-line-subtle bg-inset p-[3px]', className)}
|
||||||
|
>
|
||||||
|
{options.map((o) => (
|
||||||
|
<ToggleGroupItem
|
||||||
|
key={o.value}
|
||||||
|
value={o.value}
|
||||||
|
style={minSegmentWidth ? { minWidth: minSegmentWidth } : undefined}
|
||||||
|
className={cn(fullWidth && 'flex-1 basis-0')}
|
||||||
|
>
|
||||||
|
{o.label}
|
||||||
|
{o.count !== undefined && <span className="text-xs font-normal text-fg-subtle tabular-nums">{o.count}</span>}
|
||||||
|
</ToggleGroupItem>
|
||||||
|
))}
|
||||||
|
</ToggleGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,267 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Camera, CircleUser, Info, SlidersHorizontal, Trash2 } from 'lucide-react';
|
||||||
|
import { useId, useRef, useState } from 'react';
|
||||||
|
import { me } from '../../stories/fixtures';
|
||||||
|
import { colorSchemes } from '../../lib/tokens';
|
||||||
|
import { Avatar } 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 {
|
||||||
|
ColorSchemePicker,
|
||||||
|
SaveStatus,
|
||||||
|
SettingsNav,
|
||||||
|
SettingsRow,
|
||||||
|
SettingsSection,
|
||||||
|
ThemePicker,
|
||||||
|
type ThemeChoice,
|
||||||
|
} from './Settings';
|
||||||
|
|
||||||
|
const meta: Meta<typeof SettingsSection> = {
|
||||||
|
title: 'Einstellungen/Einstellungen',
|
||||||
|
component: SettingsSection,
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof SettingsSection>;
|
||||||
|
|
||||||
|
const ni = { size: 18, strokeWidth: 1.75 } as const;
|
||||||
|
const navGroups = [
|
||||||
|
{
|
||||||
|
title: 'Persönlich',
|
||||||
|
items: [
|
||||||
|
{ id: 'konto', label: 'Konto', href: '#', icon: <CircleUser {...ni} /> },
|
||||||
|
{ id: 'allgemein', label: 'Allgemein', href: '#', icon: <SlidersHorizontal {...ni} /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ title: 'App', items: [{ id: 'info', label: 'Info', href: '#', icon: <Info {...ni} /> }] },
|
||||||
|
];
|
||||||
|
|
||||||
|
function useAutosave() {
|
||||||
|
const [state, setState] = useState<'idle' | 'saving' | 'saved'>('idle');
|
||||||
|
const timers = useRef<number[]>([]);
|
||||||
|
const save = () => {
|
||||||
|
timers.current.forEach(clearTimeout);
|
||||||
|
setState('saving');
|
||||||
|
timers.current = [
|
||||||
|
window.setTimeout(() => setState('saved'), 900),
|
||||||
|
window.setTimeout(() => setState('idle'), 3100),
|
||||||
|
];
|
||||||
|
};
|
||||||
|
return { state, save };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Allgemein: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const { state, save } = useAutosave();
|
||||||
|
const [theme, setTheme] = useState<ThemeChoice>('dark');
|
||||||
|
const [scheme, setScheme] = useState('violett');
|
||||||
|
const [tint, setTint] = useState('off');
|
||||||
|
const [week, setWeek] = useState('mo');
|
||||||
|
const schemeLabelId = useId();
|
||||||
|
const pick = <T,>(set: (v: T) => void) => (v: T) => {
|
||||||
|
set(v);
|
||||||
|
save();
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="mx-auto flex max-w-[1040px] flex-col gap-7">
|
||||||
|
<PageHeader
|
||||||
|
eyebrow="Einstellungen"
|
||||||
|
title="Allgemein"
|
||||||
|
description="Darstellung, Sprache und wo Collabry für dich startet."
|
||||||
|
actions={
|
||||||
|
<div className="flex min-h-5 items-center">
|
||||||
|
<SaveStatus state={state} />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<div className="flex flex-wrap items-start gap-x-10 gap-y-6">
|
||||||
|
<SettingsNav groups={navGroups} activeId="allgemein" />
|
||||||
|
<div className="flex min-w-0 max-w-[760px] flex-[999_1_520px] flex-col gap-5">
|
||||||
|
<SettingsSection title="Darstellung" description="Wähle, wie Collabry für dich aussieht.">
|
||||||
|
<ThemePicker value={theme} onChange={pick(setTheme)} className="px-[22px] pt-1 pb-5" />
|
||||||
|
<SettingsRow
|
||||||
|
stacked
|
||||||
|
label={
|
||||||
|
<span className="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1.5">
|
||||||
|
<span id={schemeLabelId}>Farbschema</span>
|
||||||
|
<span className="text-sm text-accent-fg">{colorSchemes.find((s) => s.id === scheme)?.name}</span>
|
||||||
|
</span>
|
||||||
|
}
|
||||||
|
description="Akzentfarbe für Buttons, Links und Markierungen. Gilt für die ganze App."
|
||||||
|
>
|
||||||
|
<ColorSchemePicker options={colorSchemes} value={scheme} onChange={pick(setScheme)} labelledBy={schemeLabelId} />
|
||||||
|
</SettingsRow>
|
||||||
|
<SettingsRow label="Neutraltöne einfärben" description="Schwarz, Grau und Weiß bekommen einen Hauch der Akzentfarbe.">
|
||||||
|
<SegmentedControl
|
||||||
|
label="Neutraltöne einfärben"
|
||||||
|
size="md"
|
||||||
|
minSegmentWidth={84}
|
||||||
|
value={tint}
|
||||||
|
onChange={pick(setTint)}
|
||||||
|
options={[
|
||||||
|
{ value: 'off', label: 'Aus' },
|
||||||
|
{ value: 'subtle', label: 'Leicht' },
|
||||||
|
{ value: 'strong', label: 'Kräftig' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</SettingsRow>
|
||||||
|
</SettingsSection>
|
||||||
|
<SettingsSection title="Sprache & Region" description="Wie Texte, Daten und Kalender angezeigt werden.">
|
||||||
|
<SettingsRow label="Sprache" description="Sprache der Oberfläche." htmlFor="gen-lang">
|
||||||
|
<Select
|
||||||
|
id="gen-lang"
|
||||||
|
size="settings"
|
||||||
|
className="w-[220px] max-w-full"
|
||||||
|
onChange={save}
|
||||||
|
options={[
|
||||||
|
{ value: 'de', label: 'Deutsch' },
|
||||||
|
{ value: 'en', label: 'English' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</SettingsRow>
|
||||||
|
<SettingsRow label="Datumsformat" description="Zum Beispiel bei Deadlines." htmlFor="gen-date">
|
||||||
|
<Select
|
||||||
|
id="gen-date"
|
||||||
|
size="settings"
|
||||||
|
className="w-[220px] max-w-full"
|
||||||
|
onChange={save}
|
||||||
|
options={[
|
||||||
|
{ value: 'de', label: '01.11.2026' },
|
||||||
|
{ value: 'iso', label: '2026-11-01' },
|
||||||
|
{ value: 'us', label: '11/01/2026' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</SettingsRow>
|
||||||
|
<SettingsRow label="Woche beginnt am" description="Gilt für den Kalender und die Wochenansicht.">
|
||||||
|
<SegmentedControl
|
||||||
|
label="Wochenbeginn"
|
||||||
|
size="md"
|
||||||
|
minSegmentWidth={92}
|
||||||
|
value={week}
|
||||||
|
onChange={pick(setWeek)}
|
||||||
|
options={[
|
||||||
|
{ value: 'mo', label: 'Montag' },
|
||||||
|
{ value: 'so', label: 'Sonntag' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</SettingsRow>
|
||||||
|
</SettingsSection>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Konto: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [first, setFirst] = useState('Niklas');
|
||||||
|
const [saved, setSaved] = useState(false);
|
||||||
|
const dirty = first !== 'Niklas';
|
||||||
|
return (
|
||||||
|
<div className="flex max-w-[760px] flex-col gap-5">
|
||||||
|
<SettingsSection
|
||||||
|
title="Profil"
|
||||||
|
description="So sehen dich die anderen in deinen Gruppen."
|
||||||
|
footer={
|
||||||
|
<>
|
||||||
|
{saved && <SaveStatus state="saved" className="mr-auto text-sm" />}
|
||||||
|
{dirty && (
|
||||||
|
<Button variant="ghost" className="rounded-[9px]" onClick={() => setFirst('Niklas')}>
|
||||||
|
Verwerfen
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
className="rounded-[9px] px-4 shadow-primary-flat"
|
||||||
|
disabled={!dirty}
|
||||||
|
onClick={() => setSaved(true)}
|
||||||
|
>
|
||||||
|
Änderungen speichern
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div className="flex flex-wrap items-center gap-4 border-t border-line-subtle px-[22px] py-4">
|
||||||
|
<Avatar person={me} size={64} />
|
||||||
|
<div className="min-w-0 flex-[1_1_200px]">
|
||||||
|
<div className="font-bold">Profilfoto</div>
|
||||||
|
<div className="mt-[3px] text-sm text-fg-subtle">JPG oder PNG, quadratisch wirkt am besten.</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-none gap-2">
|
||||||
|
<Button className="rounded-[9px] px-3" icon={<Camera size={16} strokeWidth={1.75} />}>
|
||||||
|
Foto ändern
|
||||||
|
</Button>
|
||||||
|
<Button variant="ghost" className="rounded-[9px] px-3">
|
||||||
|
Entfernen
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-[repeat(auto-fit,minmax(220px,1fr))] gap-4 border-t border-line-subtle px-[22px] py-[18px]">
|
||||||
|
<Field label="Vorname">
|
||||||
|
{({ id }) => (
|
||||||
|
<Input
|
||||||
|
id={id}
|
||||||
|
className="h-10"
|
||||||
|
autoComplete="given-name"
|
||||||
|
value={first}
|
||||||
|
onChange={(e) => {
|
||||||
|
setFirst(e.target.value);
|
||||||
|
setSaved(false);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
<Field label="Nachname">{({ id }) => <Input id={id} className="h-10" defaultValue="Haiden" />}</Field>
|
||||||
|
<Field label="E-Mail" hint="Wird für die Anmeldung und Benachrichtigungen verwendet." className="col-span-full">
|
||||||
|
{({ id, describedBy }) => (
|
||||||
|
<Input id={id} className="h-10" type="email" defaultValue={me.email} aria-describedby={describedBy} />
|
||||||
|
)}
|
||||||
|
</Field>
|
||||||
|
</div>
|
||||||
|
</SettingsSection>
|
||||||
|
<SettingsSection title="Gefahrenbereich" description="Aktionen, die sich nicht rückgängig machen lassen.">
|
||||||
|
<SettingsRow label="Konto löschen" description="Löscht dein Konto dauerhaft. Das kann nicht rückgängig gemacht werden.">
|
||||||
|
<Button variant="danger-outline" className="rounded-[9px]" icon={<Trash2 size={16} strokeWidth={1.75} />}>
|
||||||
|
Konto löschen
|
||||||
|
</Button>
|
||||||
|
</SettingsRow>
|
||||||
|
</SettingsSection>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Designauswahl: Story = {
|
||||||
|
name: 'Designauswahl',
|
||||||
|
render: function Render() {
|
||||||
|
const [v, setV] = useState<ThemeChoice>('system');
|
||||||
|
return (
|
||||||
|
<div className="max-w-[560px]">
|
||||||
|
<ThemePicker value={v} onChange={setV} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Farbschema: Story = {
|
||||||
|
render: function Render() {
|
||||||
|
const [v, setV] = useState('petrol');
|
||||||
|
return (
|
||||||
|
<div className="max-w-[720px]">
|
||||||
|
<ColorSchemePicker options={colorSchemes} value={v} onChange={setV} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Speicherstatus: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex gap-6">
|
||||||
|
<SaveStatus state="saving" />
|
||||||
|
<SaveStatus state="saved" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
import { useId, type ReactNode } from 'react';
|
||||||
|
import { Check } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Card } from '../Card/Card';
|
||||||
|
import { CardDescription, CardTitle } from '../ui/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[];
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
return (
|
||||||
|
<nav aria-label="Einstellungen" className={cn('flex max-w-[240px] flex-[1_1_200px] flex-col gap-0.5', className)}>
|
||||||
|
{groups.map((g, gi) => (
|
||||||
|
<div key={g.title} className="contents">
|
||||||
|
<div className={cn('px-3 pb-2 text-xs font-bold text-fg-subtle', gi > 0 && 'pt-[18px]')}>{g.title}</div>
|
||||||
|
{g.items.map((it) => {
|
||||||
|
const active = it.id === activeId;
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
key={it.id}
|
||||||
|
href={it.href}
|
||||||
|
aria-current={active ? 'page' : undefined}
|
||||||
|
className={cn(
|
||||||
|
'flex h-[38px] items-center gap-2.5 rounded-lg px-3 font-bold',
|
||||||
|
active
|
||||||
|
? 'bg-side-active text-fg shadow-[inset_0_0_0_1px_var(--cl-side-active-line)] hover:text-fg'
|
||||||
|
: 'text-fg-muted hover:text-fg',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className={cn('flex', active ? 'text-accent-fg' : 'text-fg-subtle')}>{it.icon}</span>
|
||||||
|
{it.label}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (
|
||||||
|
<Card aria-labelledby={id} padding="none" className={className}>
|
||||||
|
<div className="px-[22px] pt-[18px] pb-4">
|
||||||
|
<CardTitle asChild>
|
||||||
|
<h2 id={id}>{title}</h2>
|
||||||
|
</CardTitle>
|
||||||
|
{description && <CardDescription className="mt-1 leading-normal">{description}</CardDescription>}
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
{footer && (
|
||||||
|
<div className="flex flex-wrap items-center justify-end gap-2.5 border-t border-line-subtle px-[22px] py-3.5">
|
||||||
|
{footer}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SettingsRowProps {
|
||||||
|
label: ReactNode;
|
||||||
|
description?: ReactNode;
|
||||||
|
/** id of the control, so the label is a real <label>. */
|
||||||
|
htmlFor?: string;
|
||||||
|
/** The control on the right. Put it on its own line by using `stacked`. */
|
||||||
|
children?: ReactNode;
|
||||||
|
stacked?: boolean;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Label + description on the left, control on the right; wraps on narrow screens. */
|
||||||
|
export function SettingsRow({ label, description, htmlFor, children, stacked, className }: SettingsRowProps) {
|
||||||
|
const L = htmlFor ? Label : 'div';
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'border-t border-line-subtle px-[22px] py-4',
|
||||||
|
!stacked && 'flex flex-wrap items-center justify-between gap-x-6 gap-y-3',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className={cn('min-w-0', !stacked && 'flex-[1_1_260px]')}>
|
||||||
|
<L htmlFor={htmlFor} className="block leading-tight font-bold">
|
||||||
|
{label}
|
||||||
|
</L>
|
||||||
|
{description && <div className="mt-[3px] text-sm leading-normal text-fg-subtle">{description}</div>}
|
||||||
|
</div>
|
||||||
|
{children && <div className={cn(stacked ? 'mt-3.5' : 'max-w-full flex-none')}>{children}</div>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ThemeChoice = 'light' | 'dark' | 'system';
|
||||||
|
|
||||||
|
function MiniWindow({ variant, className }: { variant: 'light' | 'dark'; className?: string }) {
|
||||||
|
const c =
|
||||||
|
variant === 'light'
|
||||||
|
? { bg: '#F4F4F5', side: '#FFFFFF', card: '#FFFFFF', line: '#DEDEE3', bar: '#E4E4E7' }
|
||||||
|
: { bg: '#050505', side: '#0E0E0E', card: '#141414', line: '#2E2E2E', bar: '#262626' };
|
||||||
|
return (
|
||||||
|
<span aria-hidden="true" className={cn('box-border flex h-[74px] w-full gap-1.5 p-2', className)} style={{ background: c.bg }}>
|
||||||
|
<span className="w-[26%] rounded-[5px]" style={{ background: c.side }} />
|
||||||
|
<span className="flex flex-auto flex-col gap-[5px]">
|
||||||
|
<span className="h-[26px] rounded-[5px]" style={{ background: c.card, boxShadow: `inset 0 0 0 1px ${c.line}` }} />
|
||||||
|
<span className="h-2 w-[70%] rounded" style={{ background: c.bar }} />
|
||||||
|
<span className="h-2 w-[45%] rounded" style={{ background: c.bar }} />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Selectable card; the checked one gets an accent ring. */
|
||||||
|
const radioCard =
|
||||||
|
'group flex flex-col rounded-xl border border-line bg-inset text-fg hover:bg-hover data-[state=checked]:shadow-[0_0_0_2px_var(--cl-accent)] data-[state=checked]:focus-visible:shadow-[0_0_0_2px_var(--cl-accent),0_0_0_5px_var(--cl-accent-ring)]';
|
||||||
|
|
||||||
|
const themeLabels: Record<ThemeChoice, string> = { light: 'Hell', dark: 'Dunkel', system: 'System' };
|
||||||
|
|
||||||
|
export interface ThemePickerProps {
|
||||||
|
value: ThemeChoice;
|
||||||
|
onChange?: (value: ThemeChoice) => void;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Radio cards with a miniature preview of each theme. */
|
||||||
|
export function ThemePicker({ value, onChange, className }: ThemePickerProps) {
|
||||||
|
return (
|
||||||
|
<RadioGroup
|
||||||
|
aria-label="Design"
|
||||||
|
value={value}
|
||||||
|
onValueChange={(v) => onChange?.(v as ThemeChoice)}
|
||||||
|
className={cn('grid-cols-[repeat(auto-fit,minmax(140px,1fr))]', className)}
|
||||||
|
>
|
||||||
|
{(['light', 'dark', 'system'] as const).map((t) => (
|
||||||
|
<RadioGroupItem
|
||||||
|
key={t}
|
||||||
|
value={t}
|
||||||
|
className={cn(radioCard, 'gap-2.5 px-2 pt-2 pb-2.5 text-left')}
|
||||||
|
>
|
||||||
|
{t === 'system' ? (
|
||||||
|
<span className="flex h-[74px] w-full overflow-hidden rounded-[9px]">
|
||||||
|
<span className="flex flex-1 basis-0 overflow-hidden">
|
||||||
|
<MiniWindow variant="light" className="w-[200%] flex-none" />
|
||||||
|
</span>
|
||||||
|
<span className="flex flex-1 basis-0 justify-end overflow-hidden">
|
||||||
|
<MiniWindow variant="dark" className="w-[200%] flex-none" />
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<MiniWindow variant={t} className="rounded-[9px]" />
|
||||||
|
)}
|
||||||
|
<span className="flex items-center justify-between gap-2 px-1 text-sm font-bold">
|
||||||
|
{themeLabels[t]}
|
||||||
|
<span className="box-border h-4 w-4 flex-none rounded-full border-[1.5px] border-line-control group-data-[state=checked]:border-accent group-data-[state=checked]:bg-accent group-data-[state=checked]:shadow-[inset_0_0_0_3px_var(--cl-inset)]" />
|
||||||
|
</span>
|
||||||
|
</RadioGroupItem>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ColorSchemeOption {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
color: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ColorSchemePickerProps {
|
||||||
|
options: readonly ColorSchemeOption[];
|
||||||
|
value: string;
|
||||||
|
onChange?: (id: string) => void;
|
||||||
|
/** id of the element that labels the group. */
|
||||||
|
labelledBy?: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Accent color swatches ("Farbschema"). */
|
||||||
|
export function ColorSchemePicker({ options, value, onChange, labelledBy, className }: ColorSchemePickerProps) {
|
||||||
|
return (
|
||||||
|
<RadioGroup
|
||||||
|
aria-labelledby={labelledBy}
|
||||||
|
aria-label={labelledBy ? undefined : 'Farbschema'}
|
||||||
|
value={value}
|
||||||
|
onValueChange={(v) => onChange?.(v)}
|
||||||
|
className={cn('grid-cols-[repeat(auto-fill,minmax(88px,1fr))] gap-2.5', className)}
|
||||||
|
>
|
||||||
|
{options.map((o) => (
|
||||||
|
<RadioGroupItem
|
||||||
|
key={o.id}
|
||||||
|
value={o.id}
|
||||||
|
className={cn(radioCard, 'items-center gap-2 px-1.5 pt-3 pb-2.5 text-xs font-bold')}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
aria-hidden="true"
|
||||||
|
className="flex h-8 w-8 items-center justify-center rounded-full text-on-accent"
|
||||||
|
style={{
|
||||||
|
background: `linear-gradient(180deg, color-mix(in srgb, ${o.color} 88%, #fff) 0%, color-mix(in srgb, ${o.color} 90%, #000) 100%)`,
|
||||||
|
boxShadow: 'inset 0 1px 0 rgba(255,255,255,0.28), 0 1px 2px rgba(0,0,0,0.5)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Check size={16} strokeWidth={3} className="hidden group-data-[state=checked]:block" />
|
||||||
|
</span>
|
||||||
|
{o.name}
|
||||||
|
</RadioGroupItem>
|
||||||
|
))}
|
||||||
|
</RadioGroup>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SaveStatusProps {
|
||||||
|
state: 'idle' | 'saving' | 'saved';
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Autosave indicator: "Wird gespeichert …" then "Gespeichert". */
|
||||||
|
export function SaveStatus({ state, className }: SaveStatusProps) {
|
||||||
|
if (state === 'idle') return null;
|
||||||
|
return (
|
||||||
|
<span
|
||||||
|
role="status"
|
||||||
|
className={cn(
|
||||||
|
'flex items-center gap-1.5 text-xs font-bold',
|
||||||
|
state === 'saving' ? 'text-fg-subtle' : 'text-success-fg',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{state === 'saving' ? <Spinner size={14} /> : <Check size={14} strokeWidth={2.5} aria-hidden="true" />}
|
||||||
|
{state === 'saving' ? 'Wird gespeichert …' : 'Gespeichert'}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { me, notificationsEarlier, notificationsToday } from '../../stories/fixtures';
|
||||||
|
import { NotificationPanel } from '../Notifications/Notifications';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
import { Sidebar, UserMenu } from './Sidebar';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Sidebar> = {
|
||||||
|
title: 'Navigation/Sidebar',
|
||||||
|
component: Sidebar,
|
||||||
|
parameters: { layout: 'fullscreen' },
|
||||||
|
args: { user: me, unreadCount: 4, activeId: 'dashboard', collapsed: false },
|
||||||
|
argTypes: {
|
||||||
|
activeId: { control: 'inline-radio', options: ['dashboard', 'aufgaben', 'kanban', 'kalender', 'gruppen'] },
|
||||||
|
user: { control: false },
|
||||||
|
items: { control: false },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Sidebar>;
|
||||||
|
|
||||||
|
export const Interaktiv: Story = {
|
||||||
|
render: function Render(args) {
|
||||||
|
const [collapsed, setCollapsed] = useState(args.collapsed);
|
||||||
|
const [notif, setNotif] = useState(false);
|
||||||
|
const [theme, setTheme] = useState<'dark' | 'light'>('dark');
|
||||||
|
return (
|
||||||
|
<div className="relative flex h-[760px]">
|
||||||
|
<Sidebar
|
||||||
|
{...args}
|
||||||
|
collapsed={collapsed}
|
||||||
|
onToggleCollapsed={() => setCollapsed((c) => !c)}
|
||||||
|
userMenu={{ theme, onToggleTheme: () => setTheme((t) => (t === 'dark' ? 'light' : 'dark')) }}
|
||||||
|
notificationsOpen={notif}
|
||||||
|
onNotificationsOpenChange={setNotif}
|
||||||
|
notifications={
|
||||||
|
<NotificationPanel
|
||||||
|
today={notificationsToday}
|
||||||
|
earlier={notificationsEarlier}
|
||||||
|
onClose={() => setNotif(false)}
|
||||||
|
onMarkAllRead={() => undefined}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
className="max-w-[338px]"
|
||||||
|
/>
|
||||||
|
<div className="flex-[999_1_560px]" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Eingeklappt: Story = {
|
||||||
|
args: { collapsed: true },
|
||||||
|
render: (args) => (
|
||||||
|
<div className="flex h-[640px]">
|
||||||
|
<Sidebar {...args} />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Kontomenue: Story = {
|
||||||
|
name: 'Kontomenü',
|
||||||
|
parameters: { layout: 'padded' },
|
||||||
|
render: () => (
|
||||||
|
<div className="flex h-[300px] items-end">
|
||||||
|
<UserMenu
|
||||||
|
user={me}
|
||||||
|
defaultOpen
|
||||||
|
trigger={<Button variant="secondary">Konto</Button>}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,247 @@
|
|||||||
|
import { forwardRef, type AnchorHTMLAttributes, type ReactNode } from 'react';
|
||||||
|
import {
|
||||||
|
Bell,
|
||||||
|
Calendar,
|
||||||
|
ChevronRight,
|
||||||
|
ChevronsUpDown,
|
||||||
|
Kanban,
|
||||||
|
LayoutDashboard,
|
||||||
|
LogOut,
|
||||||
|
Moon,
|
||||||
|
PanelLeftClose,
|
||||||
|
PanelLeftOpen,
|
||||||
|
Settings,
|
||||||
|
SquareCheck,
|
||||||
|
Sun,
|
||||||
|
Users,
|
||||||
|
} from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Avatar, type Person } from '../Avatar/Avatar';
|
||||||
|
import { Logo } from '../Logo/Logo';
|
||||||
|
import { Menu, MenuHeader, MenuItem, MenuLink, MenuSeparator, type MenuProps } from '../Menu/Menu';
|
||||||
|
import { Popover, PopoverAnchor, PopoverContent, PopoverTrigger } from '../ui/popover';
|
||||||
|
|
||||||
|
const icon = { size: 18, strokeWidth: 1.75, 'aria-hidden': true } as const;
|
||||||
|
|
||||||
|
export interface NavItemData {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
href: string;
|
||||||
|
icon: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The app's main destinations, as in the design. */
|
||||||
|
export const defaultNavItems: NavItemData[] = [
|
||||||
|
{ id: 'dashboard', label: 'Dashboard', href: '#', icon: <LayoutDashboard {...icon} /> },
|
||||||
|
{ id: 'aufgaben', label: 'Aufgaben', href: '#', icon: <SquareCheck {...icon} /> },
|
||||||
|
{ id: 'kanban', label: 'Kanban', href: '#', icon: <Kanban {...icon} /> },
|
||||||
|
{ id: 'kalender', label: 'Kalender', href: '#', icon: <Calendar {...icon} /> },
|
||||||
|
{ id: 'gruppen', label: 'Gruppen', href: '#', icon: <Users {...icon} /> },
|
||||||
|
];
|
||||||
|
|
||||||
|
export interface NavItemProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||||
|
icon: ReactNode;
|
||||||
|
active?: boolean;
|
||||||
|
/** Hide the label visually (collapsed sidebar). */
|
||||||
|
collapsed?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sidebar navigation link. The active item gets an inset frame and accent icon. */
|
||||||
|
export const NavItem = forwardRef<HTMLAnchorElement, NavItemProps>(function NavItem(
|
||||||
|
{ icon, active, collapsed, className, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
ref={ref}
|
||||||
|
aria-current={active ? 'page' : undefined}
|
||||||
|
title={collapsed && typeof children === 'string' ? children : undefined}
|
||||||
|
className={cn(
|
||||||
|
'box-border flex h-[38px] items-center gap-3 rounded-lg',
|
||||||
|
collapsed ? 'flex-[1_1_100%] justify-center px-0' : 'flex-[1_1_190px] justify-start px-3',
|
||||||
|
active
|
||||||
|
? 'bg-side-active font-bold text-fg shadow-nav-active hover:text-fg'
|
||||||
|
: 'text-fg-muted hover:text-fg',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<span className={cn('flex', active && 'text-accent-fg')}>{icon}</span>
|
||||||
|
<span className={collapsed ? 'sr-only' : 'whitespace-nowrap'}>{children}</span>
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface SidebarProps {
|
||||||
|
items?: NavItemData[];
|
||||||
|
activeId?: string;
|
||||||
|
collapsed?: boolean;
|
||||||
|
onToggleCollapsed?: () => void;
|
||||||
|
unreadCount?: number;
|
||||||
|
/** Popover content opened by the bell, usually a `NotificationPanel`. */
|
||||||
|
notifications?: ReactNode;
|
||||||
|
notificationsOpen?: boolean;
|
||||||
|
onNotificationsOpenChange?: (open: boolean) => void;
|
||||||
|
user: Person & { email?: string };
|
||||||
|
/** Account menu opened by the user button. */
|
||||||
|
userMenu?: Omit<UserMenuProps, 'user' | 'trigger'>;
|
||||||
|
/** Extra content between navigation and the user button (e.g. actions in Variante D). */
|
||||||
|
children?: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Collapsible app sidebar: logo, notifications bell, navigation and account button. */
|
||||||
|
export function Sidebar({
|
||||||
|
items = defaultNavItems,
|
||||||
|
activeId = 'dashboard',
|
||||||
|
collapsed = false,
|
||||||
|
onToggleCollapsed,
|
||||||
|
unreadCount = 0,
|
||||||
|
notifications,
|
||||||
|
notificationsOpen,
|
||||||
|
onNotificationsOpenChange,
|
||||||
|
user,
|
||||||
|
userMenu,
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
}: SidebarProps) {
|
||||||
|
const toggleLabel = collapsed ? 'Seitenleiste ausklappen' : 'Seitenleiste einklappen';
|
||||||
|
const ghost =
|
||||||
|
'flex h-8 w-8 flex-none items-center justify-center rounded-lg text-fg-muted hover:bg-hover hover:text-fg focus-visible:shadow-focus focus-visible:outline-none';
|
||||||
|
const bell = (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={`Benachrichtigungen, ${unreadCount} ungelesen`}
|
||||||
|
className={cn(ghost, 'relative data-[state=open]:bg-elevated')}
|
||||||
|
>
|
||||||
|
<Bell {...icon} />
|
||||||
|
{unreadCount > 0 && (
|
||||||
|
<span className="absolute top-[7px] right-2 h-[7px] w-[7px] rounded-full bg-danger shadow-[0_0_0_2px_var(--cl-side)]" />
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
const userButton = (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
aria-label={`Konto-Menü, ${user.name}`}
|
||||||
|
className={cn(
|
||||||
|
'box-border flex w-full items-center gap-2.5 rounded-[10px] p-1.5 text-left text-fg hover:bg-hover data-[state=open]:bg-elevated',
|
||||||
|
collapsed ? 'justify-center' : 'justify-start',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Avatar person={user} size={32} aria-hidden="true" />
|
||||||
|
{!collapsed && (
|
||||||
|
<>
|
||||||
|
<span className="min-w-0 flex-auto truncate font-bold">{user.name}</span>
|
||||||
|
<ChevronsUpDown size={16} strokeWidth={1.75} aria-hidden="true" className="text-fg-subtle" />
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
const aside = (
|
||||||
|
<aside
|
||||||
|
aria-label="Seitenleiste"
|
||||||
|
className={cn(
|
||||||
|
'box-border flex min-w-0 flex-col gap-7 overflow-hidden border-r border-side-line bg-side shadow-side',
|
||||||
|
'transition-[flex-basis,padding] duration-[180ms] ease-out',
|
||||||
|
collapsed ? 'flex-[0_0_68px] px-3 py-5' : 'flex-[1_1_248px] px-3.5 py-5',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className={cn('flex items-center', collapsed ? 'flex-col gap-3.5' : 'gap-2.5 pr-1 pl-2')}>
|
||||||
|
<Logo variant={collapsed ? 'mark' : 'wordmark'} />
|
||||||
|
<div className={cn('flex items-center gap-0.5', collapsed ? 'flex-col' : 'ml-auto')}>
|
||||||
|
{notifications ? <PopoverTrigger asChild>{bell}</PopoverTrigger> : bell}
|
||||||
|
<button type="button" onClick={onToggleCollapsed} aria-expanded={!collapsed} aria-label={toggleLabel} title={toggleLabel} className={ghost}>
|
||||||
|
{collapsed ? <PanelLeftOpen {...icon} /> : <PanelLeftClose {...icon} />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav aria-label="Hauptnavigation" className="flex flex-wrap gap-0.5">
|
||||||
|
{items.map((it) => (
|
||||||
|
<NavItem key={it.id} href={it.href} icon={it.icon} active={it.id === activeId} collapsed={collapsed}>
|
||||||
|
{it.label}
|
||||||
|
</NavItem>
|
||||||
|
))}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{children}
|
||||||
|
|
||||||
|
<div className="mt-auto border-t border-side-line pt-3">
|
||||||
|
{userMenu ? <UserMenu user={user} trigger={userButton} {...userMenu} /> : userButton}
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
);
|
||||||
|
if (!notifications) return aside;
|
||||||
|
return (
|
||||||
|
<Popover open={notificationsOpen} onOpenChange={onNotificationsOpenChange}>
|
||||||
|
<PopoverAnchor asChild>{aside}</PopoverAnchor>
|
||||||
|
{/* Sits just right of the sidebar, as in the design. */}
|
||||||
|
<PopoverContent side="right" align="start" sideOffset={12} alignOffset={12} collisionPadding={12}>
|
||||||
|
{notifications}
|
||||||
|
</PopoverContent>
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserMenuProps extends Pick<MenuProps, 'open' | 'defaultOpen' | 'onOpenChange' | 'side' | 'align'> {
|
||||||
|
user: Person & { email?: string };
|
||||||
|
/** The element that opens the menu. */
|
||||||
|
trigger: ReactNode;
|
||||||
|
theme?: 'dark' | 'light';
|
||||||
|
onToggleTheme?: () => void;
|
||||||
|
settingsHref?: string;
|
||||||
|
logoutHref?: string;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Account menu, opened by the sidebar's user button. */
|
||||||
|
export function UserMenu({
|
||||||
|
user,
|
||||||
|
trigger,
|
||||||
|
theme = 'dark',
|
||||||
|
onToggleTheme,
|
||||||
|
settingsHref = '#',
|
||||||
|
logoutHref = '#',
|
||||||
|
className,
|
||||||
|
side = 'top',
|
||||||
|
align = 'start',
|
||||||
|
...menu
|
||||||
|
}: UserMenuProps) {
|
||||||
|
return (
|
||||||
|
<Menu label="Konto" size="lg" trigger={trigger} side={side} align={align} className={className} {...menu}>
|
||||||
|
<MenuHeader>
|
||||||
|
<Avatar person={user} size={36} aria-hidden="true" />
|
||||||
|
<div className="min-w-0 flex-auto">
|
||||||
|
<div className="leading-tight font-bold">{user.name}</div>
|
||||||
|
{user.email && <div className="truncate text-xs text-fg-subtle">{user.email}</div>}
|
||||||
|
</div>
|
||||||
|
</MenuHeader>
|
||||||
|
<MenuSeparator />
|
||||||
|
<MenuLink href={settingsHref} icon={<Settings {...icon} />}>
|
||||||
|
Einstellungen
|
||||||
|
</MenuLink>
|
||||||
|
<MenuItem
|
||||||
|
// Keep the menu open so the new theme is visible right away.
|
||||||
|
onSelect={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
onToggleTheme?.();
|
||||||
|
}}
|
||||||
|
icon={theme === 'dark' ? <Moon {...icon} /> : <Sun {...icon} />}
|
||||||
|
detail={
|
||||||
|
<>
|
||||||
|
{theme === 'dark' ? 'Dunkel' : 'Hell'}
|
||||||
|
<ChevronRight size={14} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Darstellung
|
||||||
|
</MenuItem>
|
||||||
|
<MenuSeparator />
|
||||||
|
<MenuLink href={logoutHref} icon={<LogOut {...icon} />}>
|
||||||
|
Abmelden
|
||||||
|
</MenuLink>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import type { SVGAttributes } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
|
||||||
|
export interface SpinnerProps extends SVGAttributes<SVGSVGElement> {
|
||||||
|
size?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Indeterminate loading ring. Inherits `currentColor`. */
|
||||||
|
export function Spinner({ size = 14, className, ...props }: SpinnerProps) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth={2.5}
|
||||||
|
strokeLinecap="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn('cl-spinner flex-none animate-spin-fast', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<circle cx="12" cy="12" r="9" opacity={0.25} />
|
||||||
|
<path d="M21 12a9 9 0 0 0-9-9" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Checkmark that pops and draws in, shown briefly after an action succeeds. */
|
||||||
|
export function SuccessCheck({ size = 14, className, ...props }: SpinnerProps) {
|
||||||
|
return (
|
||||||
|
<svg
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
strokeWidth={3}
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn('flex-none animate-pop draw-check', className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<path d="M20 6 9 17l-5-5" />
|
||||||
|
</svg>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { ChevronRight } from 'lucide-react';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { deadlines, tasks as sample } from '../../stories/fixtures';
|
||||||
|
import { taskStatusBar, taskStatusLabel, taskStatusOrder, type TaskStatus } from '../../lib/tokens';
|
||||||
|
import { ButtonLink } from '../Button/Button';
|
||||||
|
import { Card, CardFooter, CardHeader } from '../Card/Card';
|
||||||
|
import { SegmentedControl } from '../SegmentedControl/SegmentedControl';
|
||||||
|
import { DeadlineItem, PriorityLabel, TaskSectionHeader, TaskTable, TaskTableHeader, type TaskData } from './Task';
|
||||||
|
|
||||||
|
const meta: Meta<typeof TaskTable> = {
|
||||||
|
title: 'Aufgaben/Aufgabenliste',
|
||||||
|
component: TaskTable,
|
||||||
|
args: { tasks: sample, columns: 'compact' },
|
||||||
|
argTypes: { columns: { control: 'inline-radio', options: ['compact', 'full'] }, tasks: { control: false } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof TaskTable>;
|
||||||
|
|
||||||
|
function useTasks() {
|
||||||
|
const [tasks, setTasks] = useState<TaskData[]>(sample);
|
||||||
|
const [loading, setLoading] = useState<string[]>([]);
|
||||||
|
const toggle = (id: string) => {
|
||||||
|
setLoading((l) => [...l, id]);
|
||||||
|
setTimeout(() => {
|
||||||
|
setTasks((ts) =>
|
||||||
|
ts.map((t) => {
|
||||||
|
if (t.id !== id) return t;
|
||||||
|
const original = sample.find((s) => s.id === id)!.status;
|
||||||
|
const reopened: TaskStatus = original === 'done' ? 'open' : original;
|
||||||
|
return { ...t, status: t.status === 'done' ? reopened : 'done' };
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
setLoading((l) => l.filter((x) => x !== id));
|
||||||
|
}, 700);
|
||||||
|
};
|
||||||
|
return { tasks, loading, toggle };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Kompakt: Story = {
|
||||||
|
render: function Render(args) {
|
||||||
|
const { tasks, loading, toggle } = useTasks();
|
||||||
|
return <TaskTable {...args} tasks={tasks} loadingIds={loading} onToggle={toggle} />;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Dashboardkarte: Story = {
|
||||||
|
name: 'Dashboard: Meine Aufgaben',
|
||||||
|
render: function Render() {
|
||||||
|
const { tasks, loading, toggle } = useTasks();
|
||||||
|
const [filter, setFilter] = useState('all');
|
||||||
|
const isLate = (t: TaskData) => t.overdue && t.status !== 'done';
|
||||||
|
const counts = {
|
||||||
|
all: tasks.length,
|
||||||
|
open: tasks.filter((t) => t.status !== 'done').length,
|
||||||
|
late: tasks.filter(isLate).length,
|
||||||
|
done: tasks.filter((t) => t.status === 'done').length,
|
||||||
|
};
|
||||||
|
const shown = tasks.filter((t) =>
|
||||||
|
filter === 'all' ? true : filter === 'open' ? t.status !== 'done' : filter === 'late' ? isLate(t) : t.status === 'done',
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Card aria-labelledby="h-tasks">
|
||||||
|
<CardHeader
|
||||||
|
titleId="h-tasks"
|
||||||
|
title="Meine Aufgaben"
|
||||||
|
count={counts.open}
|
||||||
|
actions={
|
||||||
|
<SegmentedControl
|
||||||
|
label="Filter"
|
||||||
|
value={filter}
|
||||||
|
onChange={setFilter}
|
||||||
|
options={[
|
||||||
|
{ value: 'all', label: 'Alle', count: counts.all },
|
||||||
|
{ value: 'open', label: 'Offen', count: counts.open },
|
||||||
|
{ value: 'late', label: 'Überfällig', count: counts.late },
|
||||||
|
{ value: 'done', label: 'Erledigt', count: counts.done },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<TaskTable tasks={shown} loadingIds={loading} onToggle={toggle} />
|
||||||
|
<CardFooter>
|
||||||
|
<ButtonLink href="#" size="sm" className="h-[34px]" iconEnd={<ChevronRight size={14} strokeWidth={1.75} />}>
|
||||||
|
Alle Aufgaben
|
||||||
|
</ButtonLink>
|
||||||
|
</CardFooter>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Vollstaendig: Story = {
|
||||||
|
name: 'Aufgabenseite (gruppiert)',
|
||||||
|
render: function Render() {
|
||||||
|
const { tasks, loading, toggle } = useTasks();
|
||||||
|
const [open, setOpen] = useState<Record<string, boolean>>({ doing: true, review: true, open: true, done: false });
|
||||||
|
const order: TaskStatus[] = ['doing', 'review', 'open', 'done'];
|
||||||
|
return (
|
||||||
|
<Card aria-label="Aufgabenliste" padding="none" innerClassName="overflow-hidden">
|
||||||
|
<TaskTableHeader columns="full" />
|
||||||
|
{order.map((s) => {
|
||||||
|
const rows = tasks.filter((t) => t.status === s);
|
||||||
|
return (
|
||||||
|
<div key={s}>
|
||||||
|
<TaskSectionHeader
|
||||||
|
title={taskStatusLabel[s]}
|
||||||
|
count={rows.length}
|
||||||
|
color={taskStatusBar[s]}
|
||||||
|
open={open[s]}
|
||||||
|
onToggle={() => setOpen((o) => ({ ...o, [s]: !o[s] }))}
|
||||||
|
/>
|
||||||
|
{open[s] && (
|
||||||
|
<TaskTable
|
||||||
|
tasks={rows}
|
||||||
|
columns="full"
|
||||||
|
header={false}
|
||||||
|
emptyText={null}
|
||||||
|
loadingIds={loading}
|
||||||
|
onToggle={toggle}
|
||||||
|
onOpen={() => undefined}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Prioritaet: Story = {
|
||||||
|
name: 'Priorität',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex gap-6">
|
||||||
|
<PriorityLabel priority="Hoch" />
|
||||||
|
<PriorityLabel priority="Mittel" />
|
||||||
|
<PriorityLabel priority="Niedrig" />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Deadlines: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="max-w-[460px]">
|
||||||
|
<Card aria-labelledby="h-deadlines" innerClassName="gap-2">
|
||||||
|
<CardHeader titleId="h-deadlines" title="Anstehende Deadlines" count={deadlines.length} />
|
||||||
|
<ul className="m-0 flex flex-col p-0">
|
||||||
|
{deadlines.map((d, i) => (
|
||||||
|
<DeadlineItem key={d.title} {...d} last={i === deadlines.length - 1} />
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const StatusReihenfolge: Story = {
|
||||||
|
name: 'Statusfarben',
|
||||||
|
render: () => (
|
||||||
|
<div className="flex gap-4">
|
||||||
|
{taskStatusOrder.map((s) => (
|
||||||
|
<span key={s} className="flex items-center gap-2 text-fg-muted">
|
||||||
|
<span className="h-2 w-2 rounded-[2px]" style={{ background: taskStatusBar[s] }} />
|
||||||
|
{taskStatusLabel[s]}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,295 @@
|
|||||||
|
import type { ReactNode } from 'react';
|
||||||
|
import { ChevronRight, Flag, MessageSquare } from 'lucide-react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import type { Priority, TaskStatus } from '../../lib/tokens';
|
||||||
|
import { Avatar, type Person } from '../Avatar/Avatar';
|
||||||
|
import { StatusBadge, Swatch } from '../Badge/Badge';
|
||||||
|
import { TaskCheckbox } from '../Checkbox/Checkbox';
|
||||||
|
|
||||||
|
const prioColor: Record<Priority, string> = {
|
||||||
|
Hoch: 'text-danger-fg',
|
||||||
|
Mittel: 'text-warning-fg',
|
||||||
|
Niedrig: 'text-fg-dim',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Flag icon plus "Hoch" / "Mittel" / "Niedrig". */
|
||||||
|
export function PriorityLabel({ priority, className }: { priority: Priority; className?: string }) {
|
||||||
|
return (
|
||||||
|
<span className={cn('flex items-center gap-1.5 text-sm text-fg-muted', className)}>
|
||||||
|
<Flag size={14} strokeWidth={1.75} aria-hidden="true" className={cn('fill-current', prioColor[priority])} />
|
||||||
|
{priority}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskData {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
group: { name: string; color: string };
|
||||||
|
priority: Priority;
|
||||||
|
/** Display date, e.g. "Mi, 4. Nov". */
|
||||||
|
due: string;
|
||||||
|
status: TaskStatus;
|
||||||
|
overdue?: boolean;
|
||||||
|
assignee?: Person;
|
||||||
|
comments?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type TaskColumns = 'compact' | 'full';
|
||||||
|
|
||||||
|
const grid: Record<TaskColumns, string> = {
|
||||||
|
compact: 'grid-cols-[36px_minmax(0,1fr)_92px_148px_96px]',
|
||||||
|
full: 'grid-cols-[40px_minmax(0,1fr)_180px_96px_130px_104px]',
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface TaskRowProps {
|
||||||
|
task: TaskData;
|
||||||
|
/** `compact` (dashboard) or `full` with assignee (Aufgaben page). */
|
||||||
|
columns?: TaskColumns;
|
||||||
|
onToggle?: (id: string) => void;
|
||||||
|
onOpen?: (id: string) => void;
|
||||||
|
loading?: boolean;
|
||||||
|
/** Hide the bottom rule (last row). */
|
||||||
|
last?: boolean;
|
||||||
|
/** Highlight, e.g. the row whose details are open. */
|
||||||
|
selected?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TaskRow({ task: t, columns = 'compact', onToggle, onOpen, loading, last, selected }: TaskRowProps) {
|
||||||
|
const done = t.status === 'done';
|
||||||
|
const late = t.overdue && !done;
|
||||||
|
const title = (
|
||||||
|
<>
|
||||||
|
<span
|
||||||
|
className={cn(
|
||||||
|
'block truncate leading-tight font-bold',
|
||||||
|
done ? 'text-fg-subtle line-through' : 'text-fg',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{t.title}
|
||||||
|
</span>
|
||||||
|
<span className="mt-[3px] flex items-center gap-[7px] text-xs text-fg-muted">
|
||||||
|
<Swatch color={t.group.color} />
|
||||||
|
{t.group.name}
|
||||||
|
{!!t.comments && (
|
||||||
|
<span className="ml-1.5 flex items-center gap-1 text-fg-subtle">
|
||||||
|
<MessageSquare size={12} strokeWidth={1.75} aria-hidden="true" />
|
||||||
|
{t.comments}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="row"
|
||||||
|
className={cn(
|
||||||
|
'grid items-center gap-3',
|
||||||
|
grid[columns],
|
||||||
|
columns === 'compact' ? 'py-[9px]' : 'py-1.5 pr-[18px] pl-2.5',
|
||||||
|
columns === 'compact' ? !last && 'border-b border-line-row' : 'border-t border-line-row',
|
||||||
|
selected && 'bg-hover-row',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span role="cell">
|
||||||
|
<TaskCheckbox
|
||||||
|
checked={done}
|
||||||
|
loading={loading}
|
||||||
|
taskTitle={t.title}
|
||||||
|
size={columns === 'compact' ? 36 : 40}
|
||||||
|
onToggle={() => onToggle?.(t.id)}
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
<span role="cell" className="min-w-0">
|
||||||
|
{onOpen ? (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => onOpen(t.id)}
|
||||||
|
aria-label={`${t.title} öffnen`}
|
||||||
|
className="block w-full min-w-0 py-1.5 text-left"
|
||||||
|
>
|
||||||
|
{title}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
title
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
{columns === 'full' && (
|
||||||
|
<span role="cell" className="flex min-w-0 items-center gap-2 text-sm text-fg-muted">
|
||||||
|
{t.assignee && (
|
||||||
|
<>
|
||||||
|
<Avatar person={t.assignee} size={24} aria-hidden="true" />
|
||||||
|
<span className="truncate">{t.assignee.name}</span>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span role="cell">
|
||||||
|
<PriorityLabel priority={t.priority} />
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
role="cell"
|
||||||
|
className={cn(
|
||||||
|
'text-sm tabular-nums',
|
||||||
|
late ? 'font-bold text-danger-fg' : done ? 'text-fg-subtle' : 'text-fg-muted',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{late ? `${t.due} · überfällig` : t.due}
|
||||||
|
</span>
|
||||||
|
<span role="cell">
|
||||||
|
<StatusBadge status={t.status} />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Column labels for a task table. */
|
||||||
|
export function TaskTableHeader({ columns = 'compact' }: { columns?: TaskColumns }) {
|
||||||
|
const headers =
|
||||||
|
columns === 'compact'
|
||||||
|
? ['Aufgabe', 'Priorität', 'Fällig', 'Status']
|
||||||
|
: ['Aufgabe', 'Zuständig', 'Priorität', 'Fällig', 'Status'];
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="row"
|
||||||
|
className={cn(
|
||||||
|
'grid items-center gap-3 text-xs text-fg-subtle',
|
||||||
|
grid[columns],
|
||||||
|
columns === 'compact' ? 'border-b border-line-divider pb-2.5' : 'pt-3 pr-[18px] pb-2.5 pl-2.5',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span role="columnheader" />
|
||||||
|
{headers.map((h) => (
|
||||||
|
<span key={h} role="columnheader">
|
||||||
|
{h}
|
||||||
|
</span>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskTableProps {
|
||||||
|
tasks: TaskData[];
|
||||||
|
columns?: TaskColumns;
|
||||||
|
/** Render the column labels. Turn off for the sections of a grouped list. */
|
||||||
|
header?: boolean;
|
||||||
|
onToggle?: (id: string) => void;
|
||||||
|
onOpen?: (id: string) => void;
|
||||||
|
loadingIds?: string[];
|
||||||
|
emptyText?: ReactNode;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Header row plus task rows; scrolls horizontally on narrow screens. */
|
||||||
|
export function TaskTable({
|
||||||
|
tasks,
|
||||||
|
columns = 'compact',
|
||||||
|
header = true,
|
||||||
|
onToggle,
|
||||||
|
onOpen,
|
||||||
|
loadingIds = [],
|
||||||
|
emptyText = 'Hier ist gerade nichts.',
|
||||||
|
className,
|
||||||
|
}: TaskTableProps) {
|
||||||
|
return (
|
||||||
|
<div className={cn('overflow-x-auto', className)}>
|
||||||
|
<div role="table" aria-label="Aufgaben" className={columns === 'compact' ? 'min-w-[600px]' : 'min-w-[760px]'}>
|
||||||
|
{header && <TaskTableHeader columns={columns} />}
|
||||||
|
{tasks.length === 0 && emptyText && <div className="px-4 py-9 text-center text-fg-muted">{emptyText}</div>}
|
||||||
|
{tasks.map((t, i) => (
|
||||||
|
<TaskRow
|
||||||
|
key={t.id}
|
||||||
|
task={t}
|
||||||
|
columns={columns}
|
||||||
|
onToggle={onToggle}
|
||||||
|
onOpen={onOpen}
|
||||||
|
loading={loadingIds.includes(t.id)}
|
||||||
|
last={i === tasks.length - 1}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskSectionHeaderProps {
|
||||||
|
title: string;
|
||||||
|
count: number;
|
||||||
|
/** Status dot color. */
|
||||||
|
color: string;
|
||||||
|
open: boolean;
|
||||||
|
onToggle?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Collapsible group header in the full task list ("In Arbeit 3"). */
|
||||||
|
export function TaskSectionHeader({ title, count, color, open, onToggle }: TaskSectionHeaderProps) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onToggle}
|
||||||
|
aria-expanded={open}
|
||||||
|
className="flex w-full items-center gap-2 border-0 border-t border-line-subtle bg-section px-[18px] py-2.5 text-left text-sm font-bold text-fg"
|
||||||
|
>
|
||||||
|
<ChevronRight
|
||||||
|
size={14}
|
||||||
|
strokeWidth={1.75}
|
||||||
|
aria-hidden="true"
|
||||||
|
className={cn('text-fg-subtle transition-transform duration-150', open && 'rotate-90')}
|
||||||
|
/>
|
||||||
|
<span className="h-2 w-2 rounded-full" style={{ background: color }} />
|
||||||
|
{title}
|
||||||
|
<span className="inline-flex h-5 items-center rounded-full bg-chip px-[7px] text-xs font-normal text-fg-3">
|
||||||
|
{count}
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeadlineItemProps {
|
||||||
|
/** Weekday short, e.g. "MO". */
|
||||||
|
weekday: string;
|
||||||
|
day: string | number;
|
||||||
|
title: string;
|
||||||
|
group: { name: string; color: string };
|
||||||
|
/** Relative time, e.g. "morgen", "in 3 Tagen". */
|
||||||
|
when: string;
|
||||||
|
/** Highlights `when` in amber. */
|
||||||
|
soon?: boolean;
|
||||||
|
href?: string;
|
||||||
|
last?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Deadline row with a date tile, used on the dashboard. */
|
||||||
|
export function DeadlineItem({ weekday, day, title, group, when, soon, href = '#', last }: DeadlineItemProps) {
|
||||||
|
return (
|
||||||
|
<li className={cn('list-none', !last && 'border-b border-line-subtle')}>
|
||||||
|
<a href={href} className="-mx-2 flex items-center gap-3.5 rounded-lg px-2 py-3 text-fg hover:bg-hover-row hover:text-fg">
|
||||||
|
<DateTile weekday={weekday} day={day} />
|
||||||
|
<div className="min-w-0 flex-auto">
|
||||||
|
<div className="truncate leading-tight font-bold">{title}</div>
|
||||||
|
<div className="mt-[3px] flex items-center gap-[7px] text-xs text-fg-muted">
|
||||||
|
<Swatch color={group.color} />
|
||||||
|
{group.name}
|
||||||
|
<span className="text-fg-dim">·</span>
|
||||||
|
<span className={soon ? 'font-bold text-warning-fg' : undefined}>{when}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ChevronRight size={16} strokeWidth={1.75} aria-hidden="true" className="text-fg-faint" />
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DateTile({ weekday, day, className }: { weekday: string; day: string | number; className?: string }) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'box-border flex h-12 w-11 flex-none flex-col items-center justify-center rounded-[10px] border border-line-divider bg-raised',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<div className="text-[10px] leading-tight font-bold tracking-[0.04em] text-fg-subtle">{weekday}</div>
|
||||||
|
<div className="text-[18px] leading-[1.1] font-bold tabular-nums">{day}</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { Plus } from 'lucide-react';
|
||||||
|
import { colorSchemes } from '../../lib/tokens';
|
||||||
|
import { StatusBadge } from '../Badge/Badge';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
import { Card, CardHeader } from '../Card/Card';
|
||||||
|
import { ThemeProvider } from './ThemeProvider';
|
||||||
|
|
||||||
|
const meta: Meta<typeof ThemeProvider> = {
|
||||||
|
title: 'Grundlagen/ThemeProvider',
|
||||||
|
component: ThemeProvider,
|
||||||
|
args: { theme: 'light', accent: colorSchemes[0].color, tint: 'off' },
|
||||||
|
argTypes: {
|
||||||
|
theme: { control: 'inline-radio', options: ['dark', 'light'] },
|
||||||
|
tint: { control: 'inline-radio', options: ['off', 'subtle', 'strong'] },
|
||||||
|
accent: { control: 'color', presetColors: colorSchemes.map((s) => s.color) },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof ThemeProvider>;
|
||||||
|
|
||||||
|
function Sample() {
|
||||||
|
return (
|
||||||
|
<Card>
|
||||||
|
<CardHeader title="Meine Aufgaben" count={6} actions={<StatusBadge status="doing" />} />
|
||||||
|
<p className="m-0 text-fg-muted">
|
||||||
|
Neutraltöne, Akzent und Status kommen aus dem nächstgelegenen <code>ThemeProvider</code>.{' '}
|
||||||
|
<a href="#">Ein Link</a>
|
||||||
|
</p>
|
||||||
|
<div className="flex gap-2">
|
||||||
|
<Button variant="primary" icon={<Plus size={16} strokeWidth={2.25} />}>
|
||||||
|
Neue Aufgabe
|
||||||
|
</Button>
|
||||||
|
<Button>Abbrechen</Button>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A nested scope overrides the toolbar theme for its subtree. */
|
||||||
|
export const Verschachtelt: Story = {
|
||||||
|
render: (args) => (
|
||||||
|
<div className="grid grid-cols-[repeat(auto-fit,minmax(320px,1fr))] gap-6">
|
||||||
|
<Sample />
|
||||||
|
<ThemeProvider {...args} className="rounded-[20px] bg-app p-4">
|
||||||
|
<Sample />
|
||||||
|
</ThemeProvider>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import { forwardRef, useCallback, useState, type CSSProperties, type HTMLAttributes } from 'react';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { PortalContainerContext } from '../../lib/portal';
|
||||||
|
|
||||||
|
export type Theme = 'dark' | 'light';
|
||||||
|
export type Tint = 'off' | 'subtle' | 'strong';
|
||||||
|
|
||||||
|
export interface ThemeProviderProps extends HTMLAttributes<HTMLDivElement> {
|
||||||
|
/** Color theme. */
|
||||||
|
theme?: Theme;
|
||||||
|
/** Accent color for buttons, links and highlights. */
|
||||||
|
accent?: string;
|
||||||
|
/** Mix a hint of the accent into neutral greys ("Neutraltöne einfärben"). */
|
||||||
|
tint?: Tint;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets up a Collabry theme scope. Every component must render inside one;
|
||||||
|
* scopes can be nested (e.g. a light preview inside a dark page). Dialogs, menus
|
||||||
|
* and popovers opened inside portal into this element, so they share its theme.
|
||||||
|
*/
|
||||||
|
export const ThemeProvider = forwardRef<HTMLDivElement, ThemeProviderProps>(function ThemeProvider(
|
||||||
|
{ theme = 'dark', accent = '#6A5FCB', tint = 'off', className, style, children, ...props },
|
||||||
|
ref,
|
||||||
|
) {
|
||||||
|
const [el, setEl] = useState<HTMLDivElement | null>(null);
|
||||||
|
const setRefs = useCallback(
|
||||||
|
(node: HTMLDivElement | null) => {
|
||||||
|
setEl(node);
|
||||||
|
if (typeof ref === 'function') ref(node);
|
||||||
|
else if (ref) ref.current = node;
|
||||||
|
},
|
||||||
|
[ref],
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={setRefs}
|
||||||
|
data-cl-theme={theme}
|
||||||
|
data-cl-tint={tint === 'off' ? undefined : tint}
|
||||||
|
className={cn('font-sans text-base text-fg', className)}
|
||||||
|
style={{ '--cl-acc': accent, ...style } as CSSProperties}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<PortalContainerContext.Provider value={el}>{children}</PortalContainerContext.Provider>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { fn } from '@storybook/test';
|
||||||
|
import { Button } from '../Button/Button';
|
||||||
|
import { Toast, Toaster, toast } from './Toast';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Toast> = {
|
||||||
|
title: 'Overlays/Toast',
|
||||||
|
component: Toast,
|
||||||
|
args: { message: 'Aufgabe gelöscht', onUndo: fn(), onClose: fn() },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj<typeof Toast>;
|
||||||
|
|
||||||
|
export const MitRueckgaengig: Story = { name: 'Mit Rückgängig' };
|
||||||
|
|
||||||
|
export const Einfach: Story = {
|
||||||
|
args: { message: 'Aufgabe erstellt', onUndo: undefined },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Ausloesen: Story = {
|
||||||
|
name: 'Auslösen mit toast()',
|
||||||
|
render: (args) => (
|
||||||
|
<div className="h-[200px]">
|
||||||
|
<Button variant="danger-outline" onClick={() => toast('Aufgabe gelöscht', { onUndo: args.onUndo })}>
|
||||||
|
Aufgabe löschen
|
||||||
|
</Button>
|
||||||
|
<Toaster />
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
import type { ComponentProps, ReactNode } from 'react';
|
||||||
|
import { CheckCircle2, X } from 'lucide-react';
|
||||||
|
import { toast as sonner } from 'sonner';
|
||||||
|
import { cn } from '../../lib/cn';
|
||||||
|
import { Toaster as UiToaster } from '../ui/sonner';
|
||||||
|
|
||||||
|
export interface ToastProps {
|
||||||
|
message: ReactNode;
|
||||||
|
/** Shows a "Rückgängig" action. */
|
||||||
|
onUndo?: () => void;
|
||||||
|
undoLabel?: string;
|
||||||
|
onClose?: () => void;
|
||||||
|
className?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Confirmation snackbar, e.g. "Aufgabe gelöscht · Rückgängig". Usually shown with `toast()`. */
|
||||||
|
export function Toast({ message, onUndo, undoLabel = 'Rückgängig', onClose, className }: ToastProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
role="status"
|
||||||
|
className={cn(
|
||||||
|
'inline-flex items-center gap-2.5 rounded-xl border border-line-strong bg-elevated py-2.5 pr-2.5 pl-3.5 text-base font-bold text-fg shadow-toast',
|
||||||
|
className,
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<CheckCircle2 size={16} strokeWidth={2.5} aria-hidden="true" className="flex-none text-success-fg" />
|
||||||
|
{message}
|
||||||
|
{onUndo && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onUndo}
|
||||||
|
className="h-7 rounded-[7px] px-2.5 text-sm font-bold text-accent-fg hover:bg-hover hover:text-accent-fg-hover"
|
||||||
|
>
|
||||||
|
{undoLabel}
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{onClose && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={onClose}
|
||||||
|
aria-label="Hinweis schließen"
|
||||||
|
className="flex h-7 w-7 items-center justify-center rounded-[7px] text-fg-subtle hover:bg-hover hover:text-fg"
|
||||||
|
>
|
||||||
|
<X size={14} strokeWidth={1.75} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Renders queued toasts at the bottom center. Mount once inside the `ThemeProvider`. */
|
||||||
|
export function Toaster(props: ComponentProps<typeof UiToaster>) {
|
||||||
|
return <UiToaster position="bottom-center" offset={24} {...props} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ShowToastOptions extends Pick<ToastProps, 'onUndo' | 'undoLabel'> {
|
||||||
|
/** ms until it hides; default 4000. */
|
||||||
|
duration?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Shows a `Toast` in the `Toaster`. Returns its id, for `dismissToast`. */
|
||||||
|
export function toast(message: ReactNode, { onUndo, undoLabel, duration }: ShowToastOptions = {}) {
|
||||||
|
return sonner.custom(
|
||||||
|
(id) => (
|
||||||
|
<Toast
|
||||||
|
message={message}
|
||||||
|
undoLabel={undoLabel}
|
||||||
|
onUndo={
|
||||||
|
onUndo &&
|
||||||
|
(() => {
|
||||||
|
onUndo();
|
||||||
|
sonner.dismiss(id);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onClose={() => sonner.dismiss(id)}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
// Center the snackbar in Sonner's fixed-width slot.
|
||||||
|
{ duration, className: 'flex w-full justify-center' },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dismissToast = (id?: string | number) => sonner.dismiss(id);
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { usePortalContainer } from "@/lib/portal"
|
||||||
|
import { AlertDialog as AlertDialogPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { Button } from "@/components/ui/button"
|
||||||
|
|
||||||
|
function AlertDialog(props: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
|
||||||
|
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogTrigger(props: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>) {
|
||||||
|
return <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogOverlay({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>) {
|
||||||
|
return (
|
||||||
|
<AlertDialogPrimitive.Overlay
|
||||||
|
data-slot="alert-dialog-overlay"
|
||||||
|
className={cn("fixed inset-0 z-[60] bg-scrim data-[state=open]:animate-fade-in", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogContent({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<AlertDialogPrimitive.Portal container={usePortalContainer()}>
|
||||||
|
<AlertDialogOverlay />
|
||||||
|
<AlertDialogPrimitive.Content
|
||||||
|
data-slot="alert-dialog-content"
|
||||||
|
className={cn(
|
||||||
|
"fixed top-[20vh] left-1/2 z-[61] box-border max-w-[calc(100vw-32px)] -translate-x-1/2 rounded-2xl border border-line-strong bg-raised text-fg shadow-[0_24px_64px_-12px_var(--cl-sh-85)] outline-none data-[state=open]:animate-panel-in",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</AlertDialogPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return <div data-slot="alert-dialog-header" className={cn("px-[22px] pt-5 pb-4", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="alert-dialog-footer"
|
||||||
|
className={cn("flex justify-end gap-2.5 border-t border-line-divider px-[22px] py-3.5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogTitle({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
|
||||||
|
return (
|
||||||
|
<AlertDialogPrimitive.Title data-slot="alert-dialog-title" className={cn("m-0 text-lg font-bold", className)} {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogDescription({ className, ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<AlertDialogPrimitive.Description
|
||||||
|
data-slot="alert-dialog-description"
|
||||||
|
className={cn("mt-1.5 mb-0 text-sm leading-normal text-fg-muted", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogAction({
|
||||||
|
variant = "danger",
|
||||||
|
size,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Action> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
||||||
|
return (
|
||||||
|
<Button variant={variant} size={size} asChild>
|
||||||
|
<AlertDialogPrimitive.Action data-slot="alert-dialog-action" {...props} />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AlertDialogCancel({
|
||||||
|
variant = "secondary",
|
||||||
|
size,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof AlertDialogPrimitive.Cancel> & Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
|
||||||
|
return (
|
||||||
|
<Button variant={variant} size={size} asChild>
|
||||||
|
<AlertDialogPrimitive.Cancel data-slot="alert-dialog-cancel" {...props} />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogOverlay,
|
||||||
|
AlertDialogTitle,
|
||||||
|
AlertDialogTrigger,
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Avatar as AvatarPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
function Avatar({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<AvatarPrimitive.Root
|
||||||
|
data-slot="avatar"
|
||||||
|
className={cn("relative inline-flex size-8 flex-none overflow-hidden rounded-full select-none", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AvatarImage({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Image>) {
|
||||||
|
return (
|
||||||
|
<AvatarPrimitive.Image data-slot="avatar-image" className={cn("size-full object-cover", className)} {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function AvatarFallback({ className, ...props }: React.ComponentProps<typeof AvatarPrimitive.Fallback>) {
|
||||||
|
return (
|
||||||
|
<AvatarPrimitive.Fallback
|
||||||
|
data-slot="avatar-fallback"
|
||||||
|
className={cn("flex size-full items-center justify-center rounded-full bg-chip font-black text-on-color", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Avatar, AvatarImage, AvatarFallback }
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Slot } from "radix-ui"
|
||||||
|
|
||||||
|
/** Badge shapes; colors come from the caller. */
|
||||||
|
const badgeVariants = cva("inline-flex w-fit shrink-0 items-center whitespace-nowrap", {
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
/** Task status tag, 22px, outlined. */
|
||||||
|
status: "h-[22px] rounded-md border px-[9px] text-xs font-bold",
|
||||||
|
/** Count pill next to headings. */
|
||||||
|
count: "h-5 rounded-full px-[7px] text-xs tabular-nums",
|
||||||
|
/** Small role tag, e.g. "Admin". */
|
||||||
|
tag: "h-5 rounded-full px-2 text-2xs font-bold",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "status",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
function Badge({
|
||||||
|
className,
|
||||||
|
variant,
|
||||||
|
asChild = false,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
||||||
|
const Comp = asChild ? Slot.Root : "span"
|
||||||
|
return <Comp data-slot="badge" data-variant={variant} className={cn(badgeVariants({ variant }), className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Badge, badgeVariants }
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Slot } from "radix-ui"
|
||||||
|
|
||||||
|
const buttonVariants = cva(
|
||||||
|
"relative inline-flex flex-none items-center justify-center font-bold whitespace-nowrap select-none transition-[filter,background-color,border-color,color] duration-100 outline-none focus-visible:shadow-focus [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
primary:
|
||||||
|
"border border-accent-deep bg-accent-gradient text-on-accent shadow-primary text-shadow-primary hover:brightness-110",
|
||||||
|
secondary:
|
||||||
|
"border border-line-strong bg-secondary-gradient text-fg-3 shadow-bevel hover:border-line-hover hover:text-fg-strong",
|
||||||
|
ghost: "border border-transparent bg-transparent text-fg-muted hover:bg-hover hover:text-fg",
|
||||||
|
danger: "border border-danger-solid-line bg-danger-solid text-on-accent hover:brightness-110",
|
||||||
|
"danger-outline":
|
||||||
|
"border border-line-danger-strong bg-transparent text-danger-fg hover:bg-[rgba(251,113,133,0.1)] hover:text-danger-fg",
|
||||||
|
},
|
||||||
|
// Heights from the design: 28 (row actions), 32, 36 (dialogs), 40 (page actions), 44 (auth forms).
|
||||||
|
size: {
|
||||||
|
xs: "h-7 gap-1.5 rounded-md px-2.5 text-sm",
|
||||||
|
sm: "h-8 gap-1.5 rounded-lg px-3 text-sm",
|
||||||
|
md: "h-9 gap-2 rounded-[10px] px-3.5 text-sm",
|
||||||
|
lg: "h-10 gap-2 rounded-[10px] px-4 text-base",
|
||||||
|
xl: "h-11 gap-2 rounded-[10px] px-5 text-base",
|
||||||
|
},
|
||||||
|
/** Square button with only an icon; pass `aria-label`. */
|
||||||
|
iconOnly: { true: "aspect-square px-0", false: "" },
|
||||||
|
fullWidth: { true: "w-full", false: "" },
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "secondary",
|
||||||
|
size: "md",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type ButtonProps = React.ComponentPropsWithoutRef<"button"> &
|
||||||
|
VariantProps<typeof buttonVariants> & {
|
||||||
|
asChild?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
||||||
|
{ className, variant, size, iconOnly, fullWidth, asChild = false, ...props },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
const Comp = asChild ? Slot.Root : "button"
|
||||||
|
return (
|
||||||
|
<Comp
|
||||||
|
ref={ref}
|
||||||
|
data-slot="button"
|
||||||
|
data-variant={variant}
|
||||||
|
data-size={size}
|
||||||
|
className={cn(buttonVariants({ variant, size, iconOnly, fullWidth }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export { Button, buttonVariants, type ButtonProps }
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Slot } from "radix-ui"
|
||||||
|
|
||||||
|
/** The raised inner surface of a Collabry card. */
|
||||||
|
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="card"
|
||||||
|
className={cn("box-border flex min-w-0 flex-auto flex-col rounded-[13px] border border-line bg-surface text-fg", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="card-header"
|
||||||
|
className={cn("flex min-h-7 flex-wrap items-center justify-between gap-3", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Pass `asChild` to render a heading element. */
|
||||||
|
function CardTitle({ className, asChild = false, ...props }: React.ComponentProps<"div"> & { asChild?: boolean }) {
|
||||||
|
const Comp = asChild ? Slot.Root : "div"
|
||||||
|
return <Comp data-slot="card-title" className={cn("m-0 text-md font-bold", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return <div data-slot="card-description" className={cn("text-sm text-fg-subtle", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return <div data-slot="card-action" className={cn("flex items-center gap-3", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return <div data-slot="card-footer" className={cn("mt-auto flex pt-1", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription }
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { CheckIcon } from "lucide-react"
|
||||||
|
import { Checkbox as CheckboxPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
const Checkbox = React.forwardRef<
|
||||||
|
HTMLButtonElement,
|
||||||
|
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
|
||||||
|
>(function Checkbox({ className, ...props }, ref) {
|
||||||
|
return (
|
||||||
|
<CheckboxPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
data-slot="checkbox"
|
||||||
|
className={cn(
|
||||||
|
"peer box-border flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-line-control bg-raised text-on-accent shadow-bevel outline-none transition-colors focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-accent data-[state=checked]:bg-accent",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="flex">
|
||||||
|
<CheckIcon size={12} strokeWidth={3.5} aria-hidden="true" />
|
||||||
|
</CheckboxPrimitive.Indicator>
|
||||||
|
</CheckboxPrimitive.Root>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export { Checkbox }
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { Command as CommandPrimitive } from "cmdk"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { SearchIcon } from "lucide-react"
|
||||||
|
|
||||||
|
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog"
|
||||||
|
|
||||||
|
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
|
||||||
|
return (
|
||||||
|
<CommandPrimitive
|
||||||
|
data-slot="command"
|
||||||
|
className={cn("flex h-full w-full flex-col overflow-hidden text-fg", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommandDialog({
|
||||||
|
title = "Suche",
|
||||||
|
description = "Suche nach Aufgaben, Gruppen, Seiten und Aktionen.",
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
commandProps,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof Dialog> & {
|
||||||
|
title?: string
|
||||||
|
description?: string
|
||||||
|
className?: string
|
||||||
|
commandProps?: React.ComponentProps<typeof CommandPrimitive>
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Dialog {...props}>
|
||||||
|
<DialogContent
|
||||||
|
showCloseButton={false}
|
||||||
|
className={cn("top-[12vh] flex w-[640px] flex-col overflow-hidden", className)}
|
||||||
|
>
|
||||||
|
<DialogTitle className="sr-only">{title}</DialogTitle>
|
||||||
|
<DialogDescription className="sr-only">{description}</DialogDescription>
|
||||||
|
<Command {...commandProps}>{children}</Command>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Search row. `children` render after the input, e.g. an "Esc" button. */
|
||||||
|
function CommandInput({ className, children, ...props }: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="command-input-wrapper"
|
||||||
|
className="flex h-14 items-center gap-3 border-b border-line-divider pr-3 pl-[18px]"
|
||||||
|
>
|
||||||
|
<SearchIcon size={18} strokeWidth={1.75} aria-hidden="true" className="flex-none text-fg-subtle" />
|
||||||
|
<CommandPrimitive.Input
|
||||||
|
data-slot="command-input"
|
||||||
|
className={cn(
|
||||||
|
"h-full min-w-0 flex-auto border-0 bg-transparent text-[16px] text-fg outline-none placeholder:text-fg-subtle",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
|
||||||
|
return (
|
||||||
|
<CommandPrimitive.List
|
||||||
|
data-slot="command-list"
|
||||||
|
className={cn("max-h-[420px] scroll-py-1 overflow-y-auto px-2 pt-1.5 pb-2", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommandEmpty({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
||||||
|
return (
|
||||||
|
<CommandPrimitive.Empty
|
||||||
|
data-slot="command-empty"
|
||||||
|
className={cn("px-4 py-9 text-center text-fg-subtle", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommandGroup({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
||||||
|
return (
|
||||||
|
<CommandPrimitive.Group
|
||||||
|
data-slot="command-group"
|
||||||
|
className={cn(
|
||||||
|
"[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pt-2.5 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-bold [&_[cmdk-group-heading]]:text-fg-subtle",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
||||||
|
return (
|
||||||
|
<CommandPrimitive.Item
|
||||||
|
data-slot="command-item"
|
||||||
|
className={cn(
|
||||||
|
"group/item box-border flex min-h-11 w-full cursor-pointer items-center gap-3 rounded-[10px] px-2.5 py-1.5 text-base outline-none select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-option-active",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Command, CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem }
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { usePortalContainer } from "@/lib/portal"
|
||||||
|
import { XIcon } from "lucide-react"
|
||||||
|
import { Dialog as DialogPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { buttonVariants } from "@/components/ui/button"
|
||||||
|
|
||||||
|
function Dialog(props: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
||||||
|
return <DialogPrimitive.Root data-slot="dialog" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTrigger(props: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
||||||
|
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogPortal(props: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
||||||
|
return <DialogPrimitive.Portal data-slot="dialog-portal" container={usePortalContainer()} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogClose(props: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
||||||
|
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Dimmed, blurred backdrop. */
|
||||||
|
function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Overlay
|
||||||
|
data-slot="dialog-overlay"
|
||||||
|
className={cn("fixed inset-0 z-[60] bg-scrim backdrop-blur-[6px] data-[state=open]:animate-fade-in", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Close button in the design's ghost style. */
|
||||||
|
const closeButtonClass = cn(buttonVariants({ variant: "ghost", size: "sm", iconOnly: true }), "text-fg-subtle")
|
||||||
|
|
||||||
|
function DialogContent({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
showCloseButton = true,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
||||||
|
showCloseButton?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<DialogPortal>
|
||||||
|
<DialogOverlay />
|
||||||
|
<DialogPrimitive.Content
|
||||||
|
data-slot="dialog-content"
|
||||||
|
className={cn(
|
||||||
|
"fixed top-[10vh] left-1/2 z-[61] box-border max-w-[calc(100vw-32px)] -translate-x-1/2 rounded-2xl border border-line-strong bg-raised text-fg shadow-dialog outline-none data-[state=open]:animate-panel-in",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
{showCloseButton && (
|
||||||
|
<DialogPrimitive.Close data-slot="dialog-close" aria-label="Schließen" className={cn(closeButtonClass, "absolute top-5 right-4")}>
|
||||||
|
<XIcon size={16} strokeWidth={1.75} />
|
||||||
|
</DialogPrimitive.Close>
|
||||||
|
)}
|
||||||
|
</DialogPrimitive.Content>
|
||||||
|
</DialogPortal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return <div data-slot="dialog-header" className={cn("flex flex-col gap-1", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="dialog-footer"
|
||||||
|
className={cn("flex justify-end gap-2.5 border-t border-line-divider px-[22px] py-3.5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
||||||
|
return <DialogPrimitive.Title data-slot="dialog-title" className={cn("m-0 text-lg font-bold", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<DialogPrimitive.Description
|
||||||
|
data-slot="dialog-description"
|
||||||
|
className={cn("m-0 text-sm text-fg-subtle", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
Dialog,
|
||||||
|
DialogClose,
|
||||||
|
DialogContent,
|
||||||
|
DialogDescription,
|
||||||
|
DialogFooter,
|
||||||
|
DialogHeader,
|
||||||
|
DialogOverlay,
|
||||||
|
DialogPortal,
|
||||||
|
DialogTitle,
|
||||||
|
DialogTrigger,
|
||||||
|
closeButtonClass,
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { usePortalContainer } from "@/lib/portal"
|
||||||
|
import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
function DropdownMenu(props: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
|
||||||
|
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuTrigger(props: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
|
||||||
|
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuContent({
|
||||||
|
className,
|
||||||
|
sideOffset = 6,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuPrimitive.Portal container={usePortalContainer()}>
|
||||||
|
<DropdownMenuPrimitive.Content
|
||||||
|
data-slot="dropdown-menu-content"
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"z-50 box-border flex max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) flex-col overflow-y-auto rounded-xl border border-line-strong bg-raised p-1.5 text-fg shadow-dropdown outline-none data-[state=open]:animate-panel-in",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</DropdownMenuPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuGroup(props: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
|
||||||
|
return <DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuItem({
|
||||||
|
className,
|
||||||
|
variant = "default",
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
|
||||||
|
variant?: "default" | "destructive"
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuPrimitive.Item
|
||||||
|
data-slot="dropdown-menu-item"
|
||||||
|
data-variant={variant}
|
||||||
|
className={cn(
|
||||||
|
"relative flex h-[38px] w-full cursor-pointer items-center gap-2.5 rounded-lg px-2.5 text-left text-base text-fg-2 outline-none select-none focus:bg-hover-menu focus:text-fg-strong data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[variant=destructive]:text-danger-fg data-[variant=destructive]:focus:text-danger-fg [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuLabel({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Label>) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuPrimitive.Label
|
||||||
|
data-slot="dropdown-menu-label"
|
||||||
|
className={cn("flex items-center gap-2.5 pt-2 pr-1 pb-2.5 pl-2", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function DropdownMenuSeparator({ className, ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
|
||||||
|
return (
|
||||||
|
<DropdownMenuPrimitive.Separator
|
||||||
|
data-slot="dropdown-menu-separator"
|
||||||
|
className={cn("mx-1 my-[5px] h-px bg-chip", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuGroup,
|
||||||
|
DropdownMenuLabel,
|
||||||
|
DropdownMenuItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
|
||||||
|
/** Shared look of text inputs, textareas and selects. */
|
||||||
|
const fieldClass =
|
||||||
|
"box-border w-full min-w-0 rounded-[10px] border border-line bg-inset text-base text-fg font-[inherit] transition-[border-color,box-shadow] duration-100 outline-none placeholder:text-fg-subtle focus:border-accent-focus focus:shadow-focus disabled:opacity-50 aria-invalid:border-danger-fg"
|
||||||
|
|
||||||
|
const Input = React.forwardRef<HTMLInputElement, React.ComponentPropsWithoutRef<"input">>(function Input(
|
||||||
|
{ className, type, ...props },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return <input ref={ref} type={type} data-slot="input" className={cn(fieldClass, "h-[38px] px-3", className)} {...props} />
|
||||||
|
})
|
||||||
|
|
||||||
|
export { Input, fieldClass }
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
|
||||||
|
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
|
||||||
|
return (
|
||||||
|
<kbd
|
||||||
|
data-slot="kbd"
|
||||||
|
className={cn(
|
||||||
|
"box-border inline-flex h-[22px] min-w-[22px] items-center justify-center rounded-[5px] border border-line-heavy bg-elevated px-[5px] font-sans text-xs text-fg-muted select-none",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Kbd }
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Label as LabelPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
function Label({ className, ...props }: React.ComponentProps<typeof LabelPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<LabelPrimitive.Root
|
||||||
|
data-slot="label"
|
||||||
|
className={cn("select-none peer-disabled:cursor-not-allowed peer-disabled:opacity-50", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Label }
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { ChevronDownIcon } from "lucide-react"
|
||||||
|
import { fieldClass } from "@/components/ui/input"
|
||||||
|
|
||||||
|
const heights = { md: "h-[38px]", lg: "h-[42px]", settings: "h-10" }
|
||||||
|
|
||||||
|
type NativeSelectProps = Omit<React.ComponentPropsWithoutRef<"select">, "size"> & {
|
||||||
|
/** 38px (filters, dialogs), 42px (auth forms) or 40px (settings rows). */
|
||||||
|
size?: keyof typeof heights
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Native select with the design's chevron. `className` sizes the wrapper. */
|
||||||
|
const NativeSelect = React.forwardRef<HTMLSelectElement, NativeSelectProps>(function NativeSelect(
|
||||||
|
{ className, size = "md", ...props },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<span data-slot="native-select-wrapper" className={cn("relative flex", className)}>
|
||||||
|
<select
|
||||||
|
ref={ref}
|
||||||
|
data-slot="native-select"
|
||||||
|
data-size={size}
|
||||||
|
className={cn(fieldClass, heights[size], "cursor-pointer appearance-none pr-8 pl-3")}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
<ChevronDownIcon
|
||||||
|
size={16}
|
||||||
|
strokeWidth={1.75}
|
||||||
|
aria-hidden="true"
|
||||||
|
data-slot="native-select-icon"
|
||||||
|
className="pointer-events-none absolute top-1/2 right-2.5 -translate-y-1/2 text-fg-subtle"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
function NativeSelectOption(props: React.ComponentProps<"option">) {
|
||||||
|
return <option data-slot="native-select-option" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export { NativeSelect, NativeSelectOption }
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { usePortalContainer } from "@/lib/portal"
|
||||||
|
import { Popover as PopoverPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
function Popover(props: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
||||||
|
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverTrigger(props: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
||||||
|
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Positioned layer without a surface of its own: the content brings its panel (e.g. `NotificationPanel`). */
|
||||||
|
function PopoverContent({
|
||||||
|
className,
|
||||||
|
align = "center",
|
||||||
|
sideOffset = 6,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<PopoverPrimitive.Portal container={usePortalContainer()}>
|
||||||
|
<PopoverPrimitive.Content
|
||||||
|
data-slot="popover-content"
|
||||||
|
align={align}
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
"z-50 origin-(--radix-popover-content-transform-origin) text-fg outline-none data-[state=open]:animate-panel-in",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</PopoverPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverAnchor(props: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
||||||
|
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverClose(props: React.ComponentProps<typeof PopoverPrimitive.Close>) {
|
||||||
|
return <PopoverPrimitive.Close data-slot="popover-close" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor, PopoverClose }
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Progress as ProgressPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
/** Thin track. Set `--progress-fill` to color the bar (defaults to the accent). */
|
||||||
|
function Progress({ className, value, ...props }: React.ComponentProps<typeof ProgressPrimitive.Root>) {
|
||||||
|
return (
|
||||||
|
<ProgressPrimitive.Root
|
||||||
|
data-slot="progress"
|
||||||
|
value={value}
|
||||||
|
className={cn("relative h-1.5 w-full overflow-hidden rounded-full bg-track", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ProgressPrimitive.Indicator
|
||||||
|
data-slot="progress-indicator"
|
||||||
|
className="h-full w-full rounded-full bg-[var(--progress-fill,var(--cl-accent))] transition-transform"
|
||||||
|
style={{ transform: `translateX(-${100 - (value || 0)}%)` }}
|
||||||
|
/>
|
||||||
|
</ProgressPrimitive.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Progress }
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { RadioGroup as RadioGroupPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
function RadioGroup({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {
|
||||||
|
return <RadioGroupPrimitive.Root data-slot="radio-group" className={cn("grid gap-3", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A radio with custom content (cards, swatches). Style checked state with `data-[state=checked]:`. */
|
||||||
|
function RadioGroupItem({ className, ...props }: React.ComponentProps<typeof RadioGroupPrimitive.Item>) {
|
||||||
|
return (
|
||||||
|
<RadioGroupPrimitive.Item
|
||||||
|
data-slot="radio-group-item"
|
||||||
|
className={cn("outline-none focus-visible:shadow-focus disabled:cursor-not-allowed disabled:opacity-50", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { RadioGroup, RadioGroupItem }
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { usePortalContainer } from "@/lib/portal"
|
||||||
|
import { XIcon } from "lucide-react"
|
||||||
|
import { Dialog as SheetPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { closeButtonClass } from "@/components/ui/dialog"
|
||||||
|
|
||||||
|
function Sheet(props: React.ComponentProps<typeof SheetPrimitive.Root>) {
|
||||||
|
return <SheetPrimitive.Root data-slot="sheet" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetTrigger(props: React.ComponentProps<typeof SheetPrimitive.Trigger>) {
|
||||||
|
return <SheetPrimitive.Trigger data-slot="sheet-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetClose(props: React.ComponentProps<typeof SheetPrimitive.Close>) {
|
||||||
|
return <SheetPrimitive.Close data-slot="sheet-close" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetOverlay({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Overlay>) {
|
||||||
|
return (
|
||||||
|
<SheetPrimitive.Overlay
|
||||||
|
data-slot="sheet-overlay"
|
||||||
|
className={cn("fixed inset-0 z-[45] bg-scrim backdrop-blur-[4px] data-[state=open]:animate-fade-in", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Floating side sheet that slides in from the right. */
|
||||||
|
function SheetContent({
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
showCloseButton = true,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
|
||||||
|
showCloseButton?: boolean
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<SheetPrimitive.Portal container={usePortalContainer()}>
|
||||||
|
<SheetOverlay />
|
||||||
|
<SheetPrimitive.Content
|
||||||
|
data-slot="sheet-content"
|
||||||
|
className={cn(
|
||||||
|
"fixed top-2 right-2 bottom-2 z-50 box-border flex max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-2xl border border-line-strong bg-raised text-fg shadow-popover outline-none data-[state=open]:animate-drawer-in",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
{showCloseButton && (
|
||||||
|
<SheetPrimitive.Close aria-label="Schließen" className={cn(closeButtonClass, "absolute top-3 right-3")}>
|
||||||
|
<XIcon size={16} strokeWidth={1.75} />
|
||||||
|
</SheetPrimitive.Close>
|
||||||
|
)}
|
||||||
|
</SheetPrimitive.Content>
|
||||||
|
</SheetPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetHeader({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="sheet-header"
|
||||||
|
className={cn("flex items-center gap-2.5 border-b border-line-divider py-3.5 pr-3 pl-5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetFooter({ className, ...props }: React.ComponentProps<"div">) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
data-slot="sheet-footer"
|
||||||
|
className={cn("border-t border-line-divider bg-surface px-3.5 pt-3 pb-3.5", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetTitle({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Title>) {
|
||||||
|
return <SheetPrimitive.Title data-slot="sheet-title" className={cn("m-0 font-bold", className)} {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function SheetDescription({ className, ...props }: React.ComponentProps<typeof SheetPrimitive.Description>) {
|
||||||
|
return (
|
||||||
|
<SheetPrimitive.Description data-slot="sheet-description" className={cn("text-sm text-fg-subtle", className)} {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Sheet, SheetTrigger, SheetClose, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription }
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { Toaster as Sonner, type ToasterProps } from "sonner"
|
||||||
|
|
||||||
|
/** Sonner toaster themed with Collabry tokens. Render it inside a `ThemeProvider`. */
|
||||||
|
const Toaster = (props: ToasterProps) => {
|
||||||
|
return (
|
||||||
|
<Sonner
|
||||||
|
className="toaster group"
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--normal-bg": "var(--cl-elevated)",
|
||||||
|
"--normal-text": "var(--cl-fg)",
|
||||||
|
"--normal-border": "var(--cl-line-strong)",
|
||||||
|
"--border-radius": "12px",
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Toaster }
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { fieldClass } from "@/components/ui/input"
|
||||||
|
|
||||||
|
const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentPropsWithoutRef<"textarea">>(function Textarea(
|
||||||
|
{ className, ...props },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
|
return (
|
||||||
|
<textarea
|
||||||
|
ref={ref}
|
||||||
|
data-slot="textarea"
|
||||||
|
className={cn(fieldClass, "resize-y px-3 py-2.5 leading-normal", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
export { Textarea }
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { type VariantProps } from "class-variance-authority"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { ToggleGroup as ToggleGroupPrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
import { toggleVariants } from "@/components/ui/toggle"
|
||||||
|
|
||||||
|
const ToggleGroupContext = React.createContext<VariantProps<typeof toggleVariants>>({})
|
||||||
|
|
||||||
|
function ToggleGroup({
|
||||||
|
className,
|
||||||
|
variant,
|
||||||
|
size,
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ToggleGroupPrimitive.Root> & VariantProps<typeof toggleVariants>) {
|
||||||
|
return (
|
||||||
|
<ToggleGroupPrimitive.Root
|
||||||
|
data-slot="toggle-group"
|
||||||
|
data-variant={variant}
|
||||||
|
data-size={size}
|
||||||
|
className={cn("group/toggle-group flex items-center", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ToggleGroupContext.Provider value={{ variant, size }}>{children}</ToggleGroupContext.Provider>
|
||||||
|
</ToggleGroupPrimitive.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ToggleGroupItem({
|
||||||
|
className,
|
||||||
|
variant,
|
||||||
|
size,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof ToggleGroupPrimitive.Item> & VariantProps<typeof toggleVariants>) {
|
||||||
|
const context = React.useContext(ToggleGroupContext)
|
||||||
|
return (
|
||||||
|
<ToggleGroupPrimitive.Item
|
||||||
|
data-slot="toggle-group-item"
|
||||||
|
className={cn(toggleVariants({ variant: context.variant || variant, size: context.size || size }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { ToggleGroup, ToggleGroupItem }
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import * as React from "react"
|
||||||
|
import { cva, type VariantProps } from "class-variance-authority"
|
||||||
|
import { cn } from "@/lib/cn"
|
||||||
|
import { Toggle as TogglePrimitive } from "radix-ui"
|
||||||
|
|
||||||
|
const toggleVariants = cva(
|
||||||
|
"inline-flex items-center justify-center whitespace-nowrap outline-none focus-visible:shadow-focus disabled:pointer-events-none",
|
||||||
|
{
|
||||||
|
variants: {
|
||||||
|
variant: {
|
||||||
|
/** A segment of a segmented control. */
|
||||||
|
segment:
|
||||||
|
"box-border gap-1.5 rounded-[7px] border border-transparent bg-transparent text-sm font-bold text-fg-muted transition-colors duration-100 hover:text-fg disabled:opacity-50 data-[state=on]:border-line-heavy data-[state=on]:bg-seg-active data-[state=on]:text-fg data-[state=on]:shadow-seg",
|
||||||
|
/** Rounded filter pill. */
|
||||||
|
chip:
|
||||||
|
"h-8 gap-2 rounded-full border border-line-divider bg-transparent px-3 text-sm font-bold text-fg-subtle hover:text-fg disabled:opacity-50 data-[state=on]:border-line-heavy data-[state=on]:bg-elevated data-[state=on]:text-fg",
|
||||||
|
/** No look of its own; style the children. */
|
||||||
|
bare: "",
|
||||||
|
},
|
||||||
|
size: {
|
||||||
|
sm: "h-[30px] px-[11px]",
|
||||||
|
md: "h-8 px-[11px]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
defaultVariants: {
|
||||||
|
variant: "segment",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
function Toggle({
|
||||||
|
className,
|
||||||
|
variant,
|
||||||
|
size,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants>) {
|
||||||
|
return (
|
||||||
|
<TogglePrimitive.Root
|
||||||
|
data-slot="toggle"
|
||||||
|
className={cn(toggleVariants({ variant, size }), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Toggle, toggleVariants }
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import './styles/index.css';
|
||||||
|
|
||||||
|
export { cn } from './lib/cn';
|
||||||
|
export * from './lib/tokens';
|
||||||
|
|
||||||
|
export * from './components/ThemeProvider/ThemeProvider';
|
||||||
|
export * from './components/Spinner/Spinner';
|
||||||
|
export * from './components/Button/Button';
|
||||||
|
export * from './components/Field/Field';
|
||||||
|
export * from './components/Checkbox/Checkbox';
|
||||||
|
export * from './components/Badge/Badge';
|
||||||
|
export * from './components/Avatar/Avatar';
|
||||||
|
export * from './components/SegmentedControl/SegmentedControl';
|
||||||
|
export * from './components/Progress/Progress';
|
||||||
|
export * from './components/Card/Card';
|
||||||
|
export * from './components/Menu/Menu';
|
||||||
|
export * from './components/Dialog/Dialog';
|
||||||
|
export * from './components/Toast/Toast';
|
||||||
|
export * from './components/CommandPalette/CommandPalette';
|
||||||
|
export * from './components/Notifications/Notifications';
|
||||||
|
export * from './components/Logo/Logo';
|
||||||
|
export * from './components/Sidebar/Sidebar';
|
||||||
|
export * from './components/MobileNav/MobileNav';
|
||||||
|
export * from './components/Task/Task';
|
||||||
|
export * from './components/Group/Group';
|
||||||
|
export * from './components/Calendar/Calendar';
|
||||||
|
export * from './components/Settings/Settings';
|
||||||
|
export * from './components/Auth/Auth';
|
||||||
|
export * from './components/Comment/Comment';
|
||||||
|
export * from './components/Layout/Layout';
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { clsx, type ClassValue } from 'clsx';
|
||||||
|
import { extendTailwindMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
|
// Teach tailwind-merge the custom font-size and shadow scales, so `text-sm` vs
|
||||||
|
// `text-fg-muted` and `shadow-focus` vs `shadow-xs` resolve as intended.
|
||||||
|
const twMerge = extendTailwindMerge({
|
||||||
|
extend: {
|
||||||
|
theme: {
|
||||||
|
text: ['2xs', 'md', 'display', 'hero'],
|
||||||
|
shadow: ['popover', 'menu', 'dropdown', 'dialog', 'toast', 'seg', 'bevel', 'nav-active', 'focus', 'side', 'primary', 'primary-flat'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export function cn(...inputs: ClassValue[]) {
|
||||||
|
return twMerge(clsx(inputs));
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { createContext, useContext } from 'react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Element that overlays (dialogs, menus, popovers) portal into. `ThemeProvider`
|
||||||
|
* sets it to its own element, so portaled content keeps the theme, accent and tint.
|
||||||
|
*/
|
||||||
|
export const PortalContainerContext = createContext<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
export const usePortalContainer = () => useContext(PortalContainerContext) ?? undefined;
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/** Accent color schemes offered in "Einstellungen – Allgemein". */
|
||||||
|
export const colorSchemes = [
|
||||||
|
{ id: 'violett', name: 'Violett', color: '#6A5FCB' },
|
||||||
|
{ id: 'blau', name: 'Blau', color: '#3B6FD6' },
|
||||||
|
{ id: 'petrol', name: 'Petrol', color: '#0C7C7C' },
|
||||||
|
{ id: 'gruen', name: 'Grün', color: '#2A7D4A' },
|
||||||
|
{ id: 'bernstein', name: 'Bernstein', color: '#B4570A' },
|
||||||
|
{ id: 'rose', name: 'Rosé', color: '#C23B6E' },
|
||||||
|
{ id: 'graphit', name: 'Graphit', color: '#5E6270' },
|
||||||
|
] as const;
|
||||||
|
|
||||||
|
export type ColorSchemeId = (typeof colorSchemes)[number]['id'];
|
||||||
|
|
||||||
|
/** Swatch colors used for groups and people. */
|
||||||
|
export const swatches = {
|
||||||
|
violet: '#9D94E8',
|
||||||
|
cyan: '#22D3EE',
|
||||||
|
pink: '#F472B6',
|
||||||
|
amber: '#FBBF24',
|
||||||
|
green: '#34D399',
|
||||||
|
} as const;
|
||||||
|
|
||||||
|
export type TaskStatus = 'done' | 'review' | 'doing' | 'open';
|
||||||
|
|
||||||
|
export const taskStatusLabel: Record<TaskStatus, string> = {
|
||||||
|
done: 'Erledigt',
|
||||||
|
review: 'Review',
|
||||||
|
doing: 'In Arbeit',
|
||||||
|
open: 'Offen',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Bar/legend color per status, in display order. */
|
||||||
|
export const taskStatusOrder: TaskStatus[] = ['done', 'review', 'doing', 'open'];
|
||||||
|
export const taskStatusBar: Record<TaskStatus, string> = {
|
||||||
|
done: 'var(--cl-success)',
|
||||||
|
review: 'var(--cl-warning)',
|
||||||
|
doing: 'var(--cl-info)',
|
||||||
|
open: 'var(--cl-open-bar)',
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Priority = 'Hoch' | 'Mittel' | 'Niedrig';
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
import type { Meta, StoryObj } from '@storybook/react';
|
||||||
|
import { colorSchemes, swatches } from '../lib/tokens';
|
||||||
|
|
||||||
|
const meta: Meta = {
|
||||||
|
title: 'Grundlagen/Tokens',
|
||||||
|
parameters: { controls: { disable: true } },
|
||||||
|
};
|
||||||
|
export default meta;
|
||||||
|
|
||||||
|
type Story = StoryObj;
|
||||||
|
|
||||||
|
const groups: { title: string; tokens: string[] }[] = [
|
||||||
|
{
|
||||||
|
title: 'Flächen',
|
||||||
|
tokens: ['app', 'frame', 'surface', 'inset', 'raised', 'elevated', 'chip', 'track', 'soft', 'section', 'side', 'side-active'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Linien',
|
||||||
|
tokens: ['line-frame', 'line', 'line-strong', 'line-heavy', 'line-divider', 'line-subtle', 'line-row', 'line-control'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Text',
|
||||||
|
tokens: ['fg', 'fg-strong', 'fg-2', 'fg-3', 'fg-4', 'fg-muted', 'fg-subtle', 'fg-faint', 'fg-dim'],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Akzent & Status',
|
||||||
|
tokens: [
|
||||||
|
'accent',
|
||||||
|
'accent-fg',
|
||||||
|
'accent-focus',
|
||||||
|
'success',
|
||||||
|
'success-fg',
|
||||||
|
'warning',
|
||||||
|
'warning-fg',
|
||||||
|
'info',
|
||||||
|
'info-fg',
|
||||||
|
'danger',
|
||||||
|
'danger-fg',
|
||||||
|
'danger-solid',
|
||||||
|
'open-bar',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function Swatch({ token }: { token: string }) {
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<span
|
||||||
|
className="h-10 w-10 flex-none rounded-[10px] border border-line-strong"
|
||||||
|
style={{ background: `var(--cl-${token})` }}
|
||||||
|
/>
|
||||||
|
<div className="min-w-0">
|
||||||
|
<div className="font-bold">{token}</div>
|
||||||
|
<code className="text-xs text-fg-subtle">--cl-{token}</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Farben: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-col gap-8">
|
||||||
|
{groups.map((g) => (
|
||||||
|
<section key={g.title}>
|
||||||
|
<h2 className="mb-3 text-md font-bold">{g.title}</h2>
|
||||||
|
<div className="grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-4">
|
||||||
|
{g.tokens.map((t) => (
|
||||||
|
<Swatch key={t} token={t} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
))}
|
||||||
|
<section>
|
||||||
|
<h2 className="mb-3 text-md font-bold">Gruppen- und Personenfarben</h2>
|
||||||
|
<div className="flex flex-wrap gap-4">
|
||||||
|
{Object.entries(swatches).map(([name, color]) => (
|
||||||
|
<div key={name} className="flex items-center gap-2">
|
||||||
|
<span className="h-6 w-6 rounded-md" style={{ background: color }} />
|
||||||
|
<span className="text-sm">
|
||||||
|
{name} <code className="text-fg-subtle">{color}</code>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h2 className="mb-3 text-md font-bold">Farbschemata (Akzent)</h2>
|
||||||
|
<div className="flex flex-wrap gap-4">
|
||||||
|
{colorSchemes.map((s) => (
|
||||||
|
<div key={s.id} className="flex items-center gap-2">
|
||||||
|
<span className="h-6 w-6 rounded-full" style={{ background: s.color }} />
|
||||||
|
<span className="text-sm">
|
||||||
|
{s.name} <code className="text-fg-subtle">{s.color}</code>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
|
const type: { cls: string; label: string; sample: string }[] = [
|
||||||
|
{ cls: 'text-hero font-bold tracking-[-0.03em]', label: 'hero · 48 / 700', sample: '62%' },
|
||||||
|
{ cls: 'text-display font-black tracking-[-0.01em]', label: 'display · 28 / 900', sample: 'Hallo Niklas' },
|
||||||
|
{ cls: 'text-xl font-black', label: 'xl · 20 / 900', sample: 'Login & Registrierung umsetzen' },
|
||||||
|
{ cls: 'text-lg font-bold', label: 'lg · 17 / 700', sample: 'Neue Aufgabe' },
|
||||||
|
{ cls: 'text-md font-bold', label: 'md · 15 / 700', sample: 'Meine Aufgaben' },
|
||||||
|
{ cls: 'text-base', label: 'base · 14 / 400', sample: 'Melde dich an, um mit deinem Team weiterzuarbeiten.' },
|
||||||
|
{ cls: 'text-sm text-fg-subtle', label: 'sm · 13 / 400', sample: 'Wähle, wie Collabry für dich aussieht.' },
|
||||||
|
{ cls: 'text-xs text-fg-muted', label: 'xs · 12 / 400', sample: 'SWE · Collabry · in 3 Tagen' },
|
||||||
|
{ cls: 'text-2xs font-bold text-fg-subtle', label: '2xs · 11 / 700', sample: 'Mit ⌘ + Enter senden' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const Typografie: Story = {
|
||||||
|
render: () => (
|
||||||
|
<div className="flex flex-col gap-5">
|
||||||
|
{type.map((t) => (
|
||||||
|
<div key={t.label} className="grid grid-cols-[160px_minmax(0,1fr)] items-baseline gap-4">
|
||||||
|
<code className="text-xs text-fg-subtle">{t.label}</code>
|
||||||
|
<div className={t.cls}>{t.sample}</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
};
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Meta } from '@storybook/blocks';
|
||||||
|
|
||||||
|
<Meta title="Einführung" />
|
||||||
|
|
||||||
|
# Collabry Components
|
||||||
|
|
||||||
|
React components for the Collabry UI, built from the **Collabry UI** design canvas (dashboards, auth,
|
||||||
|
settings, groups, calendar, tasks and mobile screens). Default copy is German, as in the design; props
|
||||||
|
and code are English.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
import { ThemeProvider, Button } from '@collabry/components';
|
||||||
|
import '@collabry/components/styles.css';
|
||||||
|
// The design uses Lato 400/700/900. Load it however you like, e.g. Fontsource:
|
||||||
|
import '@fontsource/lato/400.css';
|
||||||
|
import '@fontsource/lato/700.css';
|
||||||
|
import '@fontsource/lato/900.css';
|
||||||
|
|
||||||
|
export function App() {
|
||||||
|
return (
|
||||||
|
<ThemeProvider theme="dark" accent="#6A5FCB" className="min-h-screen bg-app">
|
||||||
|
<Button variant="primary">Neue Aufgabe</Button>
|
||||||
|
</ThemeProvider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Every component must render inside a `ThemeProvider`. It sets `data-cl-theme`, the accent color and the
|
||||||
|
optional tint on its element, so theme scopes can be nested.
|
||||||
|
|
||||||
|
## Theming
|
||||||
|
|
||||||
|
Use the toolbar above the canvas to switch:
|
||||||
|
|
||||||
|
- **Design**: Dunkel / Hell
|
||||||
|
- **Farbschema**: the seven accent colors from *Einstellungen – Allgemein*
|
||||||
|
- **Tönung**: "Neutraltöne einfärben" (Aus / Leicht / Kräftig)
|
||||||
|
|
||||||
|
Tokens are CSS custom properties (`--cl-*`) exposed to Tailwind as colors, so you write
|
||||||
|
`bg-surface`, `border-line`, `text-fg-muted`, `text-accent-fg` and so on. See *Grundlagen → Farben*.
|
||||||
|
|
||||||
|
## Building blocks
|
||||||
|
|
||||||
|
The components are built on [shadcn/ui](https://ui.shadcn.com) primitives in `src/components/ui/`
|
||||||
|
(Radix UI, cmdk, Sonner), restyled to the Collabry tokens. Dialogs, menus and popovers portal into the
|
||||||
|
nearest `ThemeProvider`, so they keep its theme.
|
||||||
|
|
||||||
|
The design's signature panel is a **double frame**: a 5px dark rim (`bg-frame`) around a raised
|
||||||
|
surface (`bg-surface`). `Card` and `SettingsSection` implement it.
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
/* Sample data taken from the Collabry design, shared by the stories. */
|
||||||
|
import { useState, type ReactNode } from 'react';
|
||||||
|
import type { Person } from '../components/Avatar/Avatar';
|
||||||
|
import type { GroupData } from '../components/Group/Group';
|
||||||
|
import type { NotificationData } from '../components/Notifications/Notifications';
|
||||||
|
import type { TaskData } from '../components/Task/Task';
|
||||||
|
import { PortalContainerContext } from '../lib/portal';
|
||||||
|
import { swatches } from '../lib/tokens';
|
||||||
|
|
||||||
|
export const people = {
|
||||||
|
NH: { name: 'Niklas Haiden', initials: 'NH', color: swatches.violet },
|
||||||
|
LB: { name: 'Lena Berger', initials: 'LB', color: swatches.pink },
|
||||||
|
PM: { name: 'Philip Mai', initials: 'PM', color: swatches.cyan },
|
||||||
|
KB: { name: 'Kevin Baumgartner', initials: 'KB', color: swatches.amber },
|
||||||
|
LK: { name: 'Lukas Kammerhofer', initials: 'LK', color: swatches.green },
|
||||||
|
} satisfies Record<string, Person>;
|
||||||
|
|
||||||
|
export const me: Person & { email: string } = {
|
||||||
|
...people.NH,
|
||||||
|
email: 'niklas@beispiel.at',
|
||||||
|
image: './avatar-niklas.webp',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const groupRefs = {
|
||||||
|
swe: { name: 'SWE · Collabry', color: swatches.violet },
|
||||||
|
db: { name: 'Datenbanken Übung', color: swatches.cyan },
|
||||||
|
mk: { name: 'Marketing Seminar', color: swatches.pink },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const groups: GroupData[] = [
|
||||||
|
{
|
||||||
|
id: 'swe',
|
||||||
|
...groupRefs.swe,
|
||||||
|
members: [people.NH, people.LB, people.PM, people.KB, people.LK],
|
||||||
|
done: 9,
|
||||||
|
total: 16,
|
||||||
|
role: 'admin',
|
||||||
|
description: 'Softwareentwicklungsprojekt: Collabry als Web-App für Gruppenarbeiten.',
|
||||||
|
next: 'Abgabe Iteration 2 · Fr, 27. Nov',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'db',
|
||||||
|
...groupRefs.db,
|
||||||
|
members: [people.NH, people.PM, people.LB],
|
||||||
|
done: 4,
|
||||||
|
total: 10,
|
||||||
|
role: 'member',
|
||||||
|
description: 'Übungsgruppe für ER-Modellierung und SQL-Abfragen.',
|
||||||
|
next: 'ER-Diagramm · Mo, 2. Nov',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'mk',
|
||||||
|
...groupRefs.mk,
|
||||||
|
members: [people.NH, people.KB, people.LK],
|
||||||
|
done: 6,
|
||||||
|
total: 8,
|
||||||
|
role: 'member',
|
||||||
|
description: 'Marktanalyse und Präsentation für das Seminar.',
|
||||||
|
next: 'Präsentation · Do, 5. Nov',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const tasks: TaskData[] = [
|
||||||
|
{ id: 't1', title: 'Gruppen-Einladung per Link', group: groupRefs.swe, priority: 'Hoch', due: 'Fr, 30. Okt', overdue: true, status: 'doing', assignee: people.NH, comments: 3 },
|
||||||
|
{ id: 't2', title: 'Login & Registrierung umsetzen', group: groupRefs.swe, priority: 'Hoch', due: 'Mi, 4. Nov', status: 'doing', assignee: people.NH, comments: 1 },
|
||||||
|
{ id: 't3', title: 'ER-Diagramm finalisieren', group: groupRefs.db, priority: 'Mittel', due: 'Mo, 2. Nov', status: 'open', assignee: people.PM },
|
||||||
|
{ id: 't4', title: 'Dashboard-UI entwerfen', group: groupRefs.swe, priority: 'Mittel', due: 'Do, 5. Nov', status: 'review', assignee: people.KB, comments: 2 },
|
||||||
|
{ id: 't5', title: 'Git-Branching-Regeln dokumentieren', group: groupRefs.swe, priority: 'Niedrig', due: 'Mo, 9. Nov', status: 'open', assignee: people.LK },
|
||||||
|
{ id: 't6', title: 'Umfrage-Ergebnisse auswerten', group: groupRefs.mk, priority: 'Mittel', due: 'Mi, 11. Nov', status: 'open', assignee: people.KB },
|
||||||
|
{ id: 't7', title: 'Review Iteration 1 schreiben', group: groupRefs.swe, priority: 'Mittel', due: 'Sa, 31. Okt', status: 'done', assignee: people.LB },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const deadlines = [
|
||||||
|
{ weekday: 'MO', day: 2, title: 'ER-Diagramm finalisieren', group: groupRefs.db, when: 'morgen', soon: true },
|
||||||
|
{ weekday: 'MI', day: 4, title: 'Login & Registrierung umsetzen', group: groupRefs.swe, when: 'in 3 Tagen', soon: true },
|
||||||
|
{ weekday: 'DO', day: 5, title: 'Präsentation Marktanalyse', group: groupRefs.mk, when: 'in 4 Tagen' },
|
||||||
|
{ weekday: 'FR', day: 6, title: 'Kanban-Board: API-Endpunkte', group: groupRefs.swe, when: 'in 5 Tagen' },
|
||||||
|
{ weekday: 'MO', day: 9, title: 'Git-Branching-Regeln dokumentieren', group: groupRefs.swe, when: 'in 8 Tagen' },
|
||||||
|
{ weekday: 'MI', day: 11, title: 'Umfrage-Ergebnisse auswerten', group: groupRefs.mk, when: 'in 10 Tagen' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const notificationsToday: NotificationData[] = [
|
||||||
|
{ id: 'n1', kind: 'person', person: people.LB, actor: 'Lena Berger', verb: 'hat dir', object: '„Login & Registrierung umsetzen“', tail: ' zugewiesen.', group: groupRefs.swe, time: 'vor 12 Min.', unread: true },
|
||||||
|
{ id: 'n2', kind: 'person', person: people.PM, actor: 'Philip Mai', verb: 'hat', object: '„ER-Diagramm finalisieren“', tail: ' kommentiert:', quote: 'Kannst du die n:m-Beziehung zwischen Gruppe und Mitglied noch auflösen?', group: groupRefs.db, time: 'vor 1 Std.', unread: true },
|
||||||
|
{ id: 'n3', kind: 'person', person: people.KB, actor: 'Kevin Baumgartner', verb: 'hat dich in die Gruppe', object: '„Statistik Projekt“', tail: ' eingeladen.', time: 'Einladung · vor 2 Std.', unread: true, invite: true },
|
||||||
|
{ id: 'n4', kind: 'deadline', actor: 'Deadline morgen:', object: '„ER-Diagramm finalisieren“', tail: ' ist am Mo, 2. Nov fällig.', group: groupRefs.db, time: 'vor 3 Std.', unread: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const notificationsEarlier: NotificationData[] = [
|
||||||
|
{ id: 'n5', kind: 'person', person: people.KB, actor: 'Kevin Baumgartner', verb: 'hat', object: '„Dashboard-UI entwerfen“', tail: ' auf Review gesetzt.', group: groupRefs.swe, time: 'Gestern, 18:40' },
|
||||||
|
{ id: 'n6', kind: 'overdue', actor: 'Überfällig:', object: '„Gruppen-Einladung per Link“', tail: ' war am Fr, 30. Okt fällig.', group: groupRefs.swe, time: 'Sa, 31. Okt' },
|
||||||
|
{ id: 'n7', kind: 'person', person: people.LK, actor: 'Lukas Kammerhofer', verb: 'ist der Gruppe', object: '„Marketing Seminar“', tail: ' beigetreten.', group: groupRefs.mk, time: 'Fr, 30. Okt' },
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Box for overlay stories. Overlays portal into it, and its transform makes it the
|
||||||
|
* containing block for their `position: fixed`, so dialogs stay inside the canvas.
|
||||||
|
*/
|
||||||
|
export function Stage({ height = 560, children }: { height?: number; children: ReactNode }) {
|
||||||
|
const [el, setEl] = useState<HTMLDivElement | null>(null);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={setEl}
|
||||||
|
className="relative overflow-hidden rounded-xl border border-line-subtle bg-app [transform:translateZ(0)]"
|
||||||
|
style={{ height }}
|
||||||
|
>
|
||||||
|
<PortalContainerContext.Provider value={el}>{children}</PortalContainerContext.Provider>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/* Lato, the design's typeface. Not part of the library CSS; load it in the app (this file, Google Fonts or self-hosted). */
|
||||||
|
@import '@fontsource/lato/400.css';
|
||||||
|
@import '@fontsource/lato/700.css';
|
||||||
|
@import '@fontsource/lato/900.css';
|
||||||
@@ -0,0 +1,277 @@
|
|||||||
|
@import 'tailwindcss';
|
||||||
|
@import './tokens.css';
|
||||||
|
|
||||||
|
@source '../';
|
||||||
|
|
||||||
|
@custom-variant light (&:where([data-cl-theme='light'], [data-cl-theme='light'] *));
|
||||||
|
@custom-variant dark (&:where([data-cl-theme='dark'], [data-cl-theme='dark'] *));
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--font-sans: Lato, 'Segoe UI', system-ui, sans-serif;
|
||||||
|
|
||||||
|
--text-2xs: 11px;
|
||||||
|
--text-2xs--line-height: 1.3;
|
||||||
|
--text-xs: 12px;
|
||||||
|
--text-xs--line-height: 1.3;
|
||||||
|
--text-sm: 13px;
|
||||||
|
--text-sm--line-height: 1.45;
|
||||||
|
--text-base: 14px;
|
||||||
|
--text-base--line-height: 1.45;
|
||||||
|
--text-md: 15px;
|
||||||
|
--text-md--line-height: 1.3;
|
||||||
|
--text-lg: 17px;
|
||||||
|
--text-lg--line-height: 1.3;
|
||||||
|
--text-xl: 20px;
|
||||||
|
--text-xl--line-height: 1.3;
|
||||||
|
--text-display: 28px;
|
||||||
|
--text-display--line-height: 1.2;
|
||||||
|
--text-hero: 48px;
|
||||||
|
--text-hero--line-height: 1;
|
||||||
|
|
||||||
|
--color-accent: var(--cl-accent);
|
||||||
|
--color-accent-fg: var(--cl-accent-fg);
|
||||||
|
--color-accent-fg-hover: var(--cl-accent-fg-hover);
|
||||||
|
--color-accent-focus: var(--cl-accent-focus);
|
||||||
|
--color-accent-ring: var(--cl-accent-ring);
|
||||||
|
--color-accent-soft: var(--cl-accent-soft);
|
||||||
|
--color-accent-chip: var(--cl-accent-chip);
|
||||||
|
|
||||||
|
--color-app: var(--cl-app);
|
||||||
|
--color-frame: var(--cl-frame);
|
||||||
|
--color-surface: var(--cl-surface);
|
||||||
|
--color-inset: var(--cl-inset);
|
||||||
|
--color-raised: var(--cl-raised);
|
||||||
|
--color-elevated: var(--cl-elevated);
|
||||||
|
--color-chip: var(--cl-chip);
|
||||||
|
--color-track: var(--cl-track);
|
||||||
|
--color-soft: var(--cl-soft);
|
||||||
|
--color-section: var(--cl-section);
|
||||||
|
--color-outside: var(--cl-outside);
|
||||||
|
--color-weekend: var(--cl-weekend);
|
||||||
|
--color-brand: var(--cl-brand);
|
||||||
|
--color-feature: var(--cl-feature);
|
||||||
|
--color-status-open: var(--cl-status-open);
|
||||||
|
--color-seg-from: var(--cl-seg-from);
|
||||||
|
--color-seg-to: var(--cl-seg-to);
|
||||||
|
--color-option-active: var(--cl-option-active);
|
||||||
|
--color-grid: var(--cl-grid);
|
||||||
|
--color-hover-row: var(--cl-hover-row);
|
||||||
|
--color-hover: var(--cl-hover);
|
||||||
|
--color-hover-menu: var(--cl-hover-menu);
|
||||||
|
|
||||||
|
--color-line-frame: var(--cl-line-frame);
|
||||||
|
--color-line: var(--cl-line);
|
||||||
|
--color-line-strong: var(--cl-line-strong);
|
||||||
|
--color-line-heavy: var(--cl-line-heavy);
|
||||||
|
--color-line-divider: var(--cl-line-divider);
|
||||||
|
--color-line-subtle: var(--cl-line-subtle);
|
||||||
|
--color-line-row: var(--cl-line-row);
|
||||||
|
--color-line-control: var(--cl-line-control);
|
||||||
|
--color-line-hover: var(--cl-line-hover);
|
||||||
|
--color-line-shell: var(--cl-line-shell);
|
||||||
|
--color-line-danger: var(--cl-line-danger);
|
||||||
|
--color-line-danger-strong: var(--cl-line-danger-strong);
|
||||||
|
|
||||||
|
--color-fg: var(--cl-fg);
|
||||||
|
--color-fg-strong: var(--cl-fg-strong);
|
||||||
|
--color-fg-2: var(--cl-fg-2);
|
||||||
|
--color-fg-3: var(--cl-fg-3);
|
||||||
|
--color-fg-4: var(--cl-fg-4);
|
||||||
|
--color-fg-muted: var(--cl-fg-muted);
|
||||||
|
--color-fg-subtle: var(--cl-fg-subtle);
|
||||||
|
--color-fg-faint: var(--cl-fg-faint);
|
||||||
|
--color-fg-dim: var(--cl-fg-dim);
|
||||||
|
--color-fg-open: var(--cl-fg-open);
|
||||||
|
--color-on-color: var(--cl-on-color);
|
||||||
|
--color-on-accent: var(--cl-white);
|
||||||
|
|
||||||
|
--color-side: var(--cl-side);
|
||||||
|
--color-side-line: var(--cl-side-line);
|
||||||
|
--color-side-active: var(--cl-side-active);
|
||||||
|
--color-side-active-line: var(--cl-side-active-line);
|
||||||
|
|
||||||
|
--color-success: var(--cl-success);
|
||||||
|
--color-success-fg: var(--cl-success-fg);
|
||||||
|
--color-warning: var(--cl-warning);
|
||||||
|
--color-warning-fg: var(--cl-warning-fg);
|
||||||
|
--color-info: var(--cl-info);
|
||||||
|
--color-info-fg: var(--cl-info-fg);
|
||||||
|
--color-danger: var(--cl-danger);
|
||||||
|
--color-danger-fg: var(--cl-danger-fg);
|
||||||
|
--color-danger-solid: var(--cl-danger-solid);
|
||||||
|
--color-danger-solid-line: var(--cl-danger-solid-line);
|
||||||
|
--color-open-bar: var(--cl-open-bar);
|
||||||
|
--color-glass: var(--cl-glass);
|
||||||
|
--color-glass-2: var(--cl-glass-2);
|
||||||
|
--color-scrim: var(--cl-sh-50);
|
||||||
|
|
||||||
|
/* shadcn/ui token names, so components added with `npx shadcn add` pick up the
|
||||||
|
Collabry palette. `accent` stays the Collabry brand color (shadcn uses it as a
|
||||||
|
hover fill), so restyle `bg-accent` hovers to `bg-hover-menu` after adding. */
|
||||||
|
--color-background: var(--cl-surface);
|
||||||
|
--color-foreground: var(--cl-fg);
|
||||||
|
--color-card: var(--cl-surface);
|
||||||
|
--color-card-foreground: var(--cl-fg);
|
||||||
|
--color-popover: var(--cl-raised);
|
||||||
|
--color-popover-foreground: var(--cl-fg);
|
||||||
|
--color-primary: var(--cl-acc);
|
||||||
|
--color-primary-foreground: var(--cl-white);
|
||||||
|
--color-secondary: var(--cl-elevated);
|
||||||
|
--color-secondary-foreground: var(--cl-fg-3);
|
||||||
|
--color-muted: var(--cl-chip);
|
||||||
|
--color-muted-foreground: var(--cl-fg-subtle);
|
||||||
|
--color-accent-foreground: var(--cl-fg-strong);
|
||||||
|
--color-destructive: var(--cl-danger-solid);
|
||||||
|
--color-border: var(--cl-line);
|
||||||
|
--color-input: var(--cl-line);
|
||||||
|
--color-ring: var(--cl-accent-focus);
|
||||||
|
|
||||||
|
--shadow-popover: 0 0 0 1px var(--cl-sh-60), 0 24px 56px -12px var(--cl-sh-85);
|
||||||
|
--shadow-menu: 0 0 0 1px var(--cl-sh-60), 0 18px 48px -8px var(--cl-sh-85);
|
||||||
|
--shadow-dropdown: 0 0 0 1px var(--cl-sh-60), 0 16px 40px -8px var(--cl-sh-85);
|
||||||
|
--shadow-dialog: 0 0 0 1px var(--cl-sh-60), 0 24px 64px -12px var(--cl-sh-85);
|
||||||
|
--shadow-toast: 0 12px 32px -8px var(--cl-sh-85);
|
||||||
|
--shadow-seg: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 1px 2px var(--cl-sh-50);
|
||||||
|
--shadow-bevel: inset 0 1px 0 rgba(255, 255, 255, 0.06);
|
||||||
|
--shadow-nav-active: inset 0 0 0 1px var(--cl-side-active-line), inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
||||||
|
--shadow-focus: 0 0 0 3px var(--cl-accent-ring);
|
||||||
|
--shadow-side: var(--cl-side-shadow);
|
||||||
|
|
||||||
|
--animate-spin-fast: cl-spin 0.7s linear infinite;
|
||||||
|
--animate-pop: cl-pop 0.28s cubic-bezier(0.2, 1.5, 0.4, 1) both;
|
||||||
|
--animate-panel-in: cl-panel-in 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||||
|
--animate-drawer-in: cl-drawer-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
||||||
|
--animate-fade-in: cl-fade-in 150ms ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes cl-spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes cl-pop {
|
||||||
|
from {
|
||||||
|
transform: scale(0.5);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: scale(1);
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes cl-draw {
|
||||||
|
to {
|
||||||
|
stroke-dashoffset: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes cl-panel-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-8px) scale(0.98);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes cl-drawer-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(16px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@keyframes cl-fade-in {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Primary button fill: accent gradient with a bevel. */
|
||||||
|
@utility bg-accent-gradient {
|
||||||
|
background: linear-gradient(
|
||||||
|
180deg,
|
||||||
|
color-mix(in srgb, var(--cl-acc) 88%, #fff) 0%,
|
||||||
|
color-mix(in srgb, var(--cl-acc) 90%, #000) 100%
|
||||||
|
);
|
||||||
|
}
|
||||||
|
@utility border-accent-deep {
|
||||||
|
border-color: color-mix(in srgb, var(--cl-acc) 62%, #000);
|
||||||
|
}
|
||||||
|
@utility shadow-primary {
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 0 rgba(255, 255, 255, 0.28),
|
||||||
|
0 1px 2px var(--cl-sh-50),
|
||||||
|
0 6px 18px -6px color-mix(in srgb, var(--cl-acc) 60%, transparent);
|
||||||
|
}
|
||||||
|
@utility shadow-primary-flat {
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
|
||||||
|
}
|
||||||
|
@utility text-shadow-primary {
|
||||||
|
text-shadow: 0 1px 0 var(--cl-sh-18);
|
||||||
|
}
|
||||||
|
/* Secondary button fill. */
|
||||||
|
@utility bg-secondary-gradient {
|
||||||
|
background: linear-gradient(180deg, var(--cl-elevated), var(--cl-surface));
|
||||||
|
}
|
||||||
|
/* Active segment in a segmented control. */
|
||||||
|
@utility bg-seg-active {
|
||||||
|
background: linear-gradient(180deg, var(--cl-seg-from), var(--cl-seg-to));
|
||||||
|
}
|
||||||
|
/* Checkmark that draws itself in after a successful action. */
|
||||||
|
@utility draw-check {
|
||||||
|
& path {
|
||||||
|
stroke-dasharray: 24;
|
||||||
|
stroke-dashoffset: 24;
|
||||||
|
animation: cl-draw 0.32s 0.06s ease-out forwards;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer base {
|
||||||
|
[data-cl-theme] {
|
||||||
|
font-family: var(--font-sans);
|
||||||
|
font-size: var(--text-base);
|
||||||
|
line-height: 1.45;
|
||||||
|
color: var(--cl-fg);
|
||||||
|
}
|
||||||
|
[data-cl-theme] button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
[data-cl-theme] button:disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
[data-cl-theme] [aria-busy='true'] {
|
||||||
|
cursor: progress;
|
||||||
|
}
|
||||||
|
[data-cl-theme] a {
|
||||||
|
color: var(--cl-accent-fg);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
[data-cl-theme] a:hover {
|
||||||
|
color: var(--cl-accent-fg-hover);
|
||||||
|
}
|
||||||
|
[data-cl-theme] input::placeholder,
|
||||||
|
[data-cl-theme] textarea::placeholder {
|
||||||
|
color: var(--cl-fg-subtle);
|
||||||
|
}
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
[data-cl-theme] *,
|
||||||
|
[data-cl-theme] *::before,
|
||||||
|
[data-cl-theme] *::after {
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
}
|
||||||
|
/* Spinners keep turning, just slower, so loading stays visible. */
|
||||||
|
[data-cl-theme] .cl-spinner {
|
||||||
|
animation-duration: 1.8s !important;
|
||||||
|
animation-iteration-count: infinite !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,260 @@
|
|||||||
|
/*
|
||||||
|
* Collabry design tokens.
|
||||||
|
*
|
||||||
|
* Every theme scope (`:root` or any element with `data-cl-theme`) defines raw
|
||||||
|
* values (`--cl-raw-*`) per theme and derives the semantic tokens (`--cl-*`)
|
||||||
|
* from them. Neutral tokens are mixed with the accent by `--cl-tint-bg` /
|
||||||
|
* `--cl-tint-fg`, which are 0% unless `data-cl-tint` is set, so "Neutraltöne
|
||||||
|
* einfärben" works by changing one attribute.
|
||||||
|
*/
|
||||||
|
|
||||||
|
:root,
|
||||||
|
[data-cl-theme] {
|
||||||
|
color-scheme: dark;
|
||||||
|
|
||||||
|
--cl-acc: #6a5fcb;
|
||||||
|
--cl-tint-bg: 0%;
|
||||||
|
--cl-tint-fg: 0%;
|
||||||
|
|
||||||
|
/* Surfaces */
|
||||||
|
--cl-raw-app: #050505;
|
||||||
|
--cl-raw-frame: #0a0a0a;
|
||||||
|
--cl-raw-surface: #141414;
|
||||||
|
--cl-raw-inset: #0e0e0e;
|
||||||
|
--cl-raw-raised: #161616;
|
||||||
|
--cl-raw-elevated: #1c1c1c;
|
||||||
|
--cl-raw-chip: #262626;
|
||||||
|
--cl-raw-track: #222222;
|
||||||
|
--cl-raw-soft: #1f1f1f;
|
||||||
|
--cl-raw-section: #101010;
|
||||||
|
--cl-raw-outside: #0c0c0c;
|
||||||
|
--cl-raw-weekend: #101010;
|
||||||
|
--cl-raw-brand: #000000;
|
||||||
|
--cl-raw-feature: #111111;
|
||||||
|
--cl-raw-status-open: #171717;
|
||||||
|
--cl-raw-seg-from: #212121;
|
||||||
|
--cl-raw-seg-to: #191919;
|
||||||
|
--cl-raw-option-active: #232323;
|
||||||
|
--cl-raw-grid: #242424;
|
||||||
|
--cl-raw-hover-row: #121212;
|
||||||
|
--cl-raw-hover: #1c1c1c;
|
||||||
|
--cl-raw-hover-menu: #1f1f1f;
|
||||||
|
|
||||||
|
/* Lines */
|
||||||
|
--cl-raw-line-frame: #1f1f1f;
|
||||||
|
--cl-raw-line: #2a2a2a;
|
||||||
|
--cl-raw-line-strong: #2e2e2e;
|
||||||
|
--cl-raw-line-heavy: #333333;
|
||||||
|
--cl-raw-line-divider: #262626;
|
||||||
|
--cl-raw-line-subtle: #242424;
|
||||||
|
--cl-raw-line-row: #222222;
|
||||||
|
--cl-raw-line-control: #3a3a3a;
|
||||||
|
--cl-raw-line-hover: #3a3a3a;
|
||||||
|
--cl-raw-line-shell: #1c1c1c;
|
||||||
|
--cl-raw-line-danger: #3a1d24;
|
||||||
|
--cl-raw-line-danger-strong: #5b2330;
|
||||||
|
|
||||||
|
/* Text */
|
||||||
|
--cl-raw-fg: #ededed;
|
||||||
|
--cl-raw-fg-strong: #ffffff;
|
||||||
|
--cl-raw-fg-2: #e5e5e5;
|
||||||
|
--cl-raw-fg-3: #d4d4d4;
|
||||||
|
--cl-raw-fg-4: #c7c7c7;
|
||||||
|
--cl-raw-fg-muted: #a3a3a3;
|
||||||
|
--cl-raw-fg-subtle: #8a8a8a;
|
||||||
|
--cl-raw-fg-faint: #6b6b6b;
|
||||||
|
--cl-raw-fg-dim: #5c5c5c;
|
||||||
|
--cl-raw-fg-open: #b5b5b5;
|
||||||
|
|
||||||
|
/* Sidebar */
|
||||||
|
--cl-raw-side: #0a0a0a;
|
||||||
|
--cl-raw-side-line: #1c1c1c;
|
||||||
|
--cl-raw-side-active: #1a1a1a;
|
||||||
|
--cl-raw-side-active-line: #2a2a2a;
|
||||||
|
--cl-side-shadow: none;
|
||||||
|
|
||||||
|
/* Status (not tinted) */
|
||||||
|
--cl-success: #34d399;
|
||||||
|
--cl-success-fg: #4ade80;
|
||||||
|
--cl-warning: #fbbf24;
|
||||||
|
--cl-warning-fg: #fbbf24;
|
||||||
|
--cl-info: #60a5fa;
|
||||||
|
--cl-info-fg: #7db4fb;
|
||||||
|
--cl-danger: #fb7185;
|
||||||
|
--cl-danger-fg: #fb7185;
|
||||||
|
--cl-danger-solid: #be123c;
|
||||||
|
--cl-danger-solid-line: #9f1239;
|
||||||
|
--cl-open-bar: #383838;
|
||||||
|
--cl-on-color: #0a0a0a;
|
||||||
|
--cl-white: #ffffff;
|
||||||
|
|
||||||
|
/* Shadow colors */
|
||||||
|
--cl-sh-18: rgba(0, 0, 0, 0.18);
|
||||||
|
--cl-sh-50: rgba(0, 0, 0, 0.5);
|
||||||
|
--cl-sh-60: rgba(0, 0, 0, 0.6);
|
||||||
|
--cl-sh-80: rgba(0, 0, 0, 0.8);
|
||||||
|
--cl-sh-85: rgba(0, 0, 0, 0.85);
|
||||||
|
|
||||||
|
--cl-glass: rgba(5, 5, 5, 0.92);
|
||||||
|
--cl-glass-2: rgba(10, 10, 10, 0.94);
|
||||||
|
|
||||||
|
/* Accent derived */
|
||||||
|
--cl-accent-fg: color-mix(in srgb, var(--cl-acc) 55%, #fff);
|
||||||
|
--cl-accent-fg-hover: color-mix(in srgb, var(--cl-acc) 35%, #fff);
|
||||||
|
--cl-accent-focus: color-mix(in srgb, var(--cl-acc) 80%, #fff);
|
||||||
|
|
||||||
|
/* ---- Semantic tokens (shared by both themes) ---- */
|
||||||
|
--cl-accent: var(--cl-acc);
|
||||||
|
--cl-accent-ring: color-mix(in srgb, var(--cl-acc) 30%, transparent);
|
||||||
|
--cl-accent-soft: color-mix(in srgb, var(--cl-acc) 10%, transparent);
|
||||||
|
--cl-accent-chip: color-mix(in srgb, var(--cl-acc) 22%, transparent);
|
||||||
|
|
||||||
|
--cl-app: color-mix(in srgb, var(--cl-raw-app), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-frame: color-mix(in srgb, var(--cl-raw-frame), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-surface: color-mix(in srgb, var(--cl-raw-surface), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-inset: color-mix(in srgb, var(--cl-raw-inset), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-raised: color-mix(in srgb, var(--cl-raw-raised), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-elevated: color-mix(in srgb, var(--cl-raw-elevated), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-chip: color-mix(in srgb, var(--cl-raw-chip), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-track: color-mix(in srgb, var(--cl-raw-track), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-soft: color-mix(in srgb, var(--cl-raw-soft), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-section: color-mix(in srgb, var(--cl-raw-section), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-outside: color-mix(in srgb, var(--cl-raw-outside), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-weekend: color-mix(in srgb, var(--cl-raw-weekend), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-brand: color-mix(in srgb, var(--cl-raw-brand), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-feature: color-mix(in srgb, var(--cl-raw-feature), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-status-open: color-mix(in srgb, var(--cl-raw-status-open), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-seg-from: color-mix(in srgb, var(--cl-raw-seg-from), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-seg-to: color-mix(in srgb, var(--cl-raw-seg-to), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-option-active: color-mix(in srgb, var(--cl-raw-option-active), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-grid: color-mix(in srgb, var(--cl-raw-grid), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-hover-row: color-mix(in srgb, var(--cl-raw-hover-row), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-hover: color-mix(in srgb, var(--cl-raw-hover), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-hover-menu: color-mix(in srgb, var(--cl-raw-hover-menu), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
|
||||||
|
--cl-line-frame: color-mix(in srgb, var(--cl-raw-line-frame), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line: color-mix(in srgb, var(--cl-raw-line), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-strong: color-mix(in srgb, var(--cl-raw-line-strong), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-heavy: color-mix(in srgb, var(--cl-raw-line-heavy), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-divider: color-mix(in srgb, var(--cl-raw-line-divider), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-subtle: color-mix(in srgb, var(--cl-raw-line-subtle), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-row: color-mix(in srgb, var(--cl-raw-line-row), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-control: color-mix(in srgb, var(--cl-raw-line-control), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-hover: color-mix(in srgb, var(--cl-raw-line-hover), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-shell: color-mix(in srgb, var(--cl-raw-line-shell), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-line-danger: var(--cl-raw-line-danger);
|
||||||
|
--cl-line-danger-strong: var(--cl-raw-line-danger-strong);
|
||||||
|
|
||||||
|
--cl-fg: color-mix(in srgb, var(--cl-raw-fg), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-strong: color-mix(in srgb, var(--cl-raw-fg-strong), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-2: color-mix(in srgb, var(--cl-raw-fg-2), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-3: color-mix(in srgb, var(--cl-raw-fg-3), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-4: color-mix(in srgb, var(--cl-raw-fg-4), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-muted: color-mix(in srgb, var(--cl-raw-fg-muted), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-subtle: color-mix(in srgb, var(--cl-raw-fg-subtle), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-faint: color-mix(in srgb, var(--cl-raw-fg-faint), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-dim: color-mix(in srgb, var(--cl-raw-fg-dim), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
--cl-fg-open: color-mix(in srgb, var(--cl-raw-fg-open), var(--cl-acc) var(--cl-tint-fg));
|
||||||
|
|
||||||
|
--cl-side: color-mix(in srgb, var(--cl-raw-side), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-side-line: color-mix(in srgb, var(--cl-raw-side-line), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-side-active: color-mix(in srgb, var(--cl-raw-side-active), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
--cl-side-active-line: color-mix(in srgb, var(--cl-raw-side-active-line), var(--cl-acc) var(--cl-tint-bg));
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-cl-theme='light'] {
|
||||||
|
color-scheme: light;
|
||||||
|
|
||||||
|
--cl-raw-app: #f4f4f5;
|
||||||
|
--cl-raw-frame: #ededef;
|
||||||
|
--cl-raw-surface: #ffffff;
|
||||||
|
--cl-raw-inset: #fafafa;
|
||||||
|
--cl-raw-raised: #ffffff;
|
||||||
|
--cl-raw-elevated: #ffffff;
|
||||||
|
--cl-raw-chip: #e7e7ea;
|
||||||
|
--cl-raw-track: #e8e8eb;
|
||||||
|
--cl-raw-soft: #f1f1f3;
|
||||||
|
--cl-raw-section: #f7f7f8;
|
||||||
|
--cl-raw-outside: #fafafa;
|
||||||
|
--cl-raw-weekend: #f7f7f8;
|
||||||
|
--cl-raw-brand: #ffffff;
|
||||||
|
--cl-raw-feature: #f4f4f5;
|
||||||
|
--cl-raw-status-open: #f4f4f5;
|
||||||
|
--cl-raw-seg-from: #ffffff;
|
||||||
|
--cl-raw-seg-to: #fafafa;
|
||||||
|
--cl-raw-option-active: #ffffff;
|
||||||
|
--cl-raw-grid: #e4e4e7;
|
||||||
|
--cl-raw-hover-row: #f4f4f5;
|
||||||
|
--cl-raw-hover: #f1f1f3;
|
||||||
|
--cl-raw-hover-menu: #f1f1f3;
|
||||||
|
|
||||||
|
--cl-raw-line-frame: #e4e4e7;
|
||||||
|
--cl-raw-line: #dedee3;
|
||||||
|
--cl-raw-line-strong: #d4d4d8;
|
||||||
|
--cl-raw-line-heavy: #d4d4d8;
|
||||||
|
--cl-raw-line-divider: #e4e4e7;
|
||||||
|
--cl-raw-line-subtle: #ededef;
|
||||||
|
--cl-raw-line-row: #ededef;
|
||||||
|
--cl-raw-line-control: #c4c4ca;
|
||||||
|
--cl-raw-line-hover: #a1a1aa;
|
||||||
|
--cl-raw-line-shell: #e4e4e7;
|
||||||
|
--cl-raw-line-danger: #f6cfd7;
|
||||||
|
--cl-raw-line-danger-strong: #f0a3b2;
|
||||||
|
|
||||||
|
--cl-raw-fg: #18181b;
|
||||||
|
--cl-raw-fg-strong: #18181b;
|
||||||
|
--cl-raw-fg-2: #27272a;
|
||||||
|
--cl-raw-fg-3: #3f3f46;
|
||||||
|
--cl-raw-fg-4: #52525b;
|
||||||
|
--cl-raw-fg-muted: #5b5b66;
|
||||||
|
--cl-raw-fg-subtle: #71717a;
|
||||||
|
--cl-raw-fg-faint: #a1a1aa;
|
||||||
|
--cl-raw-fg-dim: #a1a1aa;
|
||||||
|
--cl-raw-fg-open: #52525b;
|
||||||
|
|
||||||
|
--cl-raw-side: #ffffff;
|
||||||
|
--cl-raw-side-line: #d9d9de;
|
||||||
|
--cl-raw-side-active: #f1f1f3;
|
||||||
|
--cl-raw-side-active-line: #dcdce1;
|
||||||
|
--cl-side-shadow: 1px 0 0 rgba(0, 0, 0, 0.02), 4px 0 16px -8px rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
--cl-warning: #f59e0b;
|
||||||
|
--cl-warning-fg: #b45309;
|
||||||
|
--cl-success-fg: #15803d;
|
||||||
|
--cl-info: #3b82f6;
|
||||||
|
--cl-info-fg: #1d4ed8;
|
||||||
|
--cl-danger: #f43f5e;
|
||||||
|
--cl-danger-fg: #e11d48;
|
||||||
|
--cl-danger-solid: #e11d48;
|
||||||
|
--cl-open-bar: #d4d4d8;
|
||||||
|
|
||||||
|
--cl-sh-18: rgba(0, 0, 0, 0.05);
|
||||||
|
--cl-sh-50: rgba(0, 0, 0, 0.12);
|
||||||
|
--cl-sh-60: rgba(0, 0, 0, 0.06);
|
||||||
|
--cl-sh-80: rgba(0, 0, 0, 0.14);
|
||||||
|
--cl-sh-85: rgba(0, 0, 0, 0.16);
|
||||||
|
|
||||||
|
--cl-glass: rgba(255, 255, 255, 0.9);
|
||||||
|
--cl-glass-2: rgba(255, 255, 255, 0.94);
|
||||||
|
|
||||||
|
--cl-accent-fg: color-mix(in srgb, var(--cl-acc) 85%, #000);
|
||||||
|
--cl-accent-fg-hover: color-mix(in srgb, var(--cl-acc) 65%, #000);
|
||||||
|
--cl-accent-focus: var(--cl-acc);
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-cl-tint='subtle'] {
|
||||||
|
--cl-tint-bg: 5%;
|
||||||
|
--cl-tint-fg: 6%;
|
||||||
|
}
|
||||||
|
[data-cl-tint='strong'] {
|
||||||
|
--cl-tint-bg: 10%;
|
||||||
|
--cl-tint-fg: 12%;
|
||||||
|
}
|
||||||
|
[data-cl-theme='light'][data-cl-tint='subtle'] {
|
||||||
|
--cl-tint-bg: 3%;
|
||||||
|
--cl-tint-fg: 5%;
|
||||||
|
}
|
||||||
|
[data-cl-theme='light'][data-cl-tint='strong'] {
|
||||||
|
--cl-tint-bg: 7%;
|
||||||
|
--cl-tint-fg: 10%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"exclude": ["src/**/*.stories.tsx", "src/stories"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"strict": true,
|
||||||
|
"noUnusedLocals": true,
|
||||||
|
"noUnusedParameters": true,
|
||||||
|
"noFallthroughCasesInSwitch": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"types": ["vite/client"],
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": ["src", ".storybook"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import { resolve } from 'node:path';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import react from '@vitejs/plugin-react';
|
||||||
|
import tailwindcss from '@tailwindcss/vite';
|
||||||
|
import dts from 'vite-plugin-dts';
|
||||||
|
import pkg from './package.json';
|
||||||
|
|
||||||
|
const external = [...Object.keys(pkg.peerDependencies), ...Object.keys(pkg.dependencies)];
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
react(),
|
||||||
|
tailwindcss(),
|
||||||
|
dts({
|
||||||
|
tsconfigPath: './tsconfig.build.json',
|
||||||
|
exclude: ['**/*.stories.tsx', 'src/stories/**'],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: { '@': resolve(__dirname, 'src') },
|
||||||
|
},
|
||||||
|
// `public/` only holds Storybook sample assets.
|
||||||
|
publicDir: false,
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: resolve(__dirname, 'src/index.ts'),
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: 'index',
|
||||||
|
cssFileName: 'collabry',
|
||||||
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
external: (id) => external.some((dep) => id === dep || id.startsWith(`${dep}/`)),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user