File tree Expand file tree Collapse file tree 4 files changed +73
-4
lines changed Expand file tree Collapse file tree 4 files changed +73
-4
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { useMockMutation } from '../hooks';
66
77type Props = {
88 number : number ;
9+ name ?: string ;
910} ;
1011
1112const MOCK = [
Original file line number Diff line number Diff line change 1+ import { styled } from 'goober' ;
2+ import * as React from 'react' ;
3+
4+ import { useWizard } from '../../dist' ;
5+ import { Button } from '../modules/common' ;
6+
7+ export const Nav = styled ( 'nav' ) `
8+ display: flex;
9+ justify-content: center;
10+ flex-direction: column;
11+ gap: 0;
12+
13+ & > ul {
14+ list-style: none;
15+ margin: 0;
16+ padding: 0;
17+ }
18+
19+ @media screen and (min-width: 768px) {
20+ flex-direction: row;
21+ gap: 1rem;
22+
23+ & > p {
24+ margin: initial;
25+ }
26+ }
27+ ` ;
28+
29+ const Sidebar : React . FC = ( ) => {
30+ const { activeStep, stepCount, goToStep, stepNames } = useWizard ( ) ;
31+
32+ return (
33+ < Nav >
34+ { stepCount > 0 && (
35+ < ul >
36+ { stepNames . map ( ( stepName , index ) => (
37+ < li key = { index } >
38+ < Button
39+ label = { stepName . name }
40+ onClick = { ( ) => goToStep ( stepName . number - 1 ) }
41+ disabled = { stepName . number - 1 > activeStep }
42+ >
43+ { stepName . name }
44+ </ Button >
45+ </ li >
46+ ) ) }
47+ </ ul >
48+ ) }
49+ </ Nav >
50+ ) ;
51+ } ;
52+
53+ export default Sidebar ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { useWizard } from '../../dist';
66type Props = {
77 number : number ;
88 withCallback ?: boolean ;
9+ name ?: string ;
910} ;
1011
1112const Container = styled ( 'div' ) `
Original file line number Diff line number Diff line change 1+ import { styled } from 'goober' ;
12import * as React from 'react' ;
23
34import { Wizard } from '../../../../dist' ;
45import { AsyncStep , Footer , Step } from '../../../components' ;
6+ import Sidebar from '../../../components/sidebar' ;
57import Section from '../../common/section' ;
68
9+ const Flex = styled ( 'div' ) `
10+ display: flex;
11+ width: 100%;
12+ gap: 1rem;
13+
14+ & > :nth-child(2) {
15+ flex-grow: 1;
16+ }
17+ ` ;
18+
719const SimpleSection : React . FC = ( ) => {
820 return (
921 < Section title = "Simple wizard" description = "mix of async and sync steps" >
1022 < Wizard
1123 footer = { < Footer /> }
24+ sidebar = { < Sidebar /> }
1225 onStepChange = { ( stepIndex ) => alert ( `New step index is ${ stepIndex } ` ) }
26+ sidebarAndStepWrapper = { < Flex /> }
1327 >
14- < AsyncStep number = { 1 } />
15- < Step number = { 2 } />
16- < AsyncStep number = { 3 } />
17- < Step number = { 4 } />
28+ < AsyncStep number = { 1 } name = "Async Step 1" />
29+ < Step number = { 2 } name = "Step 2" />
30+ < AsyncStep number = { 3 } name = "Async Step 3" />
31+ < Step number = { 4 } name = "Step 4" />
1832 </ Wizard >
1933 </ Section >
2034 ) ;
You can’t perform that action at this time.
0 commit comments