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';
6
6
7
7
type Props = {
8
8
number : number ;
9
+ name ?: string ;
9
10
} ;
10
11
11
12
const 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';
6
6
type Props = {
7
7
number : number ;
8
8
withCallback ?: boolean ;
9
+ name ?: string ;
9
10
} ;
10
11
11
12
const Container = styled ( 'div' ) `
Original file line number Diff line number Diff line change
1
+ import { styled } from 'goober' ;
1
2
import * as React from 'react' ;
2
3
3
4
import { Wizard } from '../../../../dist' ;
4
5
import { AsyncStep , Footer , Step } from '../../../components' ;
6
+ import Sidebar from '../../../components/sidebar' ;
5
7
import Section from '../../common/section' ;
6
8
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
+
7
19
const SimpleSection : React . FC = ( ) => {
8
20
return (
9
21
< Section title = "Simple wizard" description = "mix of async and sync steps" >
10
22
< Wizard
11
23
footer = { < Footer /> }
24
+ sidebar = { < Sidebar /> }
12
25
onStepChange = { ( stepIndex ) => alert ( `New step index is ${ stepIndex } ` ) }
26
+ sidebarAndStepWrapper = { < Flex /> }
13
27
>
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" />
18
32
</ Wizard >
19
33
</ Section >
20
34
) ;
You can’t perform that action at this time.
0 commit comments