-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pageHeader): adds stepper component in pageHeader
- Loading branch information
Showing
4 changed files
with
315 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
core/components/organisms/pageHeader/__stories__/variants/withStepper.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import * as React from 'react'; | ||
import PageHeader from '../..//PageHeader'; | ||
import { Stepper, Button, Text } from '@/index'; | ||
import { text, boolean } from '@storybook/addon-knobs'; | ||
|
||
export const withStepper = () => { | ||
const title = text( | ||
'title', | ||
'Page title' | ||
); | ||
|
||
const stepperData = [ | ||
{ | ||
value: 'step_1', | ||
label: 'Step 1', | ||
}, | ||
{ | ||
value: 'step_2', | ||
label: 'Step 2' | ||
}, | ||
{ | ||
value: 'step_3', | ||
label: 'Step 3', | ||
} | ||
]; | ||
|
||
const seperator = boolean('seperator', true); | ||
|
||
const [active, setActive] = React.useState(0); | ||
const [completed, setCompleted] = React.useState(-1); | ||
|
||
const onChangeHandler = (activeStep: number) => { | ||
setActive(activeStep); | ||
}; | ||
|
||
const onClickHandler = () => { | ||
if (active > completed) setCompleted(active); | ||
active > completed ? setActive(active + 1) : setActive(completed + 1); | ||
}; | ||
|
||
const options = { | ||
title, | ||
seperator, | ||
stepper: <Stepper steps={stepperData} onChange={onChangeHandler} active={active} completed={completed} />, | ||
actions: ( | ||
<div style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> | ||
<span className="mr-4"><Text appearance="subtle">Meta data</Text></span> | ||
<Button appearance="primary" onClick={onClickHandler}>Next</Button> | ||
</div> | ||
) | ||
}; | ||
|
||
return ( | ||
<div className="w-100 p-6" style={{ background: '#f4f4f4' }}> | ||
<PageHeader {...options} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const customCode = `() => { | ||
const title = 'Page title'; | ||
const stepperData = [ | ||
{ | ||
value: 'step_1', | ||
label: 'Step 1', | ||
}, | ||
{ | ||
value: 'step_2', | ||
label: 'Step 2' | ||
}, | ||
{ | ||
value: 'step_3', | ||
label: 'Step 3', | ||
} | ||
]; | ||
const [active, setActive] = React.useState(0); | ||
const [completed, setCompleted] = React.useState(-1); | ||
const onChangeHandler = (activeStep) => { | ||
setActive(activeStep) | ||
}; | ||
const onClickHandler = () => { | ||
if (active > completed) setCompleted(active); | ||
active > completed ? setActive(active + 1) : setActive(completed + 1); | ||
} | ||
const options = { | ||
title, | ||
seperator: true, | ||
stepper: <Stepper steps={stepperData} onChange={onChangeHandler} active={active} completed={completed} />, | ||
actions: ( | ||
<div style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> | ||
<span className="mr-4"><Text appearance="subtle">Meta data</Text></span> | ||
<Button appearance="primary" onClick={onClickHandler}>Primary</Button> | ||
</div> | ||
) | ||
}; | ||
return ( | ||
<div className="w-100 p-6" style={{ background: '#f4f4f4' }}> | ||
<PageHeader {...options} /> | ||
</div> | ||
); | ||
}`; | ||
|
||
export default { | ||
title: 'Organisms|PageHeader/Level 0/Variants', | ||
component: PageHeader, | ||
parameters: { | ||
docs: { | ||
docPage: { | ||
customCode | ||
} | ||
} | ||
} | ||
}; |
177 changes: 177 additions & 0 deletions
177
core/components/organisms/pageHeader/__stories__/variants/withStepperL1.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import * as React from 'react'; | ||
import PageHeader from '../../PageHeader'; | ||
import { select, text, boolean } from '@storybook/addon-knobs'; | ||
import { Stepper, Button, Breadcrumbs, Badge, StatusHint } from '@/index'; | ||
import { action } from '@storybook/addon-actions'; | ||
|
||
export const withStepper = () => { | ||
const navigationPosition = select( | ||
'navigationPosition', | ||
['center', 'bottom'], | ||
'center' | ||
); | ||
const seperator = boolean('seperator', true); | ||
const title = text( | ||
'title', | ||
'Page title' | ||
); | ||
|
||
const stepperData = [ | ||
{ | ||
value: 'step_1', | ||
label: 'Step 1', | ||
}, | ||
{ | ||
value: 'step_2', | ||
label: 'Step 2' | ||
}, | ||
{ | ||
value: 'step_3', | ||
label: 'Step 3', | ||
} | ||
]; | ||
|
||
const breadcrumbData = [ | ||
{ | ||
label: 'Level 0', | ||
link: '/level0' | ||
}, | ||
{ | ||
label: 'Level 1', | ||
link: '/level1' | ||
} | ||
]; | ||
|
||
const [active, setActive] = React.useState(0); | ||
const [completed, setCompleted] = React.useState(-1); | ||
|
||
const onChangeHandler = (activeStep: number) => { | ||
setActive(activeStep); | ||
}; | ||
|
||
const onClickHandler = () => { | ||
if (active > completed) setCompleted(active); | ||
active > completed ? setActive(active + 1) : setActive(completed + 1); | ||
}; | ||
|
||
const options = { | ||
navigationPosition, | ||
title, | ||
seperator, | ||
stepper: <Stepper steps={stepperData} onChange={onChangeHandler} active={active} completed={completed} />, | ||
actions: ( | ||
<div style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> | ||
<Button appearance="primary" onClick={onClickHandler}>Next</Button> | ||
</div> | ||
), | ||
breadcrumbs: ( | ||
<Breadcrumbs | ||
list={breadcrumbData} | ||
onClick={link => action(`on-click: ${link}`)} | ||
/> | ||
), | ||
badge: ( | ||
<Badge appearance="secondary">Badge</Badge> | ||
), | ||
status: ( | ||
<StatusHint appearance="alert">Alert</StatusHint> | ||
), | ||
meta: ( | ||
<StatusHint appearance="default">Meta Data</StatusHint> | ||
) | ||
}; | ||
|
||
return ( | ||
<div className="w-100 p-6" style={{ background: '#f4f4f4' }}> | ||
<PageHeader {...options} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const customCode = `() => { | ||
const navigationPosition = 'center'; | ||
const title = 'Page title'; | ||
const stepperData = [ | ||
{ | ||
value: 'step_1', | ||
label: 'Step 1', | ||
}, | ||
{ | ||
value: 'step_2', | ||
label: 'Step 2' | ||
}, | ||
{ | ||
value: 'step_3', | ||
label: 'Step 3', | ||
} | ||
]; | ||
const breadcrumbData = [ | ||
{ | ||
label: 'Level 0', | ||
link: '/level0' | ||
}, | ||
{ | ||
label: 'Level 1', | ||
link: '/level1' | ||
} | ||
]; | ||
const [active, setActive] = React.useState(0); | ||
const [completed, setCompleted] = React.useState(-1); | ||
const onChangeHandler = (activeStep) => { | ||
setActive(activeStep) | ||
}; | ||
const onClickHandler = () => { | ||
if (active > completed) setCompleted(active); | ||
active > completed ? setActive(active + 1) : setActive(completed + 1); | ||
}; | ||
const options = { | ||
navigationPosition, | ||
title, | ||
seperator: true, | ||
stepper: <Stepper steps={stepperData} onChange={onChangeHandler} active={active} completed={completed} />, | ||
actions: ( | ||
<div style={{ display: 'flex', justifyContent: 'flex-end', alignItems: 'center' }}> | ||
<Button appearance="primary" onClick={onClickHandler}>Next</Button> | ||
</div> | ||
), | ||
breadcrumbs: ( | ||
<Breadcrumbs | ||
list={breadcrumbData} | ||
/> | ||
), | ||
badge: ( | ||
<Badge appearance="secondary">Badge</Badge> | ||
), | ||
status: ( | ||
<StatusHint appearance="alert">Alert</StatusHint> | ||
), | ||
meta: ( | ||
<StatusHint appearance="default">Meta Data</StatusHint> | ||
) | ||
}; | ||
return ( | ||
<div className="w-100 p-6" style={{ background: '#f4f4f4' }}> | ||
<PageHeader {...options} /> | ||
</div> | ||
); | ||
}`; | ||
|
||
export default { | ||
title: 'Organisms|PageHeader/Level 1/Variants', | ||
component: PageHeader, | ||
parameters: { | ||
docs: { | ||
docPage: { | ||
customCode | ||
} | ||
} | ||
} | ||
}; |