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

test(react-components): add visual baselines for Headings #307

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { LuxDocument, LuxParagraph } from '@lux-design-system/components-react';
import tokens from '@lux-design-system/design-tokens/dist/index.json';
import type { Meta, StoryObj } from '@storybook/react';
import tokensDefinition from './tokens.json';
import { createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';
import { createDesignTokensStory } from '../../utils';
import { createDesignTokensStory, createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

type Story = StoryObj<typeof meta>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LuxHeading, LuxHeadingGroup, LuxPreHeading } from '@lux-design-system/components-react';
import { LuxHeading, LuxHeading1, LuxHeadingGroup, LuxPreHeading } from '@lux-design-system/components-react';
import tokens from '@lux-design-system/design-tokens/dist/index.json';
import type { Meta, StoryObj } from '@storybook/react';
import { createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

type Story = StoryObj<typeof meta>;

const meta = {
title: 'React Components/Heading-group',
title: 'React Components/HeadingGroup',
id: 'react-components-heading-group',
component: LuxHeadingGroup,
subcomponents: {},
Expand Down Expand Up @@ -47,3 +48,22 @@ export const Playground: Story = {
},
tags: ['!autodocs'],
};

export const Visual = createVisualRegressionStory(() => (
<>
<h4 className="utrecht-heading-3">Light</h4>
<VisualRegressionWrapper className="lux-theme--logius-light" key="light">
<LuxHeadingGroup>
<LuxHeading1>LuxHeading1</LuxHeading1>
<LuxPreHeading>LuxPreHeading</LuxPreHeading>
</LuxHeadingGroup>
</VisualRegressionWrapper>
<h4 className="utrecht-heading-3">Dark</h4>
<VisualRegressionWrapper className="lux-theme--logius-dark" key="dark">
<LuxHeadingGroup>
<LuxHeading1>LuxHeading1</LuxHeading1>
<LuxPreHeading>LuxPreHeading</LuxPreHeading>
</LuxHeadingGroup>
</VisualRegressionWrapper>
</>
));
4 changes: 2 additions & 2 deletions packages/storybook/src/react-components/heading/heading.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CitationDocumentation } from "../../utils/CitationDocumentation";

<Meta of={HeadingStories} />

# Lux Heading
# Heading

<CitationDocumentation
component="Utrecht Heading"
Expand All @@ -17,7 +17,7 @@ import { CitationDocumentation } from "../../utils/CitationDocumentation";
## Opmerkingen

- Als de waarde voor de property `appearance` niet gedefinieerd is krijgt het de waarde van de property `level`
- De componenten "Heading1" t/m "Heading6" zijn gebouwd met het dynamische "Heading" component.
- De componenten `Heading1` t/m `Heading6` zijn gebouwd met het dynamische `Heading` component.

## Playground

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,25 @@ import {
LuxHeading4,
LuxHeading5,
LuxHeading6,
type LuxHeadingProps,
} from '@lux-design-system/components-react';
import tokens from '@lux-design-system/design-tokens/dist/index.json';
import type { Meta, StoryObj } from '@storybook/react';
import tokensDefinition from '@utrecht/heading-css/src/tokens.json';
import { createDesignTokensStory, createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

type Story = StoryObj<typeof meta>;

const headingText = "Pa's wijze lynx bezag vroom het fikse aquaduct!";

const meta = {
title: 'React Components/Heading',
id: 'react-components-heading',
component: LuxHeading,
subcomponents: {},
parameters: {
tokens,
tokensPrefix: 'react-heading',
tokensPrefix: 'utrecht-heading-1',
tokensDefinition,
},
argTypes: {
children: {
Expand All @@ -45,8 +50,6 @@ const meta = {

export default meta;

const headingText = "Pa's wijze lynx bezag vroom het fikse aquaduct!";

const HeadingTemplate: Story = {
render: ({ children, ...args }) => <LuxHeading {...args}>{children}</LuxHeading>,
args: {
Expand Down Expand Up @@ -91,3 +94,44 @@ export const HeadingWithDifferentAppearance: Story = {
appearance: 1,
},
};

export const DesignTokens = createDesignTokensStory(meta);

export const Visual = createVisualRegressionStory(() => (
<>
<h4 className="utrecht-heading-3">Light</h4>
<VisualRegressionWrapper className={`lux-theme--logius-light`} key={'light'}>
{[1, 2, 3, 4, 5, 6].map((level) => (
<>
<LuxHeading level={level as LuxHeadingProps['level']} key={'light-level-' + level}>
H{level}: {headingText}
</LuxHeading>
<LuxHeading
level={99 as LuxHeadingProps['level']}
appearance={level as LuxHeadingProps['appearance']}
key={'light-appeareance-' + level}
>
Lijkt op een H{level}: {headingText}
</LuxHeading>
</>
))}
</VisualRegressionWrapper>
<h4 className="utrecht-heading-3">Dark</h4>
<VisualRegressionWrapper className={`lux-theme--logius-dark`} key="dark">
{[1, 2, 3, 4, 5, 6].map((level) => (
<>
<LuxHeading level={level as LuxHeadingProps['level']} key={'dark-level-' + level}>
H{level}: {headingText}
</LuxHeading>
<LuxHeading
level={99 as LuxHeadingProps['level']}
appearance={level as LuxHeadingProps['appearance']}
key={'dark-appeareance-' + level}
>
Lijkt op een H{level}: {headingText}
</LuxHeading>
</>
))}
</VisualRegressionWrapper>
</>
));
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { LuxParagraph } from '@lux-design-system/components-react';
import tokens from '@lux-design-system/design-tokens/dist/index.json';
import type { Meta, StoryObj } from '@storybook/react';
import tokensDefinition from './tokens.json';
import { createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';
import { createDesignTokensStory } from '../../utils';
import tokensDefinition from '@utrecht/paragraph-css/src/tokens.json';
import { createDesignTokensStory, createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

type Story = StoryObj<typeof meta>;

Expand Down
172 changes: 0 additions & 172 deletions packages/storybook/src/react-components/paragraph/tokens.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { LuxPreHeading } from '@lux-design-system/components-react';
import tokens from '@lux-design-system/design-tokens/dist/index.json';
import type { Meta, StoryObj } from '@storybook/react';
import { createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

type Story = StoryObj<typeof meta>;

const meta = {
title: 'React Components/Pre-heading',
title: 'React Components/PreHeading',
id: 'react-components-pre-heading',
component: LuxPreHeading,
subcomponents: {},
Expand Down Expand Up @@ -48,3 +49,16 @@ export const Playground: Story = {
},
tags: ['!autodocs'],
};

export const Visual = createVisualRegressionStory(() => (
<>
<h4 className="utrecht-heading-3">Light</h4>
<VisualRegressionWrapper className="lux-theme--logius-light">
<LuxPreHeading>LuxPreHeading: {preHeadingText}</LuxPreHeading>
</VisualRegressionWrapper>
<h4 className="utrecht-heading-3">Dark</h4>
<VisualRegressionWrapper className="lux-theme--logius-dark">
<LuxPreHeading>LuxPreHeading: {preHeadingText}</LuxPreHeading>
</VisualRegressionWrapper>
</>
));
Loading