Files
collabry-components/src/stories/Foundations.stories.tsx
T
2026-11-04 22:31:12 +01:00

127 lines
4.3 KiB
TypeScript

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>
),
};