shadcn base
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user