Files
collabry-components/.storybook/preview.tsx
T
2026-11-04 22:31:12 +01:00

84 lines
2.3 KiB
TypeScript

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;