Debian Codegraph @

node/@patternfly/react-core/src/deprecated/components/Wizard/examples/WizardWithDrawer.tsx

raw
1 import { Fragment, useRef, useState } from 'react';
2 import {
3 Button,
4 DrawerActions,
5 DrawerCloseButton,
6 DrawerHead,
7 DrawerPanelContent,
8 DrawerColorVariant
9 } from '@patternfly/react-core';
10 import { Wizard as WizardDeprecated } from '@patternfly/react-core/deprecated';
11
12 export const WizardWithDrawer: React.FunctionComponent = () => {
13 const [isDrawerExpanded, setIsDrawerExpanded] = useState(false);
14
15 const drawerRef = useRef<HTMLSpanElement>(null);
16
17 const onExpandDrawer = () => {
18 drawerRef.current && drawerRef.current.focus();
19 };
20
21 const onOpenClick = () => {
22 setIsDrawerExpanded(true);
23 };
24
25 const onCloseClick = () => {
26 setIsDrawerExpanded(false);
27 };
28
29 const panel1Content = (
30 <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.secondary}>
31 <DrawerHead>
32 <span tabIndex={isDrawerExpanded ? 0 : -1} ref={drawerRef}>
33 drawer-panel-1 content
34 </span>
35 <DrawerActions>
36 <DrawerCloseButton onClick={onCloseClick} />
37 </DrawerActions>
38 </DrawerHead>
39 </DrawerPanelContent>
40 );
41
42 const panel2Content = (
43 <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.secondary}>
44 <DrawerHead>
45 <span tabIndex={0} ref={drawerRef}>
46 drawer-panel-2 content
47 </span>
48 <DrawerActions>
49 <DrawerCloseButton onClick={onCloseClick} />
50 </DrawerActions>
51 </DrawerHead>
52 </DrawerPanelContent>
53 );
54
55 const panel3Content = (
56 <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.secondary}>
57 <DrawerHead>
58 <span tabIndex={0} ref={drawerRef}>
59 drawer-panel-3 content
60 </span>
61 <DrawerActions>
62 <DrawerCloseButton onClick={onCloseClick} />
63 </DrawerActions>
64 </DrawerHead>
65 </DrawerPanelContent>
66 );
67
68 const drawerToggleButton = (
69 <Button isInline variant="link" onClick={onOpenClick}>
70 Open Drawer
71 </Button>
72 );
73
74 const steps = [
75 {
76 name: 'Information',
77 component: <p>Information step content</p>,
78 drawerPanelContent: panel1Content,
79 drawerToggleButton
80 },
81 {
82 name: 'Configuration',
83 steps: [
84 {
85 name: 'Substep A',
86 component: <p>Substep A content</p>,
87 drawerPanelContent: panel2Content,
88 drawerToggleButton
89 },
90 {
91 name: 'Substep B',
92 component: <p>Substep B content</p>,
93 drawerPanelContent: panel2Content,
94 drawerToggleButton
95 },
96 {
97 name: 'Substep C',
98 component: <p>Substep C content</p>,
99 drawerPanelContent: panel2Content,
100 drawerToggleButton
101 }
102 ]
103 },
104 {
105 name: 'Additional',
106 component: <p>Additional step content</p>,
107 drawerPanelContent: panel3Content,
108 drawerToggleButton
109 },
110 {
111 name: 'Review',
112 component: <p>Review step content</p>,
113 nextButtonText: 'Finish'
114 }
115 ];
116
117 const title = 'Wizard with drawer example';
118
119 return (
120 <Fragment>
121 <WizardDeprecated
122 height={400}
123 isDrawerExpanded={isDrawerExpanded}
124 onExpandDrawer={onExpandDrawer}
125 hasDrawer
126 navAriaLabel={`${title} steps`}
127 steps={steps}
128 />
129 </Fragment>
130 );
131 };