Skip to content

Commit

Permalink
chore: test responsiveness in Chromatic (#2727)
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahgm committed Jan 23, 2023
1 parent 3545b61 commit 1f33094
Show file tree
Hide file tree
Showing 39 changed files with 9,560 additions and 3,086 deletions.
8 changes: 5 additions & 3 deletions config/storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import isChromatic from 'chromatic/isChromatic';
import type { StoryFn } from '@storybook/react';
import { StoryFn } from '@storybook/react';

import { Box, MarigoldProvider } from '@marigold/components';
import b2bTheme from '@marigold/theme-b2b';
Expand Down Expand Up @@ -48,7 +48,7 @@ export const parameters = {
export const decorators = [
(Story: StoryFn, { globals, parameters }: any) => {
const theme = isChromatic()
? 'stacked'
? parameters.theme || 'stacked'
: globals.theme || parameters.theme || 'b2b';

switch (theme) {
Expand All @@ -68,7 +68,9 @@ export const decorators = [
default: {
return (
<MarigoldProvider theme={THEME[theme as ThemeNames]}>
<Story />
<div style={{ height: '900px' }}>
<Story />
</div>
</MarigoldProvider>
);
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@types/node": "16.18.3",
"all-contributors-cli": "6.24.0",
"async-retry": "1.3.3",
"chromatic": "6.6.3",
"eslint": "8.32.0",
"husky": "8.0.2",
"jest": "29.3.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/components/src/Aside/Aside.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, ComponentStory } from '@storybook/react';
import { Box } from '../Box';

import { Aside } from './Aside';
import isChromatic from 'chromatic';

export default {
title: 'Components/Aside',
Expand Down Expand Up @@ -85,3 +86,9 @@ export const InheritWidth: ComponentStory<typeof Aside> = () => (
</Box>
</Aside>
);

Basic.parameters = {
// Set the viewports in Chromatic at a story level.
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Aspect/Aspect.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, ComponentStory } from '@storybook/react';

import { Aspect } from './Aspect';
import { Image } from '../Image';
import isChromatic from 'chromatic';

export default {
title: 'Components/Aspect',
Expand Down Expand Up @@ -49,3 +50,8 @@ export const CutImage: ComponentStory<typeof Aspect> = args => (
/>
</Aspect>
);

CutImage.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Breakout/Breakout.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Image } from '../Image';
import { Text } from '../Text';

import { Breakout } from './Breakout';
import isChromatic from 'chromatic';

export default {
title: 'Components/Breakout',
Expand Down Expand Up @@ -127,3 +128,8 @@ export const ExampleFrame: ComponentStory<typeof Breakout> = args => (
</Text>
</Container>
);

ExampleFrame.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Button/Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Facebook } from '@marigold/icons';
import { Button } from './Button';
import isChromatic from 'chromatic';

export default {
title: 'Components/Button',
Expand Down Expand Up @@ -82,3 +83,8 @@ export const PassThroughProps: ComponentStory<typeof Button> = args => {
</>
);
};

WithIcon.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Card/Card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Close, ExternalLink } from '@marigold/icons';
import { Inline } from '../Inline';
import { Split } from '../Split';
import { Tiles } from '../Tiles';
import isChromatic from 'chromatic';

export default {
title: 'Components/Card',
Expand Down Expand Up @@ -85,3 +86,8 @@ export const CoreCard: ComponentStory<typeof Card> = args => (
</Card>
</Tiles>
);

CoreCard.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Center/Center.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Headline } from '../Headline';
import { Stack } from '../Stack';
import { Text } from '../Text';
import { Button } from '../Button';
import isChromatic from 'chromatic';

export default {
title: 'Components/Center',
Expand Down Expand Up @@ -99,3 +100,8 @@ export const Complex: ComponentStory<typeof Center> = args => (
</Text>
</Stack>
);

Complex.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Checkbox/CheckboxGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, ComponentStory } from '@storybook/react';

import { Checkbox } from './Checkbox';
import { CheckboxGroup } from './CheckboxGroup';
import isChromatic from 'chromatic';

export default {
title: 'Components/CheckboxGroup',
Expand Down Expand Up @@ -94,3 +95,8 @@ export const Error: ComponentStory<typeof CheckboxGroup> = args => {
</>
);
};

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Columns/Columns.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
import type { Meta, ComponentStory } from '@storybook/react';

import { Box, Columns, Stack } from '@marigold/components';
import isChromatic from 'chromatic';

export default {
title: 'Components/Columns',
Expand Down Expand Up @@ -122,3 +123,8 @@ export const FullHeight: ComponentStory<typeof Columns> = args => (
</Columns>
</Box>
);

MultiRow.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Container/Container.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Box } from '../Box';
import { Container } from './Container';
import { Headline } from '../Headline';
import { Text } from '../Text';
import isChromatic from 'chromatic';

export default {
title: 'Components/Container',
Expand Down Expand Up @@ -90,3 +91,8 @@ export const InnerContent: ComponentStory<typeof Container> = args => (
</Container>
</Box>
);

InnerContent.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Divider/Divider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Divider } from './Divider';
import { Text } from '../Text';
import isChromatic from 'chromatic';

export default {
title: 'Components/Divider',
Expand All @@ -28,3 +29,8 @@ export const Basic: ComponentStory<typeof Divider> = args => (
<Text>Below</Text>
</>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/FieldBase/FieldBase.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { TextField } from '../TextField';
import { RadioGroup } from '../Radio/RadioGroup';
import { Radio } from '../Radio';
import { Checkbox, CheckboxGroup } from '../Checkbox';
import isChromatic from 'chromatic';

export default {
title: 'Components/FieldBase',
Expand Down Expand Up @@ -85,3 +86,8 @@ export const Complex: ComponentStory<typeof FieldBase> = args => (
</CheckboxGroup>
</FieldGroup>
);

Complex.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Footer/Footer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Footer } from './Footer';
import isChromatic from 'chromatic';

export default {
title: 'Components/Footer',
Expand All @@ -23,3 +24,8 @@ export default {
export const Basic: ComponentStory<typeof Footer> = args => (
<Footer>This is a Footer.</Footer>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Header/Header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Container } from '../Container';
import { Header } from './Header';
import isChromatic from 'chromatic';

export default {
title: 'Components/Header',
Expand All @@ -26,3 +27,8 @@ export const Basic: ComponentStory<typeof Header> = args => (
<Header {...args}>Awsome Header</Header>
</Container>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/HelpText/HelpText.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { HelpText } from '../HelpText';
import isChromatic from 'chromatic';

export default {
title: 'Components/HelpText',
Expand Down Expand Up @@ -39,3 +40,8 @@ export default {
export const Basic: ComponentStory<typeof HelpText> = args => (
<HelpText {...args} />
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
7 changes: 7 additions & 0 deletions packages/components/src/Image/Image.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Image } from './Image';
import isChromatic from 'chromatic';

export default {
title: 'Components/Image',
Expand Down Expand Up @@ -52,3 +53,9 @@ export const Basic: ComponentStory<typeof Image> = args => (
alt="marigold_logo"
/>
);

Basic.parameters = {
// Set the viewports in Chromatic at a story level.
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Inline/Inline.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Box } from '@marigold/system';
import { shadow } from '@marigold/tokens';

import { Inline } from './Inline';
import isChromatic from 'chromatic';

export default {
title: 'Components/Inline',
Expand Down Expand Up @@ -70,3 +71,8 @@ export const Basic: ComponentStory<typeof Inline> = args => (
<Block>Löffelstiel!</Block>
</Inline>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Input/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Input } from './Input';
import isChromatic from 'chromatic';

export default {
title: 'Components/Input',
Expand Down Expand Up @@ -44,3 +45,8 @@ export default {
export const Basic: ComponentStory<typeof Input> = args => (
<Input placeholder="Placeholder..." {...args} />
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Label/Label.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Label } from './Label';
import isChromatic from 'chromatic';

export default {
title: 'Components/Label',
Expand All @@ -25,3 +26,8 @@ export default {
export const Basic: ComponentStory<typeof Label> = ({ children, ...args }) => (
<Label {...args}>{children}</Label>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Link/Link.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { Link } from './Link';
import { Text } from '../Text';
import isChromatic from 'chromatic';

export default {
title: 'Components/Link',
Expand Down Expand Up @@ -36,3 +37,8 @@ export const Basic: ComponentStory<typeof Link> = args => (
</Link>
</Text>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/List/List.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import type { Meta, ComponentStory } from '@storybook/react';
import { List } from './List';
import isChromatic from 'chromatic';

export default {
title: 'Components/List',
Expand Down Expand Up @@ -35,3 +36,8 @@ export const Ordered: ComponentStory<typeof List> = args => (
<List.Item>Brot</List.Item>
</List>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
6 changes: 6 additions & 0 deletions packages/components/src/Message/Message.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, ComponentStory } from '@storybook/react';
import { Message } from './Message';
import { Text } from '../Text';
import { Box } from '@marigold/system';
import isChromatic from 'chromatic';

export default {
title: 'Components/Message',
Expand Down Expand Up @@ -39,3 +40,8 @@ export const MultiLineTitle: ComponentStory<typeof Message> = () => (
</Message>
</Box>
);

Basic.parameters = {
chromatic: { viewports: [320, 1200] },
theme: isChromatic() ? 'b2b' : 'stacked',
};
Loading

0 comments on commit 1f33094

Please sign in to comment.