import type { Decorator, Preview } from '@storybook/react-vite' import '../src/styles.css' import { palettes, DEFAULT_PALETTE, type PaletteName } from '@openkhalix/tansy-ui' import { tansyTheme } from './tansyTheme' import { ThemeSurface } from './ThemeSurface' const withTheme: Decorator = (Story, context) => { const palette = (context.globals.palette ?? DEFAULT_PALETTE) as PaletteName const mode = context.globals.mode === 'dark' ? 'dark' : 'light' const padded = context.parameters.layout !== 'fullscreen' return ( ) } const preview: Preview = { title: 'Tansy UI / Component Workshop', decorators: [withTheme], globalTypes: { mode: { description: 'Light or dark mode for every component and popup.', toolbar: { title: 'Mode', icon: 'contrast', items: [ { value: 'light', title: 'Light', icon: 'sun' }, { value: 'dark', title: 'Dark', icon: 'moon' }, ], dynamicTitle: true, }, }, palette: { description: 'Brand palette applied to every element in the canvas.', toolbar: { title: 'Palette', icon: 'paintbrush', items: Object.values(palettes).map((p) => ({ value: p.name, title: `${p.label} — ${p.note}`, })), dynamicTitle: true, }, }, }, initialGlobals: { mode: 'light', palette: DEFAULT_PALETTE, }, parameters: { backgrounds: { disable: true }, a11y: { // Page-level rules can't apply to an isolated component: a story has no //
, no

and no landmarks of its own. Everything else runs. config: { rules: [ { id: 'landmark-one-main', enabled: false }, { id: 'page-has-heading-one', enabled: false }, { id: 'region', enabled: false }, ], }, }, docs: { theme: tansyTheme, }, options: { storySort: { order: [ 'Introduction', ['Welcome', 'Getting started', 'Theming', 'Accessibility', 'Changelog', 'Roadmap'], 'Actions', 'Forms', 'Feedback', 'Display', 'Layout', 'Navigation', 'Overlays', ], }, }, controls: { matchers: { date: /Date$/i, }, }, }, } export default preview