Debian Codegraph @

node/@patternfly/react-core/src/components/NotificationDrawer/examples/NotificationDrawerLightweight.tsx

raw
1 import { useState } from 'react';
2 import {
3 Button,
4 EmptyState,
5 EmptyStateBody,
6 EmptyStateFooter,
7 EmptyStateVariant,
8 NotificationDrawer,
9 NotificationDrawerBody,
10 NotificationDrawerHeader,
11 NotificationDrawerGroup,
12 NotificationDrawerGroupList,
13 NotificationDrawerList,
14 NotificationDrawerListItem,
15 NotificationDrawerListItemBody,
16 NotificationDrawerListItemHeader,
17 EmptyStateActions
18 } from '@patternfly/react-core';
19 import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
20
21 export const NotificationDrawerLightweight: React.FunctionComponent = () => {
22 const [firstGroupExpanded, setFirstGroupExpanded] = useState(false);
23 const [secondGroupExpanded, setSecondGroupExpanded] = useState(true);
24 const [thirdGroupExpanded, setThirdGroupExpanded] = useState(false);
25
26 const toggleFirstDrawer = (_event: any, value: boolean) => {
27 setFirstGroupExpanded(value);
28 setSecondGroupExpanded(false);
29 setThirdGroupExpanded(false);
30 };
31
32 const toggleSecondDrawer = (_event: any, value: boolean) => {
33 setSecondGroupExpanded(value);
34 setFirstGroupExpanded(false);
35 setThirdGroupExpanded(false);
36 };
37
38 const toggleThirdDrawer = (_event: any, value: boolean) => {
39 setThirdGroupExpanded(value);
40 setSecondGroupExpanded(false);
41 setFirstGroupExpanded(false);
42 };
43
44 const onDrawerClose = (_event: KeyboardEvent | React.MouseEvent<Element, MouseEvent>) => {
45 // do something cool in a callback
46 };
47
48 return (
49 <NotificationDrawer>
50 <NotificationDrawerHeader onClose={(event) => onDrawerClose(event)} />
51 <NotificationDrawerBody>
52 <NotificationDrawerGroupList>
53 <NotificationDrawerGroup
54 title="First notification group"
55 isExpanded={firstGroupExpanded}
56 count={4}
57 isRead={true}
58 onExpand={toggleFirstDrawer}
59 >
60 <NotificationDrawerList
61 isHidden={!firstGroupExpanded}
62 aria-label="Notifications in the first lightweight group"
63 >
64 <NotificationDrawerListItem variant="info">
65 <NotificationDrawerListItemHeader
66 variant="info"
67 title="Info notification title"
68 srTitle="Info notification:"
69 />
70 <NotificationDrawerListItemBody timestamp="5 minutes ago">
71 This is an info notification description.
72 </NotificationDrawerListItemBody>
73 </NotificationDrawerListItem>
74 <NotificationDrawerListItem variant="danger">
75 <NotificationDrawerListItemHeader
76 variant="danger"
77 title="Danger notification title. This is a long title to show how the title will wrap if it is long and wraps to multiple lines."
78 srTitle="Danger notification:"
79 />
80 <NotificationDrawerListItemBody timestamp="10 minutes ago">
81 This is a danger notification description. This is a long description to show how the title will wrap
82 if it is long and wraps to multiple lines.
83 </NotificationDrawerListItemBody>
84 </NotificationDrawerListItem>
85 <NotificationDrawerListItem variant="warning">
86 <NotificationDrawerListItemHeader
87 variant="warning"
88 title="Warning notification title"
89 srTitle="Warning notification:"
90 />
91 <NotificationDrawerListItemBody timestamp="20 minutes ago">
92 This is a warning notification description.
93 </NotificationDrawerListItemBody>
94 </NotificationDrawerListItem>
95 <NotificationDrawerListItem variant="success">
96 <NotificationDrawerListItemHeader
97 variant="success"
98 title="Success notification title"
99 srTitle="Success notification:"
100 />
101 <NotificationDrawerListItemBody timestamp="30 minutes ago">
102 This is a success notification description.
103 </NotificationDrawerListItemBody>
104 </NotificationDrawerListItem>
105 </NotificationDrawerList>
106 </NotificationDrawerGroup>
107 <NotificationDrawerGroup
108 title="Second notification group"
109 isExpanded={secondGroupExpanded}
110 count={4}
111 isRead={true}
112 onExpand={toggleSecondDrawer}
113 >
114 <NotificationDrawerList
115 isHidden={!secondGroupExpanded}
116 aria-label="Notifications in the second lightweight group"
117 >
118 <NotificationDrawerListItem variant="info">
119 <NotificationDrawerListItemHeader
120 variant="info"
121 title="Info notification title w/action"
122 srTitle="Info notification:"
123 >
124 <Button variant="link">Action</Button>
125 </NotificationDrawerListItemHeader>
126 <NotificationDrawerListItemBody timestamp="5 minutes ago">
127 This is an info notification description.
128 </NotificationDrawerListItemBody>
129 </NotificationDrawerListItem>
130 <NotificationDrawerListItem variant="danger">
131 <NotificationDrawerListItemHeader
132 variant="danger"
133 title="Danger notification title. This is a long title to show how the title will wrap if it is long and wraps to multiple lines."
134 srTitle="Danger notification:"
135 />
136 <NotificationDrawerListItemBody timestamp="10 minutes ago">
137 This is a danger notification description. This is a long description to show how the title will wrap
138 if it is long and wraps to multiple lines.
139 </NotificationDrawerListItemBody>
140 </NotificationDrawerListItem>
141 <NotificationDrawerListItem variant="warning">
142 <NotificationDrawerListItemHeader
143 variant="warning"
144 title="Warning notification title"
145 srTitle="Warning notification:"
146 />
147 <NotificationDrawerListItemBody timestamp="20 minutes ago">
148 This is a warning notification description.
149 </NotificationDrawerListItemBody>
150 </NotificationDrawerListItem>
151 <NotificationDrawerListItem variant="success">
152 <NotificationDrawerListItemHeader
153 variant="success"
154 title="Success notification title"
155 srTitle="Success notification:"
156 />
157 <NotificationDrawerListItemBody timestamp="30 minutes ago">
158 This is a success notification description.
159 </NotificationDrawerListItemBody>
160 </NotificationDrawerListItem>
161 </NotificationDrawerList>
162 </NotificationDrawerGroup>
163 <NotificationDrawerGroup
164 title="Third notification group"
165 isExpanded={thirdGroupExpanded}
166 count={0}
167 isRead={true}
168 onExpand={toggleThirdDrawer}
169 >
170 <NotificationDrawerList
171 isHidden={!thirdGroupExpanded}
172 aria-label="Notifications in the third lightweight group"
173 >
174 <EmptyState
175 headingLevel="h2"
176 titleText="No alerts found"
177 icon={SearchIcon}
178 variant={EmptyStateVariant.full}
179 >
180 <EmptyStateBody>
181 There are currently no critical alerts firing. There may be firing alerts of other severities or
182 silenced critical alerts however.
183 </EmptyStateBody>
184 <EmptyStateFooter>
185 <EmptyStateActions>
186 <Button variant="link">Action</Button>
187 </EmptyStateActions>
188 </EmptyStateFooter>
189 </EmptyState>
190 </NotificationDrawerList>
191 </NotificationDrawerGroup>
192 </NotificationDrawerGroupList>
193 </NotificationDrawerBody>
194 </NotificationDrawer>
195 );
196 };