Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: migrate deprecated storybook config #2660

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Loading