import fetchMock from 'fetch-mock' import Notification from '../js/shared/components/notification' import { postJSON } from '../js/infrastructure/fetch-json' import useAsync from '../js/shared/hooks/use-async' type Args = React.ComponentProps export const NotificationInfo = (args: Args) => { return } export const NotificationSuccess = (args: Args) => { return } export const NotificationWarning = (args: Args) => { return } export const NotificationError = (args: Args) => { return } export const NotificationWithActionBelowContent = (args: Args) => { return (

The CTA will always go below the content on small screens.

We can also opt to always put the CTA below the content on all screens

} isDismissible isActionBelowContent /> ) } export const NotificationWithTitle = (args: Args) => { return } export const NotificationWithAction = (args: Args) => { return } export const NotificationDismissible = (args: Args) => { return } export const APlainNotification = (args: Args) => { return } export const NotificationWithMultipleParagraphsAndActionAndDismissible = ( args: Args ) => { return (

Lorem ipsum

Dolor sit amet, consectetur adipiscing elit. Proin lacus velit, faucibus vitae feugiat sit amet, Some link iaculis ut mi.

Vel eros donec ac odio tempor orci dapibus ultrices in. Fermentum iaculis eu non diam phasellus.

Aliquam at tempor risus. Vestibulum bibendum ut

} /> ) } export const NotificationWithMultipleParagraphsAndDismissible = ( args: Args ) => { return (

Lorem ipsum

Dolor sit amet, consectetur adipiscing elit. Proin lacus velit, faucibus vitae feugiat sit amet, Some link iaculis ut mi.

Vel eros donec ac odio tempor orci dapibus ultrices in. Fermentum iaculis eu non diam phasellus.

Aliquam at tempor risus. Vestibulum bibendum ut

} /> ) } export const MultipleParagraphsAndAction = (args: Args) => { return (

Lorem ipsum

Dolor sit amet, consectetur adipiscing elit. Proin lacus velit, faucibus vitae feugiat sit amet, Some link iaculis ut mi.

Vel eros donec ac odio tempor orci dapibus ultrices in. Fermentum iaculis eu non diam phasellus.

Aliquam at tempor risus. Vestibulum bibendum ut

} /> ) } export const MultipleParagraphs = (args: Args) => { return (

Lorem ipsum

Dolor sit amet, consectetur adipiscing elit. Proin lacus velit, faucibus vitae feugiat sit amet, Some link iaculis ut mi.

Vel eros donec ac odio tempor orci dapibus ultrices in. Fermentum iaculis eu non diam phasellus.

Aliquam at tempor risus. Vestibulum bibendum ut

} /> ) } export const ShortText = (args: Args) => { return ( Lorem ipsum

} /> ) } export const ShortTextAndDismissible = (args: Args) => { return ( Lorem ipsum

} /> ) } export const ShortTextAndActionLinkAsButton = (args: Args) => { return ( Lorem ipsum

} /> ) } export const ShortTextAndActionAsLink = (args: Args) => { return ( Lorem ipsum

} action={An action} isDismissible={false} /> ) } export const ShortTextAndActionAsLinkButStyledAsButton = (args: Args) => { return ( Lorem ipsum

} action={ An action } isDismissible={false} /> ) } export const LongActionButton = (args: Args) => { return ( Action that has a lot of text } /> ) } export const LongActionLink = (args: Args) => { return ( Action that has a lot of text} /> ) } export const CustomIcon = (args: Args) => { return ( 🎉} /> ) } export const SuccessFlow = (args: Args) => { console.log('.....render') fetchMock.post( 'express:/test-success', { status: 200 }, { delay: 250, overwriteRoutes: true } ) const { isLoading, isSuccess, runAsync } = useAsync() function handleClick() { console.log('clicked') runAsync(postJSON('/test-success')).catch(console.error) } const ctaText = isLoading ? 'Processing' : 'Click' const action = ( ) const startNotification = ( This story shows 2 notifications, and it's up to the parent component to determine which to show. There's a successful request made after clicking the action and so the parent component then renders the success notification.

} /> ) const successNotification = ( Now follow this link to go home} type="success" content={

Success! You made a successful request.

} /> ) if (isSuccess) return successNotification return startNotification } export const ContentAsAString = (args: Args) => { return } export default { title: 'Shared / Components / Notification', component: Notification, args: { content: (

This can be any HTML passed to the component. For example, paragraphs, headers, code samples, links, etc are all supported.

), action: , isDismissible: true, }, }