From 171e45c56417018acccc87a292f579c8fee04c89 Mon Sep 17 00:00:00 2001 From: Lauren Schaller Date: Thu, 5 May 2022 16:31:22 -0400 Subject: [PATCH] more stories Signed-off-by: Lauren Schaller --- .../DismissableBanner.stories.tsx | 74 +++++-------------- .../DismissableBanner/DismissableBanner.tsx | 2 +- .../SimpleStepper/SimpleStepper.stories.tsx | 25 +++++-- .../src/layout/InfoCard/InfoCard.stories.tsx | 30 ++++---- .../src/layout/InfoCard/InfoCard.tsx | 2 +- 5 files changed, 54 insertions(+), 79 deletions(-) diff --git a/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx b/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx index 449d4a987b..ac341071bf 100644 --- a/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx +++ b/packages/core-components/src/components/DismissableBanner/DismissableBanner.stories.tsx @@ -15,7 +15,7 @@ */ import React from 'react'; -import { DismissableBanner } from './DismissableBanner'; +import { DismissableBanner, Props } from './DismissableBanner'; import Typography from '@material-ui/core/Typography'; import { WebStorage } from '@backstage/core-app-api'; import { @@ -29,6 +29,12 @@ import { Link } from '../Link'; export default { title: 'Feedback/DismissableBanner', component: DismissableBanner, + argTypes: { + variant: { + options: ['info', 'error', 'warning'], + control: { type: 'select' }, + }, + }, }; let errorApi: ErrorApi; @@ -39,47 +45,27 @@ const createWebStorage = (): StorageApi => { }; const apis = [[storageApiRef, createWebStorage()] as const]; +const defaultArgs = { + message: 'This is a dismissable banner', + variant: 'info', + fixed: false, +}; -export const Default = () => ( +export const Default = (args: Props) => (
- +
); -export const Error = () => ( -
- - - -
-); +Default.args = defaultArgs; -export const EmojisIncluded = () => ( -
- - - -
-); - -export const WithLink = () => ( +export const WithLink = (args: Props) => (
This is a dismissable banner with a link:{' '} @@ -88,34 +74,10 @@ export const WithLink = () => ( } - variant="info" id="linked_dismissable" />
); -export const Fixed = () => ( -
- - - -
-); - -export const Warning = () => ( -
- - - -
-); +WithLink.args = defaultArgs; diff --git a/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx b/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx index 9ff7616c45..99113fcdb1 100644 --- a/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx +++ b/packages/core-components/src/components/DismissableBanner/DismissableBanner.tsx @@ -87,7 +87,7 @@ const useStyles = makeStyles( { name: 'BackstageDismissableBanner' }, ); -type Props = { +export type Props = { variant: 'info' | 'error' | 'warning'; message: ReactNode; id: string; diff --git a/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx b/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx index aa6846bc8f..2f3f26f23e 100644 --- a/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx +++ b/packages/core-components/src/components/SimpleStepper/SimpleStepper.stories.tsx @@ -16,7 +16,7 @@ import TextField from '@material-ui/core/TextField'; import React, { useState } from 'react'; -import { SimpleStepper } from './SimpleStepper'; +import { SimpleStepper, StepperProps } from './SimpleStepper'; import { SimpleStepperStep } from './SimpleStepperStep'; export default { @@ -24,8 +24,13 @@ export default { component: SimpleStepper, }; -export const Default = () => ( - +const defaultArgs = { + elevated: false, + activeStep: 0, +}; + +export const Default = (args: StepperProps) => ( +
This is the content for step 1
@@ -38,11 +43,13 @@ export const Default = () => (
); -export const ConditionalButtons = () => { +Default.args = defaultArgs; + +export const ConditionalButtons = (args: StepperProps) => { const [required, setRequired] = useState(false); return ( - + { ); }; -export const CompletionStep = () => { +ConditionalButtons.args = defaultArgs; + +export const CompletionStep = (args: StepperProps) => { return ( - +
This is the content for step 1
@@ -80,3 +89,5 @@ export const CompletionStep = () => {
); }; + +CompletionStep.args = defaultArgs; diff --git a/packages/core-components/src/layout/InfoCard/InfoCard.stories.tsx b/packages/core-components/src/layout/InfoCard/InfoCard.stories.tsx index 8dd8272f5a..e2c11690d1 100644 --- a/packages/core-components/src/layout/InfoCard/InfoCard.stories.tsx +++ b/packages/core-components/src/layout/InfoCard/InfoCard.stories.tsx @@ -18,7 +18,7 @@ import Grid from '@material-ui/core/Grid'; import Typography from '@material-ui/core/Typography'; import React, { PropsWithChildren } from 'react'; import { MemoryRouter } from 'react-router'; -import { InfoCard } from './InfoCard'; +import { InfoCard, Props } from './InfoCard'; const linkInfo = { title: 'Go to XYZ Location', link: '#' }; @@ -38,6 +38,11 @@ const text = ( ); +const defaultProps = { + title: 'Information Card', + subheader: 'Subheader', +}; + const Wrapper = ({ children }: PropsWithChildren<{}>) => ( @@ -48,24 +53,21 @@ const Wrapper = ({ children }: PropsWithChildren<{}>) => ( ); -export const Default = () => ( +export const Default = (args: Props) => ( - {text} + {text} ); -export const Subhead = () => ( +Default.args = defaultProps; + +export const LinkInFooter = (args: Props) => ( - - {text} - + {text} ); -export const LinkInFooter = () => ( - - - {text} - - -); +LinkInFooter.args = { + ...defaultProps, + deepLink: { title: 'Go to XYZ Location', link: '#' }, +}; diff --git a/packages/core-components/src/layout/InfoCard/InfoCard.tsx b/packages/core-components/src/layout/InfoCard/InfoCard.tsx index 256d60cfa2..831c8f95d9 100644 --- a/packages/core-components/src/layout/InfoCard/InfoCard.tsx +++ b/packages/core-components/src/layout/InfoCard/InfoCard.tsx @@ -125,7 +125,7 @@ export type InfoCardVariants = 'flex' | 'fullHeight' | 'gridItem'; * * `...` */ -type Props = { +export type Props = { title?: ReactNode; subheader?: ReactNode; divider?: boolean;