Skip to content

Commit

Permalink
fix: chromatic
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB committed Apr 18, 2024
1 parent e159f83 commit 00b51a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
15 changes: 13 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import * as tokens from '@sbb-esta/lyne-design-tokens';
import type { StoryContext } from '@storybook/types';
import type { Decorator } from '@storybook/web-components';
import isChromatic from 'chromatic/isChromatic';
import { html } from 'lit';

import '../src/components/core/styles/global.scss';
import { withBackgroundDecorator } from '../src/storybook/testing/with-background-decorator.js';

import '../src/components/core/styles/global.scss';

const getViewportName = (key: string): string =>
key.replace(/(^SbbBreakpoint|Min$)/g, '').toLowerCase();

Expand Down Expand Up @@ -65,4 +70,10 @@ export const parameters = {
},
};

export const decorators = [withBackgroundDecorator];
export const decorators: Decorator[] = [
(story, context: StoryContext) =>
isChromatic() && context.parameters.layout !== 'fullscreen'
? html`<div style="padding: 2rem"></div>`
: story(),
withBackgroundDecorator,
];
5 changes: 4 additions & 1 deletion src/components/autocomplete/autocomplete.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,10 @@ export const MixedSingleOptionWithOptionGroupNegative: StoryObj = {
};

const meta: Meta = {
decorators: [withActions as Decorator],
decorators: [
(story) => (isChromatic() ? html` <div style="min-height: 100vh">${story()}</div>` : story()),
withActions as Decorator,
],
parameters: {
chromatic: { disableSnapshot: false },
actions: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/breadcrumb/breadcrumb/breadcrumb.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const LongContent: StoryObj = {
'icon-name': 'house-small',
text: 'This label name is so long that it needs ellipsis to fit.',
},
decorators: [(story) => html` <div style="max-width: 200px;">${story()}</div> `],
decorators: [(story) => html`<div style="max-width: 200px;">${story()}</div>`],
};

export const NoLink: StoryObj = {
Expand Down

0 comments on commit 00b51a3

Please sign in to comment.