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