import { map } from 'lodash'; import React from 'react'; import { Meta, Story } from '@storybook/react'; import * as d3Scale from 'd3-scale'; import VerticalTabs, { IVerticalTabsProps } from './VerticalTabs'; import Lines from '../Lines/Lines'; import SuccessIcon from '../Icon/SuccessIcon/SuccessIcon'; import WarningIcon from '../Icon/WarningIcon/WarningIcon'; //πŸ‘‡ Provide Storybook with the component name, 'section', any subcomponents and a description export default { title: 'Navigation/VerticalTabs', component: VerticalTabs, parameters: { docs: { description: { component: VerticalTabs.peek.description, }, }, }, args: VerticalTabs.defaultProps, } as Meta; //πŸ‘‡ Destructure any child components that we will need const { Tab, Title } = VerticalTabs; //πŸ‘‡ Add a key prop to each child element of the array function addKeys(children: any) { return map(children, (child, index) => ({ ...child, key: index })); } //πŸ‘‡ Create a β€œtemplate” of how args map to rendering const Template: Story = (args) => { return (
); }; //πŸ‘‡ Each story then reuses that template /** Default: Title as Prop */ export const Basic = Template.bind({}); Basic.args = { children: addKeys([ One content, Two content, Three content, Four content, ]), }; /** Title as Child */ export const TitleAsChild = Template.bind({}); TitleAsChild.args = { children: addKeys([ One One content , Two Two content , Three Three content , Four Four content , ]), }; /** Complex Title as Child */ export const ComplexTitleAsChild = Template.bind({}); const dataSet = [ { x: 'OR', y: 1 }, { x: 'CA', y: 0 }, { x: 'WA', y: 3 }, { x: 'NY', y: 2 }, { x: 'TX', y: 1 }, { x: 'WV', y: 3 }, ]; const width = 200; const height = 50; const xScale = d3Scale.scalePoint().domain(map(dataSet, 'x')).range([0, width]); const yScale = d3Scale.scaleLinear().domain([0, 4]).range([height, 0]); const titleThree = (

Performance

); ComplexTitleAsChild.args = { children: addKeys([ <h2 style={{ margin: 0 }}>One</h2> <SuccessIcon /> <span style={{ fontWeight: 'normal', marginLeft: '5px', }} > Lorem ipsum dolor sit amet, consectetur adipiscing elit. </span> One content ,

Two

Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Two content
, {titleThree} Three content , Four Four content , ]), };