From 42f75229c48ac14e5a19cf7f5452011c84340467 Mon Sep 17 00:00:00 2001 From: Jaap-Hein Wester Date: Wed, 20 Nov 2024 09:37:34 +0100 Subject: [PATCH] chore(docs): Fixes Design review button en Visual regression (#337) # Contents Fixes in documentatie nav Design review button en Visual regression story toegevoegd. ## Checklist - [x] New features/components and bugfixes are covered by tests - ~~[ ] Changesets are created~~ - ~~[ ] Definition of Done is checked~~ --------- Co-authored-by: Jaap-Hein Wester --- packages/storybook/config/preview.tsx | 2 + packages/storybook/config/themes.ts | 1 + .../src/react-components/button/button.mdx | 56 +++++++- .../button/button.stories.tsx | 136 +++++++++++++----- .../react-components/button/visual/States.tsx | 44 ++++++ .../button/visual/Variants.tsx | 11 ++ 6 files changed, 210 insertions(+), 40 deletions(-) create mode 100644 packages/storybook/src/react-components/button/visual/States.tsx create mode 100644 packages/storybook/src/react-components/button/visual/Variants.tsx diff --git a/packages/storybook/config/preview.tsx b/packages/storybook/config/preview.tsx index b3ee1f78d..5eea05ed4 100644 --- a/packages/storybook/config/preview.tsx +++ b/packages/storybook/config/preview.tsx @@ -27,6 +27,8 @@ const preview: Preview = { 'DigiD dark': 'lux-theme--digid-dark', 'Logius light': 'lux-theme--logius-light', 'Logius dark': 'lux-theme--logius-dark', + 'Mijn Aansluitingen light': 'lux-theme--eva-light', + 'Mijn Aansluitingen dark': 'lux-theme--eva-dark', 'Mijn Overheid light': 'lux-theme--mijnoverheid-light', 'Mijn Overheid dark': 'lux-theme--mijnoverheid-dark', 'NLdoc light': 'lux-theme--nldoc-light', diff --git a/packages/storybook/config/themes.ts b/packages/storybook/config/themes.ts index 24088da33..085a2a1a5 100644 --- a/packages/storybook/config/themes.ts +++ b/packages/storybook/config/themes.ts @@ -5,5 +5,6 @@ */ import '@lux-design-system/design-tokens/dist/digid/index-theme.css'; import '@lux-design-system/design-tokens/dist/logius/index-theme.css'; +import '@lux-design-system/design-tokens/dist/eva/index-theme.css'; import '@lux-design-system/design-tokens/dist/mijnoverheid/index-theme.css'; import '@lux-design-system/design-tokens/dist/nldoc/index-theme.css'; diff --git a/packages/storybook/src/react-components/button/button.mdx b/packages/storybook/src/react-components/button/button.mdx index d77052c7c..e4f8e4c81 100644 --- a/packages/storybook/src/react-components/button/button.mdx +++ b/packages/storybook/src/react-components/button/button.mdx @@ -1,4 +1,4 @@ -import { Canvas, Controls, Markdown, Meta } from "@storybook/blocks"; +import { Canvas, Controls, Description, Markdown, Meta } from "@storybook/blocks"; import markdown from "@utrecht/button-css/README.md?raw"; import * as ButtonStories from "./button.stories.tsx"; import { CitationDocumentation } from "../../utils/CitationDocumentation.tsx"; @@ -12,6 +12,8 @@ import { CitationDocumentation } from "../../utils/CitationDocumentation.tsx"; url="https://nl-design-system.github.io/utrecht/storybook-css/index.html?path=/docs/css-button--docs" /> +{/* TODO: New way of doc md */} + {markdown} ## Opmerkingen @@ -24,26 +26,68 @@ import { CitationDocumentation } from "../../utils/CitationDocumentation.tsx"; -## Small Button - - - ## Variants +### Primary / primary action button + + + +### Secondary / secondary action button + + + +### Tertiary / subtle button + + -## Button states +### Small Button + + + + +

States

+ +### Active + + +### Focus + + + +### Hover + + + +### Disabled + + + +### Busy + + + +### Toggle / Pressed + + ## Button With Icon +### At start position + + + +### At end position + + diff --git a/packages/storybook/src/react-components/button/button.stories.tsx b/packages/storybook/src/react-components/button/button.stories.tsx index 931bb6747..cce9b6c71 100644 --- a/packages/storybook/src/react-components/button/button.stories.tsx +++ b/packages/storybook/src/react-components/button/button.stories.tsx @@ -2,6 +2,10 @@ import { LuxButton } from '@lux-design-system/components-react'; import tokens from '@lux-design-system/design-tokens/dist/index.json'; import { useArgs } from '@storybook/preview-api'; import type { Meta, StoryFn, StoryObj } from '@storybook/react'; +import tokensDefinition from '@utrecht/button-css/src/tokens.json'; +import { InteractiveStates, PropertyStates } from './visual/States'; +import { Appearances, Sizes } from './visual/Variants'; +import { createDesignTokensStory, createVisualRegressionStory, VisualRegressionWrapper } from '../../utils'; type Story = StoryObj; @@ -12,6 +16,7 @@ const meta = { subcomponents: {}, parameters: { tokens, + tokensDefinition, tokensPrefix: 'utrecht-button', }, argTypes: { @@ -29,6 +34,11 @@ const meta = { description: 'Icon Position modifier', control: 'select', options: [undefined, 'start', 'end'], + table: { + defaultValue: { + summary: 'start', + }, + }, }, busy: { description: 'Busy indicator', @@ -40,19 +50,19 @@ const meta = { }, icon: { description: 'Icon Node', - control: 'object', + control: 'boolean', table: { type: { - summary: 'HTML Content', + summary: 'HTML/SVG Content / React Node', + detail: 'Use the boolean switch to show an Icon', }, }, }, - label: { - description: 'Label Node', - control: 'object', + children: { + description: 'Label (children)', table: { type: { - summary: 'HTML Content', + summary: 'HTML Content / React Node', }, }, }, @@ -63,8 +73,8 @@ export default meta; //TODO replace icon in #308 const ExampleIcon = ( - - + + ); @@ -76,9 +86,13 @@ const ButtonTemplate: Story = { icon: undefined, pressed: false, busy: false, - label: 'Klik hier!', + children: 'Button', }, - render: ({ ...args }) => {args['children']}, + render: ({ icon, children, ...args }: { icon: boolean; children: any; args: unknown }) => ( + + {children} + + ), }; const AllButtonVariantsTemplate: Story = { @@ -116,24 +130,12 @@ export const Playground: Story = { tags: ['!autodocs'], }; -export const SmallButton: Story = { - ...ButtonTemplate, - args: { - ...ButtonTemplate.args, - size: 'small', - }, - parameters: { - docs: { - sourceState: 'shown', - }, - }, -}; - export const Primary: Story = { + ...ButtonTemplate, name: 'Primary', args: { + ...ButtonTemplate.args, appearance: 'primary-action-button', - children: 'Primary Button', }, parameters: { docs: { @@ -145,10 +147,11 @@ export const Primary: Story = { }; export const Secondary: Story = { + ...ButtonTemplate, name: 'Secondary', args: { + ...ButtonTemplate.args, appearance: 'secondary-action-button', - children: 'Secondary Button', }, parameters: { docs: { @@ -160,10 +163,11 @@ export const Secondary: Story = { }; export const Tertiary: Story = { + ...ButtonTemplate, name: 'Tertiary', args: { + ...ButtonTemplate.args, appearance: 'subtle-button', - children: 'Tertiary Button', }, parameters: { docs: { @@ -174,6 +178,22 @@ export const Tertiary: Story = { }, }; +export const SmallButton: Story = { + ...ButtonTemplate, + name: 'Small', + args: { + ...ButtonTemplate.args, + size: 'small', + }, + parameters: { + docs: { + description: { + story: 'Een kleine variant zet je met `size="small"`.', + }, + }, + }, +}; + export const Active: Story = { ...AllButtonVariantsTemplate, name: 'Active', @@ -181,7 +201,7 @@ export const Active: Story = { pseudo: { active: true }, }, args: { - children: 'Active Button', + ...ButtonTemplate.args, }, }; @@ -192,7 +212,7 @@ export const Hover: Story = { pseudo: { hover: true }, }, args: { - children: 'Hover Button', + ...ButtonTemplate.args, }, }; @@ -203,7 +223,7 @@ export const Focus: Story = { pseudo: { focus: true, focusVisible: true }, }, args: { - children: 'Focus Button', + ...ButtonTemplate.args, }, }; @@ -211,7 +231,7 @@ export const Disabled: Story = { ...AllButtonVariantsTemplate, name: 'Disabled', args: { - children: 'Disabled Button', + ...ButtonTemplate.args, disabled: true, }, }; @@ -220,14 +240,14 @@ export const Busy: Story = { ...AllButtonVariantsTemplate, name: 'Busy', args: { - children: 'Busy Button', + ...ButtonTemplate.args, busy: true, }, parameters: { docs: { description: { - story: - 'Een busy button zet je met het `busy`-attribute (`true`/`false`, default: `undefined`). Toont een `wait` cursor en `aria-busy`-attribute.', + story: `Een busy button zet je met het \`busy\`-attribute (\`true\`/\`false\`, default: \`undefined\`). Toont een \`wait\` cursor en \`aria-busy\`-attribute. Dit gebruik je + bijvoorbeeld als een gebruiker met een knop een actie in gang zet die langer kan duren, zoals een download.`, }, }, }, @@ -237,6 +257,7 @@ export const Toggle: Story = { ...ButtonTemplate, name: 'Toggle', args: { + ...ButtonTemplate.args, appearance: 'primary-action-button', pressed: true, }, @@ -249,10 +270,20 @@ export const Toggle: Story = { return ( - Toggle Button {args.pressed ? 'pressed' : 'not pressed'} + Button {args.pressed ? 'pressed' : 'not pressed'} ); }, + argTypes: { + pressed: { + control: 'boolean', + }, + children: { + table: { + disable: true, + }, + }, + }, parameters: { docs: { description: { @@ -290,3 +321,40 @@ export const ButtonWithIconAtPositionEnd: Story = { }, }, }; + +export const DesignTokens = createDesignTokensStory(meta); + +export const Visual = createVisualRegressionStory(() => ( + <> +

Light

+
Logius
+ + + + + + +
MijnAansluitingen
+ + + + + + +

Dark

+
Logius
+ + + + + + +
MijnAansluitingen
+ + + + + + + +)); diff --git a/packages/storybook/src/react-components/button/visual/States.tsx b/packages/storybook/src/react-components/button/visual/States.tsx new file mode 100644 index 000000000..0452c3c19 --- /dev/null +++ b/packages/storybook/src/react-components/button/visual/States.tsx @@ -0,0 +1,44 @@ +import { LuxButton } from '@lux-design-system/components-react'; +import { Fragment } from 'react'; + +const appearances = ['primary-action', 'secondary-action', 'subtle']; + +export const InteractiveStates = () => ( + <> + {appearances.map((appearance) => ( + + + Active Button ({appearance}) + + + Focus Button ({appearance}) + + + Hover Button ({appearance}) + + + ))} + +); + +export const PropertyStates = () => ( + <> + {appearances.map((appearance) => ( + + + Disabled Button ({appearance}) + + + Busy Button ({appearance}) + + + Pressed Button ({appearance}) + + + ))} + +); diff --git a/packages/storybook/src/react-components/button/visual/Variants.tsx b/packages/storybook/src/react-components/button/visual/Variants.tsx new file mode 100644 index 000000000..4133fe91d --- /dev/null +++ b/packages/storybook/src/react-components/button/visual/Variants.tsx @@ -0,0 +1,11 @@ +import { LuxButton } from '@lux-design-system/components-react'; + +export const Appearances = () => ( + <> + Primary Action Button + Secondary Action Button + Subtle Button + +); + +export const Sizes = () => Small Button;