From a08291b1586858fc894a27d56f55f87a88f8dbd3 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Wed, 20 Apr 2022 19:24:21 +0200 Subject: refactor(storybook): reorganize design system Add more stories for each components and change some components categories for better organization. --- .../molecules/layout/branding.stories.tsx | 46 +++++++++++---- src/components/molecules/layout/branding.tsx | 4 +- src/components/molecules/layout/card.module.scss | 5 +- src/components/molecules/layout/card.stories.tsx | 69 +++++++++++++++++++--- src/components/molecules/layout/card.tsx | 2 +- .../molecules/layout/flipping-logo.module.scss | 59 ------------------ .../molecules/layout/flipping-logo.stories.tsx | 66 --------------------- .../molecules/layout/flipping-logo.test.tsx | 25 -------- src/components/molecules/layout/flipping-logo.tsx | 48 --------------- src/components/molecules/layout/meta.stories.tsx | 11 ++-- src/components/molecules/layout/widget.module.scss | 5 ++ src/components/molecules/layout/widget.stories.tsx | 46 +++++++++++---- 12 files changed, 147 insertions(+), 239 deletions(-) delete mode 100644 src/components/molecules/layout/flipping-logo.module.scss delete mode 100644 src/components/molecules/layout/flipping-logo.stories.tsx delete mode 100644 src/components/molecules/layout/flipping-logo.test.tsx delete mode 100644 src/components/molecules/layout/flipping-logo.tsx (limited to 'src/components/molecules/layout') diff --git a/src/components/molecules/layout/branding.stories.tsx b/src/components/molecules/layout/branding.stories.tsx index 726ba26..1637c99 100644 --- a/src/components/molecules/layout/branding.stories.tsx +++ b/src/components/molecules/layout/branding.stories.tsx @@ -1,10 +1,13 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; import { IntlProvider } from 'react-intl'; -import BrandingComponent from './branding'; +import Branding from './branding'; +/** + * Branding - Storybook Meta + */ export default { - title: 'Molecules/Layout', - component: BrandingComponent, + title: 'Molecules/Layout/Branding', + component: Branding, args: { isHome: false, }, @@ -53,6 +56,7 @@ export default { required: true, }, }, + unoptimized: { table: { disable: true } }, withLink: { control: { type: 'boolean', @@ -68,16 +72,38 @@ export default { }, }, }, -} as ComponentMeta; + decorators: [ + (Story) => ( + + + + ), + ], +} as ComponentMeta; -const Template: ComponentStory = (args) => ( - - - +const Template: ComponentStory = (args) => ( + ); -export const Branding = Template.bind({}); -Branding.args = { +/** + * Branding Stories - Default + */ +export const Default = Template.bind({}); +Default.args = { title: 'Website title', photo: 'http://placeimg.com/640/480', + // @ts-ignore - Needed because of the placeholder image. + unoptimized: true, +}; + +/** + * Branding Stories - With baseline + */ +export const WithBaseline = Template.bind({}); +WithBaseline.args = { + title: 'Website title', + baseline: 'Maiores corporis qui', + photo: 'http://placeimg.com/640/480', + // @ts-ignore - Needed because of the placeholder image. + unoptimized: true, }; diff --git a/src/components/molecules/layout/branding.tsx b/src/components/molecules/layout/branding.tsx index 9fe89e7..423c54f 100644 --- a/src/components/molecules/layout/branding.tsx +++ b/src/components/molecules/layout/branding.tsx @@ -2,8 +2,8 @@ import Heading from '@components/atoms/headings/heading'; import Link from 'next/link'; import { FC } from 'react'; import { useIntl } from 'react-intl'; +import FlippingLogo, { type FlippingLogoProps } from '../images/flipping-logo'; import styles from './branding.module.scss'; -import FlippingLogo, { type FlippingLogoProps } from './flipping-logo'; export type BrandingProps = Pick & { /** @@ -35,6 +35,7 @@ const Branding: FC = ({ photo, title, withLink = false, + ...props }) => { const intl = useIntl(); const altText = intl.formatMessage( @@ -61,6 +62,7 @@ const Branding: FC = ({ altText={altText} logoTitle={logoTitle} photo={photo} + {...props} /> ; +} as ComponentMeta; -const Template: ComponentStory = (args) => ( - -); +const Template: ComponentStory = (args) => ; const cover = { alt: 'A picture', height: 480, src: 'http://placeimg.com/640/480', width: 640, + unoptimized: true, }; const meta = [ @@ -92,10 +96,57 @@ const meta = [ }, ]; -export const Card = Template.bind({}); -Card.args = { +/** + * Card Stories - Default + */ +export const Default = Template.bind({}); +Default.args = { + title: 'Veritatis dicta quod', + titleLevel: 2, + url: '#', +}; + +/** + * Card Stories - With cover + */ +export const WithCover = Template.bind({}); +WithCover.args = { + cover, + title: 'Veritatis dicta quod', + titleLevel: 2, + url: '#', +}; + +/** + * Card Stories - With meta + */ +export const WithMeta = Template.bind({}); +WithMeta.args = { + meta, + title: 'Veritatis dicta quod', + titleLevel: 2, + url: '#', +}; + +/** + * Card Stories - With tagline + */ +export const WithTagline = Template.bind({}); +WithTagline.args = { + tagline: 'Ullam accusantium ipsa', + title: 'Veritatis dicta quod', + titleLevel: 2, + url: '#', +}; + +/** + * Card Stories - With all data + */ +export const WithAll = Template.bind({}); +WithAll.args = { cover, meta, + tagline: 'Ullam accusantium ipsa', title: 'Veritatis dicta quod', titleLevel: 2, url: '#', diff --git a/src/components/molecules/layout/card.tsx b/src/components/molecules/layout/card.tsx index 89f100e..15927e9 100644 --- a/src/components/molecules/layout/card.tsx +++ b/src/components/molecules/layout/card.tsx @@ -93,7 +93,7 @@ const Card: FC = ({ {title} -
{tagline}
+ {tagline &&
{tagline}
} {meta && (