Skip to content

Commit

Permalink
build: migrate deprecated storybook config
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremias Peier <[email protected]>
  • Loading branch information
jeripeierSBB committed May 15, 2024
1 parent ec4fdc8 commit 2ab08ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 0 additions & 3 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const config: StorybookConfig = {
name: '@storybook/web-components-vite',
options: {},
},
docs: {
autodocs: true,
},
async viteFinal(config) {
let build: BuildOptions = {};
if (process.env.CHROMATIC) {
Expand Down
17 changes: 13 additions & 4 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as tokens from '@sbb-esta/lyne-design-tokens';
import type { StoryContext } from '@storybook/types';
import type { Decorator } from '@storybook/web-components';
import type { Parameters, StoryContext } from '@storybook/types';
import type { Decorator, Preview } from '@storybook/web-components';
import isChromatic from 'chromatic/isChromatic';
import { html } from 'lit';

Expand Down Expand Up @@ -41,7 +41,7 @@ const storybookViewports = breakpoints.reduce(
{} as Record<string, number>,
);

export const parameters = {
const parameters: Parameters = {
// Set the viewports in Chromatic globally.
chromatic: {
delay: 2000,
Expand All @@ -52,6 +52,7 @@ export const parameters = {
breakpointNames,
debounceTimeout: 10,
},
tags: ['autodocs'],
docs: {
toc: {
ignoreSelector: '.docs-story h2',
Expand All @@ -70,11 +71,19 @@ export const parameters = {
},
};

export const decorators: Decorator[] = [
const decorators: Decorator[] = [
(story, context: StoryContext) =>
isChromatic() && context.parameters.layout !== 'fullscreen'
? html`<div style="padding: 2rem;min-height: 100vh">${story()}</div>`
: story(),
withBackgroundDecorator,
(story) => (isChromatic() ? html`<div class="sbb-disable-animation">${story()}</div>` : story()),
];

const preview: Preview = {
decorators,
parameters,
tags: ['autodocs'],
};

export default preview;

0 comments on commit 2ab08ce

Please sign in to comment.