feat(storybook): add a global decorator for stories

This commit is contained in:
Ilia Mashkov
2026-01-18 19:25:07 +03:00
parent 50c7511698
commit 06cb155b47
2 changed files with 33 additions and 1 deletions

View File

@@ -1,9 +1,10 @@
import type { Preview } from '@storybook/svelte-vite';
import StoryStage from './StoryStage.svelte';
import '../src/app/styles/app.css';
const preview: Preview = {
parameters: {
layout: 'fullscreen',
controls: {
matchers: {
color: /(background|color)$/i,
@@ -18,6 +19,21 @@ const preview: Preview = {
test: 'todo',
},
},
decorators: [
(storyFn, { parameters }) => {
const { Component, props } = storyFn();
return {
Component: StoryStage,
// We pass the actual story component into the Stage via a snippet/slot
// Svelte 5 Storybook handles this mapping internally when you return this structure
props: {
children: Component,
width: parameters.stageWidth || 'max-w-3xl',
...props,
},
};
},
],
};
export default preview;