68 lines
3.6 KiB
Markdown
68 lines
3.6 KiB
Markdown
# @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
|