From 4cf5c942aabfafd4ca8560c4ea8c6a9ae1066b62 Mon Sep 17 00:00:00 2001 From: Benjamin Bourgeois Date: Thu, 13 Jan 2022 19:40:45 +0000 Subject: [PATCH] Typography stories : convert knobs and actions to controls / args (#13220) Convert Typography story in ui/components/ui/typography/typography.stories.js to use controls argType annotation - Add README.MDX - Story has argTypes that align with component api / props - All instances of @storybook/addon-knobs have been removed in favour of control args - All instances of @storybook/addon-actions have been removed in favour of action argType annotation --- ui/components/ui/typography/README.mdx | 16 +++++ .../ui/typography/typography.stories.js | 63 +++++++++++-------- 2 files changed, 54 insertions(+), 25 deletions(-) create mode 100644 ui/components/ui/typography/README.mdx diff --git a/ui/components/ui/typography/README.mdx b/ui/components/ui/typography/README.mdx new file mode 100644 index 000000000..1286a8b1c --- /dev/null +++ b/ui/components/ui/typography/README.mdx @@ -0,0 +1,16 @@ +import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; +import Typography from '.'; + +# Typography + + + + + + + + + +## Component API + + diff --git a/ui/components/ui/typography/typography.stories.js b/ui/components/ui/typography/typography.stories.js index 2f761bfcf..119860c25 100644 --- a/ui/components/ui/typography/typography.stories.js +++ b/ui/components/ui/typography/typography.stories.js @@ -1,52 +1,65 @@ import React from 'react'; -import { number, select, text } from '@storybook/addon-knobs'; import { COLORS, FONT_WEIGHT, TEXT_ALIGN, TYPOGRAPHY, } from '../../../helpers/constants/design-system'; +import README from './README.mdx'; import Typography from '.'; export default { title: 'Components/UI/Typography', id: __filename, + parameters: { + docs: { + page: README, + }, + }, + argTypes: { + color: { + control: { type: 'select' }, + options: COLORS, + defaultValue: COLORS.BLACK, + }, + align: { + control: { type: 'select' }, + options: TEXT_ALIGN, + defaultValue: TEXT_ALIGN.LEFT, + }, + fontWeight: { + control: { type: 'select' }, + options: FONT_WEIGHT, + defaultValue: FONT_WEIGHT.NORMAL, + }, + variant: { + control: { type: 'select' }, + options: TYPOGRAPHY, + defaultValue: TYPOGRAPHY.Paragraph, + }, + content: { + control: { type: 'text' }, + defaultValue: 'The quick orange fox jumped over the lazy dog.', + }, + }, }; -export const List = () => ( +export const DefaultStory = (args) => (
{Object.values(TYPOGRAPHY).map((variant) => (
- - {variant} - + {variant}
))}
); -export const TheQuickOrangeFox = () => ( +DefaultStory.storyName = 'List'; + +export const TheQuickOrangeFox = (args) => (
- - {text('content', 'The quick orange fox jumped over the lazy dog.')} - + {args.content}
);