forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWizardGetCurrentStep.tsx
More file actions
89 lines (82 loc) · 3.39 KB
/
WizardGetCurrentStep.tsx
File metadata and controls
89 lines (82 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { useState } from 'react';
import {
DescriptionList,
DescriptionListGroup,
DescriptionListTerm,
DescriptionListDescription,
Wizard,
WizardStep,
WizardStepType
} from '@patternfly/react-core';
const CurrentStepDescriptionList = ({ currentStep }: { currentStep: WizardStepType | undefined }) => (
<DescriptionList isHorizontal isCompact aria-label={`${currentStep?.name} prop data`}>
<DescriptionListGroup>
<DescriptionListTerm>Index</DescriptionListTerm>
<DescriptionListDescription>{currentStep?.index}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>ID</DescriptionListTerm>
<DescriptionListDescription>{currentStep?.id}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Name</DescriptionListTerm>
<DescriptionListDescription>{currentStep?.name}</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Visited</DescriptionListTerm>
<DescriptionListDescription>{currentStep?.isVisited ? 'true' : 'false'}</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
);
export const GetCurrentStepWizard: React.FunctionComponent = () => {
const [currentStep, setCurrentStep] = useState<WizardStepType>();
const onStepChange = (_event: React.MouseEvent<HTMLButtonElement>, currentStep: WizardStepType) =>
setCurrentStep(currentStep);
return (
<Wizard height={400} title="Get current step wizard" onStepChange={onStepChange}>
<WizardStep name="Step 1" id="get-current-step-1">
{currentStep ? <CurrentStepDescriptionList currentStep={currentStep} /> : 'Step 1 content'}
</WizardStep>
<WizardStep
name="Step 2"
id="get-current-step-2"
isDisabled
steps={[
<WizardStep name="Substep 1" id="get-current-substep-1" key="get-current-substep-1">
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>,
<WizardStep name="Substep 2" id="get-current-substep-2" key="get-current-substep-2">
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>
]}
/>
<WizardStep
name="Step 3"
id="get-current-step-3"
steps={[
<WizardStep name="Substep 3" id="get-current-substep-3" key="get-current-substep-3">
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>,
<WizardStep name="Substep 4" id="get-current-substep-4" key="get-current-substep-4">
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>
]}
/>
<WizardStep
name="Step 4"
id="get-current-step-4"
steps={[
<WizardStep name="Substep 5" id="get-current-substep-5" key="get-current-substep-5" isHidden>
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>,
<WizardStep name="Substep 6" id="get-current-substep-6" key="get-current-substep-6">
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>
]}
/>
<WizardStep name="Review" id="get-current-review-step" footer={{ nextButtonText: 'Finish' }}>
<CurrentStepDescriptionList currentStep={currentStep} />
</WizardStep>
</Wizard>
);
};