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(components-react): add visual baseline section #346

Merged
merged 3 commits into from
Jan 2, 2025
Merged
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
6 changes: 5 additions & 1 deletion packages/storybook/config/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const preview: Preview = {
name: 'default',
value: 'var(--lux-color-background-default)',
},
{
name: 'canvas',
value: 'var(--lux-color-canvas)',
},
{
/*
Deliberately provide a background which we'd never use in production.
Expand All @@ -65,7 +69,7 @@ const preview: Preview = {
{
name: 'transparent',
value:
'fixed repeating-conic-gradient(#CCC 0% 25%, var(--lux-color-background-default) 0% 50%) 50% / 20px 20px',
'fixed repeating-conic-gradient(#EFEFEF 0% 25%, var(--lux-color-background-default) 0% 50%) 50% / 20px 20px',
},
{
name: 'light',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import {
LuxHeading1,
LuxHeading2,
LuxParagraph,
type LuxSectionProps,
LuxSection as Section,
} 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 { type HTMLAttributes, type PropsWithChildren } from 'react';
import { VisualStates } from './visual/States';
import { createVisualRegressionStory, VisualRegressionWrapper } from '../../utils';

const LuxSection = (props: PropsWithChildren<LuxSectionProps> & HTMLAttributes<HTMLDivElement>) => (
<Section {...props} />
Expand All @@ -18,7 +21,6 @@ const meta = {
title: 'React Components/Section',
id: 'react-components-section',
component: LuxSection,
subcomponents: {},
parameters: {
tokens,
tokensPrefix: 'react-section',
Expand Down Expand Up @@ -56,7 +58,7 @@ export const Playground: Story = {
</LuxParagraph>
</div>,
<div>
<LuxHeading1>Morbi commodo</LuxHeading1>
<LuxHeading2>Morbi commodo</LuxHeading2>
<LuxParagraph>
Morbi commodo augue eget consequat tempus. Nulla scelerisque cursus fermentum. Aenean placerat ligula libero,
sit amet malesuada neque maximus et. Phasellus at massa nulla. Quisque sagittis tempor ante, quis sollicitudin
Expand All @@ -70,9 +72,25 @@ export const Playground: Story = {
],
},
parameters: {
backgrounds: {
default: 'canvas',
},
docs: {
sourceState: 'shown',
},
},
tags: ['!autodocs'],
};

export const Visual = createVisualRegressionStory(() => (
<>
<h4 className="utrecht-heading-3">Light</h4>
<VisualRegressionWrapper className="lux-theme--logius-light">
<VisualStates />
</VisualRegressionWrapper>
<h4 className="utrecht-heading-3">Dark</h4>
<VisualRegressionWrapper className="lux-theme--logius-dark">
<VisualStates />
</VisualRegressionWrapper>
</>
));
22 changes: 22 additions & 0 deletions packages/storybook/src/react-components/section/visual/States.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LuxHeading1, LuxHeading2, LuxParagraph, LuxSection } from '@lux-design-system/components-react';

export const VisualStates = () => (
<LuxSection>
<LuxHeading1>Lorem ipsum</LuxHeading1>
<LuxParagraph>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Dolor ante id varius, aenean eu faucibus vitae
malesuada. Viverra malesuada aliquam et placerat justo porta ipsum parturient. Cursus nostra varius efficitur
lobortis aliquam lectus bibendum.
</LuxParagraph>
<LuxHeading2>Morbi commodo</LuxHeading2>
<LuxParagraph>
Morbi commodo augue eget consequat tempus. Nulla scelerisque cursus fermentum. Aenean placerat ligula libero, sit
amet malesuada neque maximus et. Phasellus at massa nulla. Quisque sagittis tempor ante, quis sollicitudin nisi
vulputate eu. Curabitur eget ante a orci efficitur commodo. Fusce lobortis laoreet tincidunt. Nam a massa quis
risus vestibulum vulputate nec eget erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
inceptos himenaeos. Curabitur finibus semper congue. Integer in nulla venenatis quam luctus accumsan. Aliquam
molestie tincidunt erat a tincidunt. Donec posuere et dolor sit amet euismod. Praesent dolor justo, aliquet quis
nulla ac, ultrices dictum leo.
</LuxParagraph>
</LuxSection>
);
Loading