|
| 1 | +import React from 'react'; |
| 2 | +import { Story, Meta } from '@storybook/react'; |
| 3 | + |
| 4 | +import { BaseContainer } from '../../Layout/GlintsContainer/GlintsContainer'; |
| 5 | +import { Bar, BarProps } from './Bar'; |
| 6 | +import { Colors, Typography } from '..'; |
| 7 | +import { StyledCustomHeadingWrapper } from './BarStyle'; |
| 8 | + |
| 9 | +(Bar as React.FunctionComponent<BarProps>).displayName = 'Bar'; |
| 10 | + |
| 11 | +export default { |
| 12 | + title: '@next/Bar', |
| 13 | + component: Bar, |
| 14 | + decorators: [ |
| 15 | + Story => ( |
| 16 | + <BaseContainer style={{ height: '200px' }}>{Story()}</BaseContainer> |
| 17 | + ), |
| 18 | + ], |
| 19 | +} as Meta; |
| 20 | + |
| 21 | +const Template: Story<BarProps> = args => { |
| 22 | + const primaryAction = { |
| 23 | + label: 'Yes', |
| 24 | + action: () => console.log('Primary action!'), |
| 25 | + }; |
| 26 | + const secondaryAction = { |
| 27 | + label: 'No', |
| 28 | + action: () => console.log('Secondary action!'), |
| 29 | + }; |
| 30 | + const tertiaryAction = { |
| 31 | + label: 'No', |
| 32 | + action: () => console.log('Tertiary action!'), |
| 33 | + }; |
| 34 | + return ( |
| 35 | + <Bar |
| 36 | + {...args} |
| 37 | + primaryAction={primaryAction} |
| 38 | + secondaryAction={secondaryAction} |
| 39 | + tertiaryAction={tertiaryAction} |
| 40 | + /> |
| 41 | + ); |
| 42 | +}; |
| 43 | + |
| 44 | +export const Interactive = Template.bind({}); |
| 45 | +Interactive.args = { |
| 46 | + heading: 'Heading', |
| 47 | + subheading: 'SubHeading', |
| 48 | + position: 'top', |
| 49 | +}; |
| 50 | +Interactive.parameters = { |
| 51 | + docs: { |
| 52 | + source: { |
| 53 | + code: ` |
| 54 | + <Bar |
| 55 | + heading="Heading" |
| 56 | + primaryAction={{ |
| 57 | + action: () => {console.log('Primary action!')}, |
| 58 | + label: 'Yes' |
| 59 | + }} |
| 60 | + secondaryAction={{ |
| 61 | + action: () => {console.log('Secondary action!')}, |
| 62 | + label: 'No' |
| 63 | + }} |
| 64 | + subheading="Subheading" |
| 65 | + tertiaryAction={{ |
| 66 | + action: () => {console.log('Tertiary action!')}, |
| 67 | + label: 'No' |
| 68 | + }} |
| 69 | + /> |
| 70 | + `, |
| 71 | + }, |
| 72 | + language: 'javascript', |
| 73 | + type: 'auto', |
| 74 | + }, |
| 75 | +}; |
| 76 | + |
| 77 | +const PrimaryActionOnlyTemplate: Story<BarProps> = args => { |
| 78 | + const primaryAction = { |
| 79 | + label: 'Yes', |
| 80 | + action: () => console.log('Primary action!'), |
| 81 | + }; |
| 82 | + return <Bar {...args} primaryAction={primaryAction} />; |
| 83 | +}; |
| 84 | + |
| 85 | +export const PrimaryActionOnly = PrimaryActionOnlyTemplate.bind({}); |
| 86 | +PrimaryActionOnly.args = { |
| 87 | + heading: 'Heading', |
| 88 | +}; |
| 89 | + |
| 90 | +const CustomHeadingTemplate: Story<BarProps> = args => { |
| 91 | + const headingMarkup = ( |
| 92 | + <StyledCustomHeadingWrapper> |
| 93 | + <Typography as="span">Status:</Typography> |
| 94 | + <Typography as="span" color={Colors.Orange.S86}> |
| 95 | + DRAFT |
| 96 | + </Typography> |
| 97 | + </StyledCustomHeadingWrapper> |
| 98 | + ); |
| 99 | + const primaryAction = { |
| 100 | + label: 'Yes', |
| 101 | + action: () => console.log('Yes'), |
| 102 | + }; |
| 103 | + const secondaryAction = { |
| 104 | + label: 'No', |
| 105 | + action: () => console.log('No'), |
| 106 | + }; |
| 107 | + |
| 108 | + return ( |
| 109 | + <Bar |
| 110 | + {...args} |
| 111 | + heading={headingMarkup} |
| 112 | + subheading={'Autosaved to draft'} |
| 113 | + primaryAction={primaryAction} |
| 114 | + secondaryAction={secondaryAction} |
| 115 | + /> |
| 116 | + ); |
| 117 | +}; |
| 118 | + |
| 119 | +export const CustomHeading = CustomHeadingTemplate.bind({}); |
0 commit comments