Files
tansy-ui/.storybook/preview.tsx
T
thekhalidsha 23e67006d3 Make every component and the landing page responsive (v0.3.1)
Every story and the landing page now fit from a 320px phone to a wide
desktop without scrolling sideways.

- Inputs in flex rows (Input, FeaturedInput, NumberInput, Combobox) shrink
  instead of holding their native width
- Tab rows and ToggleGroup scroll within themselves on narrow screens;
  vertical tabs stack above their panel on phones
- Positioned popups cap at Base UI's --available-width
- Landing page: tablet header no longer crowds; code sample fits at 1024px
- Storybook a11y panel skips page-level rules that can't apply to a story
- check-stories.mjs gains --width and fails on horizontal overflow; all
  423 stories pass at 320, 375, 768 and desktop widths in both modes
2026-09-28 22:47:26 +05:30

91 lines
2.4 KiB
TypeScript

import type { Decorator, Preview } from '@storybook/react-vite'
import '../src/index.css'
import { palettes, DEFAULT_PALETTE, type PaletteName } from '../src/theme/palettes'
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 (
<ThemeSurface palette={palette} mode={mode} padded={padded}>
<Story />
</ThemeSurface>
)
}
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
// <main>, no <h1> 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