@patternfly/react-core 4.208.12 → 4.210.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.d.ts.map +1 -1
  3. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.js +1 -1
  4. package/dist/esm/components/ClipboardCopy/ClipboardCopyButton.js.map +1 -1
  5. package/dist/esm/components/Select/SelectMenu.d.ts +3 -1
  6. package/dist/esm/components/Select/SelectMenu.d.ts.map +1 -1
  7. package/dist/esm/components/Select/SelectMenu.js.map +1 -1
  8. package/dist/esm/components/Tabs/Tabs.d.ts +3 -1
  9. package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
  10. package/dist/esm/components/Tabs/Tabs.js +2 -2
  11. package/dist/esm/components/Tabs/Tabs.js.map +1 -1
  12. package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
  13. package/dist/esm/components/Wizard/Wizard.js +3 -3
  14. package/dist/esm/components/Wizard/Wizard.js.map +1 -1
  15. package/dist/esm/components/Wizard/WizardNavItem.d.ts +2 -0
  16. package/dist/esm/components/Wizard/WizardNavItem.d.ts.map +1 -1
  17. package/dist/esm/components/Wizard/WizardNavItem.js +2 -2
  18. package/dist/esm/components/Wizard/WizardNavItem.js.map +1 -1
  19. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.d.ts.map +1 -1
  20. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.js +1 -1
  21. package/dist/js/components/ClipboardCopy/ClipboardCopyButton.js.map +1 -1
  22. package/dist/js/components/Select/SelectMenu.d.ts +3 -1
  23. package/dist/js/components/Select/SelectMenu.d.ts.map +1 -1
  24. package/dist/js/components/Select/SelectMenu.js.map +1 -1
  25. package/dist/js/components/Tabs/Tabs.d.ts +3 -1
  26. package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
  27. package/dist/js/components/Tabs/Tabs.js +2 -2
  28. package/dist/js/components/Tabs/Tabs.js.map +1 -1
  29. package/dist/js/components/Wizard/Wizard.d.ts.map +1 -1
  30. package/dist/js/components/Wizard/Wizard.js +3 -3
  31. package/dist/js/components/Wizard/Wizard.js.map +1 -1
  32. package/dist/js/components/Wizard/WizardNavItem.d.ts +2 -0
  33. package/dist/js/components/Wizard/WizardNavItem.d.ts.map +1 -1
  34. package/dist/js/components/Wizard/WizardNavItem.js +2 -2
  35. package/dist/js/components/Wizard/WizardNavItem.js.map +1 -1
  36. package/dist/umd/react-core.js +8 -8
  37. package/dist/umd/react-core.min.css +75 -75
  38. package/dist/umd/react-core.min.js +2 -2
  39. package/package.json +5 -5
  40. package/src/components/ClipboardCopy/ClipboardCopyButton.tsx +2 -0
  41. package/src/components/Drawer/examples/Drawer.md +19 -1354
  42. package/src/components/Drawer/examples/DrawerAdditionalSectionAboveContent.tsx +59 -0
  43. package/src/components/Drawer/examples/DrawerBasic.tsx +57 -0
  44. package/src/components/Drawer/examples/DrawerBasicInline.tsx +57 -0
  45. package/src/components/Drawer/examples/DrawerBreakpoint.tsx +57 -0
  46. package/src/components/Drawer/examples/DrawerInlinePanelLeft.tsx +57 -0
  47. package/src/components/Drawer/examples/DrawerInlinePanelRight.tsx +57 -0
  48. package/src/components/Drawer/examples/DrawerLightGray.tsx +107 -0
  49. package/src/components/Drawer/examples/DrawerModifiedContentPadding.tsx +59 -0
  50. package/src/components/Drawer/examples/DrawerModifiedPanelPadding.tsx +57 -0
  51. package/src/components/Drawer/examples/DrawerPanelBottom.tsx +59 -0
  52. package/src/components/Drawer/examples/DrawerPanelLeft.tsx +57 -0
  53. package/src/components/Drawer/examples/DrawerPanelRight.tsx +57 -0
  54. package/src/components/Drawer/examples/DrawerResizableOnBottom.tsx +58 -0
  55. package/src/components/Drawer/examples/DrawerResizableOnInline.tsx +56 -0
  56. package/src/components/Drawer/examples/DrawerResizableOnLeft.tsx +57 -0
  57. package/src/components/Drawer/examples/DrawerResizableOnRight.tsx +62 -0
  58. package/src/components/Drawer/examples/DrawerStackedContentBodyElements.tsx +60 -0
  59. package/src/components/Drawer/examples/DrawerStatic.tsx +57 -0
  60. package/src/components/Select/SelectMenu.tsx +1 -1
  61. package/src/components/Tabs/Tabs.tsx +5 -1
  62. package/src/components/Tabs/__tests__/Tabs.test.tsx +40 -1
  63. package/src/components/Wizard/Wizard.tsx +3 -0
  64. package/src/components/Wizard/WizardNavItem.tsx +4 -0
  65. package/src/components/Wizard/__tests__/Wizard.test.tsx +6 -3
  66. package/src/components/Wizard/__tests__/__snapshots__/Wizard.test.tsx.snap +6 -0
  67. package/src/demos/Tabs.md +53 -57
@@ -12,7 +12,7 @@ propComponents:
12
12
  DrawerHead,
13
13
  DrawerActions,
14
14
  DrawerCloseButton,
15
- DrawerColorVariant
15
+ DrawerColorVariant,
16
16
  ]
17
17
  section: components
18
18
  ---
@@ -21,1427 +21,92 @@ section: components
21
21
 
22
22
  ### Basic
23
23
 
24
- ```js
25
- import React from 'react';
26
- import {
27
- Drawer,
28
- DrawerPanelContent,
29
- DrawerContent,
30
- DrawerContentBody,
31
- DrawerHead,
32
- DrawerActions,
33
- DrawerCloseButton,
34
- Button
35
- } from '@patternfly/react-core';
36
-
37
- class SimpleDrawer extends React.Component {
38
- constructor(props) {
39
- super(props);
40
- this.state = {
41
- isExpanded: false
42
- };
43
- this.drawerRef = React.createRef();
44
-
45
- this.onExpand = () => {
46
- this.drawerRef.current && this.drawerRef.current.focus();
47
- };
48
-
49
- this.onClick = () => {
50
- const isExpanded = !this.state.isExpanded;
51
- this.setState({
52
- isExpanded
53
- });
54
- };
55
-
56
- this.onCloseClick = () => {
57
- this.setState({
58
- isExpanded: false
59
- });
60
- };
61
- }
62
-
63
- render() {
64
- const { isExpanded } = this.state;
65
- const panelContent = (
66
- <DrawerPanelContent>
67
- <DrawerHead>
68
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
69
- drawer-panel
70
- </span>
71
- <DrawerActions>
72
- <DrawerCloseButton onClick={this.onCloseClick} />
73
- </DrawerActions>
74
- </DrawerHead>
75
- </DrawerPanelContent>
76
- );
77
-
78
- const drawerContent =
79
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
80
-
81
- return (
82
- <React.Fragment>
83
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
84
- Toggle drawer
85
- </Button>
86
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
87
- <DrawerContent panelContent={panelContent}>
88
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
89
- </DrawerContent>
90
- </Drawer>
91
- </React.Fragment>
92
- );
93
- }
94
- }
24
+ ```ts file="./DrawerBasic.tsx"
95
25
  ```
96
26
 
97
27
  ### Panel on right
98
28
 
99
- ```js
100
- import React from 'react';
101
- import {
102
- Drawer,
103
- DrawerPanelContent,
104
- DrawerContent,
105
- DrawerContentBody,
106
- DrawerHead,
107
- DrawerActions,
108
- DrawerCloseButton,
109
- Button
110
- } from '@patternfly/react-core';
111
-
112
- class SimpleDrawerPanelRight extends React.Component {
113
- constructor(props) {
114
- super(props);
115
- this.state = {
116
- isExpanded: false
117
- };
118
- this.drawerRef = React.createRef();
119
-
120
- this.onExpand = () => {
121
- this.drawerRef.current && this.drawerRef.current.focus();
122
- };
123
-
124
- this.onClick = () => {
125
- const isExpanded = !this.state.isExpanded;
126
- this.setState({
127
- isExpanded
128
- });
129
- };
130
-
131
- this.onCloseClick = () => {
132
- this.setState({
133
- isExpanded: false
134
- });
135
- };
136
- }
137
-
138
- render() {
139
- const { isExpanded } = this.state;
140
- const panelContent = (
141
- <DrawerPanelContent>
142
- <DrawerHead>
143
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
144
- drawer-panel
145
- </span>
146
- <DrawerActions>
147
- <DrawerCloseButton onClick={this.onCloseClick} />
148
- </DrawerActions>
149
- </DrawerHead>
150
- </DrawerPanelContent>
151
- );
152
-
153
- const drawerContent =
154
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
155
-
156
- return (
157
- <React.Fragment>
158
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
159
- Toggle drawer
160
- </Button>
161
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
162
- <DrawerContent panelContent={panelContent}>
163
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
164
- </DrawerContent>
165
- </Drawer>
166
- </React.Fragment>
167
- );
168
- }
169
- }
29
+ ```ts file="./DrawerPanelRight.tsx"
170
30
  ```
171
31
 
172
32
  ### Panel on left
173
33
 
174
- ```js
175
- import React from 'react';
176
- import {
177
- Drawer,
178
- DrawerPanelContent,
179
- DrawerContent,
180
- DrawerContentBody,
181
- DrawerHead,
182
- DrawerActions,
183
- DrawerCloseButton,
184
- Button
185
- } from '@patternfly/react-core';
186
-
187
- class SimpleDrawerPanelLeft extends React.Component {
188
- constructor(props) {
189
- super(props);
190
- this.state = {
191
- isExpanded: false
192
- };
193
- this.drawerRef = React.createRef();
194
-
195
- this.onExpand = () => {
196
- this.drawerRef.current && this.drawerRef.current.focus();
197
- };
198
-
199
- this.onClick = () => {
200
- const isExpanded = !this.state.isExpanded;
201
- this.setState({
202
- isExpanded
203
- });
204
- };
205
-
206
- this.onCloseClick = () => {
207
- this.setState({
208
- isExpanded: false
209
- });
210
- };
211
- }
212
-
213
- render() {
214
- const { isExpanded } = this.state;
215
- const panelContent = (
216
- <DrawerPanelContent>
217
- <DrawerHead>
218
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
219
- drawer-panel
220
- </span>
221
- <DrawerActions>
222
- <DrawerCloseButton onClick={this.onCloseClick} />
223
- </DrawerActions>
224
- </DrawerHead>
225
- </DrawerPanelContent>
226
- );
227
-
228
- const drawerContent =
229
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
230
-
231
- return (
232
- <React.Fragment>
233
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
234
- Toggle drawer
235
- </Button>
236
- <Drawer isExpanded={isExpanded} position="left" onExpand={this.onExpand}>
237
- <DrawerContent panelContent={panelContent}>
238
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
239
- </DrawerContent>
240
- </Drawer>
241
- </React.Fragment>
242
- );
243
- }
244
- }
34
+ ```ts file="./DrawerPanelLeft.tsx"
245
35
  ```
246
36
 
247
37
  ### Panel on bottom
248
38
 
249
- ```js
250
- import React from 'react';
251
- import {
252
- Drawer,
253
- DrawerPanelContent,
254
- DrawerContent,
255
- DrawerContentBody,
256
- DrawerHead,
257
- DrawerActions,
258
- DrawerCloseButton,
259
- Button
260
- } from '@patternfly/react-core';
261
-
262
- class SimpleDrawerPanelBottom extends React.Component {
263
- constructor(props) {
264
- super(props);
265
- this.state = {
266
- isExpanded: false
267
- };
268
- this.drawerRef = React.createRef();
269
-
270
- this.onExpand = () => {
271
- this.drawerRef.current && this.drawerRef.current.focus();
272
- };
273
-
274
- this.onClick = () => {
275
- const isExpanded = !this.state.isExpanded;
276
- this.setState({
277
- isExpanded
278
- });
279
- };
280
-
281
- this.onCloseClick = () => {
282
- this.setState({
283
- isExpanded: false
284
- });
285
- };
286
- }
287
-
288
- render() {
289
- const { isExpanded } = this.state;
290
- const panelContent = (
291
- <DrawerPanelContent>
292
- <DrawerHead>
293
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
294
- drawer-panel
295
- </span>
296
- <DrawerActions>
297
- <DrawerCloseButton onClick={this.onCloseClick} />
298
- </DrawerActions>
299
- </DrawerHead>
300
- </DrawerPanelContent>
301
- );
302
-
303
- const drawerContent =
304
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
305
-
306
- return (
307
- <React.Fragment>
308
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
309
- Toggle drawer
310
- </Button>
311
- <div style={{ height: '400px' }}>
312
- <Drawer isExpanded={isExpanded} position="bottom" onExpand={this.onExpand}>
313
- <DrawerContent panelContent={panelContent}>
314
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
315
- </DrawerContent>
316
- </Drawer>
317
- </div>
318
- </React.Fragment>
319
- );
320
- }
321
- }
39
+ ```ts file="./DrawerPanelBottom.tsx"
322
40
  ```
323
41
 
324
42
  ### Basic inline
325
43
 
326
- ```js
327
- import React from 'react';
328
- import {
329
- Drawer,
330
- DrawerPanelContent,
331
- DrawerContent,
332
- DrawerContentBody,
333
- DrawerHead,
334
- DrawerActions,
335
- DrawerCloseButton,
336
- Button
337
- } from '@patternfly/react-core';
338
-
339
- class SimpleDrawerInlineContent extends React.Component {
340
- constructor(props) {
341
- super(props);
342
- this.state = {
343
- isExpanded: false
344
- };
345
- this.drawerRef = React.createRef();
346
-
347
- this.onExpand = () => {
348
- this.drawerRef.current && this.drawerRef.current.focus();
349
- };
350
-
351
- this.onClick = () => {
352
- const isExpanded = !this.state.isExpanded;
353
- this.setState({
354
- isExpanded
355
- });
356
- };
357
-
358
- this.onCloseClick = () => {
359
- this.setState({
360
- isExpanded: false
361
- });
362
- };
363
- }
364
-
365
- render() {
366
- const { isExpanded } = this.state;
367
- const panelContent = (
368
- <DrawerPanelContent>
369
- <DrawerHead>
370
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
371
- drawer-panel
372
- </span>
373
- <DrawerActions>
374
- <DrawerCloseButton onClick={this.onCloseClick} />
375
- </DrawerActions>
376
- </DrawerHead>
377
- </DrawerPanelContent>
378
- );
379
-
380
- const drawerContent =
381
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
382
-
383
- return (
384
- <React.Fragment>
385
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
386
- Toggle drawer
387
- </Button>
388
- <Drawer isExpanded={isExpanded} isInline onExpand={this.onExpand}>
389
- <DrawerContent panelContent={panelContent}>
390
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
391
- </DrawerContent>
392
- </Drawer>
393
- </React.Fragment>
394
- );
395
- }
396
- }
44
+ ```ts file="./DrawerBasicInline.tsx"
397
45
  ```
398
46
 
399
47
  ### Inline panel on right
400
48
 
401
- ```js
402
- import React from 'react';
403
- import {
404
- Drawer,
405
- DrawerPanelContent,
406
- DrawerContent,
407
- DrawerContentBody,
408
- DrawerHead,
409
- DrawerActions,
410
- DrawerCloseButton,
411
- Button
412
- } from '@patternfly/react-core';
413
-
414
- class DrawerInlineContentPanelRight extends React.Component {
415
- constructor(props) {
416
- super(props);
417
- this.state = {
418
- isExpanded: false
419
- };
420
- this.drawerRef = React.createRef();
421
-
422
- this.onExpand = () => {
423
- this.drawerRef.current && this.drawerRef.current.focus();
424
- };
425
-
426
- this.onClick = () => {
427
- const isExpanded = !this.state.isExpanded;
428
- this.setState({
429
- isExpanded
430
- });
431
- };
432
-
433
- this.onCloseClick = () => {
434
- this.setState({
435
- isExpanded: false
436
- });
437
- };
438
- }
439
-
440
- render() {
441
- const { isExpanded } = this.state;
442
- const panelContent = (
443
- <DrawerPanelContent>
444
- <DrawerHead>
445
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
446
- drawer-panel
447
- </span>
448
- <DrawerActions>
449
- <DrawerCloseButton onClick={this.onCloseClick} />
450
- </DrawerActions>
451
- </DrawerHead>
452
- </DrawerPanelContent>
453
- );
454
-
455
- const drawerContent =
456
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
457
-
458
- return (
459
- <React.Fragment>
460
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
461
- Toggle drawer
462
- </Button>
463
- <Drawer isExpanded={isExpanded} isInline onExpand={this.onExpand}>
464
- <DrawerContent panelContent={panelContent}>
465
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
466
- </DrawerContent>
467
- </Drawer>
468
- </React.Fragment>
469
- );
470
- }
471
- }
49
+ ```ts file="./DrawerInlinePanelRight.tsx"
472
50
  ```
473
51
 
474
52
  ### Inline panel on left
475
53
 
476
- ```js
477
- import React from 'react';
478
- import {
479
- Drawer,
480
- DrawerPanelContent,
481
- DrawerContent,
482
- DrawerContentBody,
483
- DrawerHead,
484
- DrawerActions,
485
- DrawerCloseButton,
486
- Button
487
- } from '@patternfly/react-core';
488
-
489
- class DrawerInlineContentPanelLeft extends React.Component {
490
- constructor(props) {
491
- super(props);
492
- this.state = {
493
- isExpanded: false
494
- };
495
- this.drawerRef = React.createRef();
496
-
497
- this.onExpand = () => {
498
- this.drawerRef.current && this.drawerRef.current.focus();
499
- };
500
-
501
- this.onClick = () => {
502
- const isExpanded = !this.state.isExpanded;
503
- this.setState({
504
- isExpanded
505
- });
506
- };
507
-
508
- this.onCloseClick = () => {
509
- this.setState({
510
- isExpanded: false
511
- });
512
- };
513
- }
514
-
515
- render() {
516
- const { isExpanded } = this.state;
517
- const panelContent = (
518
- <DrawerPanelContent>
519
- <DrawerHead>
520
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
521
- drawer-panel
522
- </span>
523
- <DrawerActions>
524
- <DrawerCloseButton onClick={this.onCloseClick} />
525
- </DrawerActions>
526
- </DrawerHead>
527
- </DrawerPanelContent>
528
- );
529
-
530
- const drawerContent =
531
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
532
-
533
- return (
534
- <React.Fragment>
535
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
536
- Toggle drawer
537
- </Button>
538
- <Drawer isExpanded={isExpanded} isInline position="left" onExpand={this.onExpand}>
539
- <DrawerContent panelContent={panelContent}>
540
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
541
- </DrawerContent>
542
- </Drawer>
543
- </React.Fragment>
544
- );
545
- }
546
- }
54
+ ```ts file="./DrawerInlinePanelLeft.tsx"
547
55
  ```
548
56
 
549
57
  ### Stacked content body elements
550
58
 
551
- ```js
552
- import React from 'react';
553
- import {
554
- Drawer,
555
- DrawerPanelContent,
556
- DrawerContent,
557
- DrawerContentBody,
558
- DrawerPanelBody,
559
- DrawerHead,
560
- DrawerActions,
561
- DrawerCloseButton,
562
- Button
563
- } from '@patternfly/react-core';
564
-
565
- class DrawerStackedContentBodyElements extends React.Component {
566
- constructor(props) {
567
- super(props);
568
- this.state = {
569
- isExpanded: false
570
- };
571
- this.drawerRef = React.createRef();
572
-
573
- this.onExpand = () => {
574
- this.drawerRef.current && this.drawerRef.current.focus();
575
- };
576
-
577
- this.onClick = () => {
578
- const isExpanded = !this.state.isExpanded;
579
- this.setState({
580
- isExpanded
581
- });
582
- };
583
-
584
- this.onCloseClick = () => {
585
- this.setState({
586
- isExpanded: false
587
- });
588
- };
589
- }
590
-
591
- render() {
592
- const { isExpanded } = this.state;
593
- const panelContent = (
594
- <DrawerPanelContent>
595
- <DrawerHead>
596
- <h3 className="pf-c-title pf-m-2xl" tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
597
- drawer title{' '}
598
- </h3>
599
- <DrawerActions>
600
- <DrawerCloseButton onClick={this.onCloseClick} />
601
- </DrawerActions>
602
- drawer-panel
603
- </DrawerHead>
604
- <DrawerPanelBody hasNoPadding>drawer-panel with no padding</DrawerPanelBody>
605
- <DrawerPanelBody>drawer-panel</DrawerPanelBody>
606
- </DrawerPanelContent>
607
- );
608
-
609
- return (
610
- <React.Fragment>
611
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
612
- Toggle drawer
613
- </Button>
614
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
615
- <DrawerContent panelContent={panelContent}>
616
- <DrawerContentBody>content-body</DrawerContentBody>
617
- <DrawerContentBody hasPadding>content-body with padding</DrawerContentBody>
618
- <DrawerContentBody>content-body</DrawerContentBody>
619
- </DrawerContent>
620
- </Drawer>
621
- </React.Fragment>
622
- );
623
- }
624
- }
59
+ ```ts file="./DrawerStackedContentBodyElements.tsx"
625
60
  ```
626
61
 
627
62
  ### Modified content padding
628
63
 
629
- ```js
630
- import React from 'react';
631
- import {
632
- Drawer,
633
- DrawerPanelContent,
634
- DrawerContent,
635
- DrawerContentBody,
636
- DrawerHead,
637
- DrawerActions,
638
- DrawerCloseButton,
639
- Button
640
- } from '@patternfly/react-core';
641
-
642
- class DrawerModifiedContentPadding extends React.Component {
643
- constructor(props) {
644
- super(props);
645
- this.state = {
646
- isExpanded: false
647
- };
648
- this.drawerRef = React.createRef();
649
-
650
- this.onExpand = () => {
651
- this.drawerRef.current && this.drawerRef.current.focus();
652
- };
653
-
654
- this.onClick = () => {
655
- const isExpanded = !this.state.isExpanded;
656
- this.setState({
657
- isExpanded
658
- });
659
- };
660
-
661
- this.onCloseClick = () => {
662
- this.setState({
663
- isExpanded: false
664
- });
665
- };
666
- }
667
-
668
- render() {
669
- const { isExpanded } = this.state;
670
- const panelContent = (
671
- <DrawerPanelContent>
672
- <DrawerHead>
673
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
674
- drawer-panel
675
- </span>
676
- <DrawerActions>
677
- <DrawerCloseButton onClick={this.onCloseClick} />
678
- </DrawerActions>
679
- </DrawerHead>
680
- </DrawerPanelContent>
681
- );
682
-
683
- const drawerContent =
684
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
685
-
686
- return (
687
- <React.Fragment>
688
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
689
- Toggle drawer
690
- </Button>
691
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
692
- <DrawerContent panelContent={panelContent}>
693
- <DrawerContentBody hasPadding>
694
- <b>Drawer content padding.</b> {drawerContent}
695
- </DrawerContentBody>
696
- </DrawerContent>
697
- </Drawer>
698
- </React.Fragment>
699
- );
700
- }
701
- }
64
+ ```ts file="DrawerModifiedContentPadding.tsx"
702
65
  ```
703
66
 
704
67
  ### Modified panel padding
705
68
 
706
- ```js
707
- import React from 'react';
708
- import {
709
- Drawer,
710
- DrawerPanelContent,
711
- DrawerContent,
712
- DrawerContentBody,
713
- DrawerHead,
714
- DrawerActions,
715
- DrawerCloseButton,
716
- Button
717
- } from '@patternfly/react-core';
718
-
719
- class DrawerModifiedPanelPadding extends React.Component {
720
- constructor(props) {
721
- super(props);
722
- this.state = {
723
- isExpanded: false
724
- };
725
- this.drawerRef = React.createRef();
726
-
727
- this.onExpand = () => {
728
- this.drawerRef.current && this.drawerRef.current.focus();
729
- };
730
-
731
- this.onClick = () => {
732
- const isExpanded = !this.state.isExpanded;
733
- this.setState({
734
- isExpanded
735
- });
736
- };
737
-
738
- this.onCloseClick = () => {
739
- this.setState({
740
- isExpanded: false
741
- });
742
- };
743
- }
744
-
745
- render() {
746
- const { isExpanded } = this.state;
747
- const panelContent = (
748
- <DrawerPanelContent>
749
- <DrawerHead hasNoPadding>
750
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
751
- drawer-panel
752
- </span>
753
- <DrawerActions>
754
- <DrawerCloseButton onClick={this.onCloseClick} />
755
- </DrawerActions>
756
- </DrawerHead>
757
- </DrawerPanelContent>
758
- );
759
-
760
- const drawerContent =
761
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
762
-
763
- return (
764
- <React.Fragment>
765
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
766
- Toggle drawer
767
- </Button>
768
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
769
- <DrawerContent panelContent={panelContent}>
770
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
771
- </DrawerContent>
772
- </Drawer>
773
- </React.Fragment>
774
- );
775
- }
776
- }
69
+ ```ts file="DrawerModifiedPanelPadding.tsx"
777
70
  ```
778
71
 
779
72
  ### Additional section above drawer content
780
73
 
781
- ```js
782
- import React from 'react';
783
- import {
784
- Drawer,
785
- DrawerPanelContent,
786
- DrawerContent,
787
- DrawerContentBody,
788
- DrawerHead,
789
- DrawerActions,
790
- DrawerCloseButton,
791
- DrawerSection,
792
- Button
793
- } from '@patternfly/react-core';
794
-
795
- class DrawerWithSection extends React.Component {
796
- constructor(props) {
797
- super(props);
798
- this.state = {
799
- isExpanded: false
800
- };
801
- this.drawerRef = React.createRef();
802
-
803
- this.onExpand = () => {
804
- this.drawerRef.current && this.drawerRef.current.focus();
805
- };
806
-
807
- this.onClick = () => {
808
- const isExpanded = !this.state.isExpanded;
809
- this.setState({
810
- isExpanded
811
- });
812
- };
813
-
814
- this.onCloseClick = () => {
815
- this.setState({
816
- isExpanded: false
817
- });
818
- };
819
- }
820
-
821
- render() {
822
- const { isExpanded } = this.state;
823
- const panelContent = (
824
- <DrawerPanelContent>
825
- <DrawerHead>
826
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
827
- drawer-panel
828
- </span>
829
- <DrawerActions>
830
- <DrawerCloseButton onClick={this.onCloseClick} />
831
- </DrawerActions>
832
- </DrawerHead>
833
- </DrawerPanelContent>
834
- );
835
-
836
- const drawerContent =
837
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
838
-
839
- return (
840
- <React.Fragment>
841
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
842
- Toggle drawer
843
- </Button>
844
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
845
- <DrawerSection>drawer-section</DrawerSection>
846
- <DrawerContent panelContent={panelContent}>
847
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
848
- </DrawerContent>
849
- </Drawer>
850
- </React.Fragment>
851
- );
852
- }
853
- }
74
+ ```ts file="DrawerAdditionalSectionAboveContent.tsx"
854
75
  ```
855
76
 
856
77
  ### Static drawer
857
78
 
858
79
  **Note:** For mobile viewports, all drawer variants behave the same way. At the `md` breakpoint, or where `.pf-m-static{-on-[lg, xl, 2xl]}` is applied, the `static drawer` variant’s `close button` is automatically hidden because the drawer panel doesn’t close by design.
859
80
 
860
- ```js
861
- import React from 'react';
862
- import {
863
- Drawer,
864
- DrawerPanelContent,
865
- DrawerContent,
866
- DrawerContentBody,
867
- DrawerHead,
868
- DrawerActions,
869
- DrawerCloseButton,
870
- Button
871
- } from '@patternfly/react-core';
872
-
873
- class StaticDrawer extends React.Component {
874
- constructor(props) {
875
- super(props);
876
- this.state = {
877
- isExpanded: false
878
- };
879
-
880
- this.onClick = () => {
881
- const isExpanded = !this.state.isExpanded;
882
- this.setState({
883
- isExpanded
884
- });
885
- };
886
-
887
- this.onCloseClick = () => {
888
- this.setState({
889
- isExpanded: false
890
- });
891
- };
892
- }
893
-
894
- render() {
895
- const { isExpanded } = this.state;
896
- const panelContent = (
897
- <DrawerPanelContent>
898
- <DrawerHead>
899
- <span>drawer-panel</span>
900
- <DrawerActions>
901
- <DrawerCloseButton onClick={this.onCloseClick} />
902
- </DrawerActions>
903
- </DrawerHead>
904
- </DrawerPanelContent>
905
- );
906
-
907
- const drawerContent =
908
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
909
-
910
- return (
911
- <React.Fragment>
912
- <Button className="pf-u-hidden-on-md" aria-expanded={isExpanded} onClick={this.onClick}>
913
- Toggle drawer
914
- </Button>
915
- <Drawer isStatic isExpanded={isExpanded} onExpand={this.onExpand}>
916
- <DrawerContent panelContent={panelContent}>
917
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
918
- </DrawerContent>
919
- </Drawer>
920
- </React.Fragment>
921
- );
922
- }
923
- }
81
+ ```ts file="DrawerStatic.tsx"
924
82
  ```
925
83
 
926
84
  ### Breakpoint
927
85
 
928
- ```js
929
- import React from 'react';
930
- import {
931
- Drawer,
932
- DrawerPanelContent,
933
- DrawerContent,
934
- DrawerContentBody,
935
- DrawerHead,
936
- DrawerActions,
937
- DrawerCloseButton,
938
- Button
939
- } from '@patternfly/react-core';
940
-
941
- class SimpleDrawer extends React.Component {
942
- constructor(props) {
943
- super(props);
944
- this.state = {
945
- isExpanded: false
946
- };
947
- this.drawerRef = React.createRef();
948
-
949
- this.onExpand = () => {
950
- this.drawerRef.current && this.drawerRef.current.focus();
951
- };
952
-
953
- this.onClick = () => {
954
- const isExpanded = !this.state.isExpanded;
955
- this.setState({
956
- isExpanded
957
- });
958
- };
959
-
960
- this.onCloseClick = () => {
961
- this.setState({
962
- isExpanded: false
963
- });
964
- };
965
- }
966
-
967
- render() {
968
- const { isExpanded } = this.state;
969
- const panelContent = (
970
- <DrawerPanelContent widths={{ default: 'width_33' }}>
971
- <DrawerHead>
972
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
973
- drawer-panel
974
- </span>
975
- <DrawerActions>
976
- <DrawerCloseButton onClick={this.onCloseClick} />
977
- </DrawerActions>
978
- </DrawerHead>
979
- </DrawerPanelContent>
980
- );
981
-
982
- const drawerContent =
983
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
984
-
985
- return (
986
- <React.Fragment>
987
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
988
- Toggle drawer
989
- </Button>
990
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
991
- <DrawerContent panelContent={panelContent}>
992
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
993
- </DrawerContent>
994
- </Drawer>
995
- </React.Fragment>
996
- );
997
- }
998
- }
86
+ ```ts file="DrawerBreakpoint.tsx"
999
87
  ```
1000
88
 
1001
89
  ### Resizable on right
1002
90
 
1003
- ```js
1004
- import React from 'react';
1005
- import {
1006
- Drawer,
1007
- DrawerPanelContent,
1008
- DrawerContent,
1009
- DrawerContentBody,
1010
- DrawerHead,
1011
- DrawerActions,
1012
- DrawerCloseButton,
1013
- Button
1014
- } from '@patternfly/react-core';
1015
-
1016
- class ResizableDrawer extends React.Component {
1017
- constructor(props) {
1018
- super(props);
1019
- this.state = {
1020
- isExpanded: false,
1021
- isResizing: false,
1022
- panelWidth: 200
1023
- };
1024
- this.drawerRef = React.createRef();
1025
-
1026
- this.onExpand = () => {
1027
- this.drawerRef.current && this.drawerRef.current.focus();
1028
- };
1029
-
1030
- this.onClick = () => {
1031
- const isExpanded = !this.state.isExpanded;
1032
- this.setState({
1033
- isExpanded
1034
- });
1035
- };
1036
-
1037
- this.onResize = (newWidth, id) => {
1038
- this.setState(
1039
- {
1040
- panelWidth: newWidth
1041
- },
1042
- () => console.log(`${id} has new width of: ${newWidth}`)
1043
- );
1044
- };
1045
-
1046
- this.onCloseClick = () => {
1047
- this.setState({
1048
- isExpanded: false
1049
- });
1050
- };
1051
- }
1052
-
1053
- render() {
1054
- const { isExpanded } = this.state;
1055
- const panelContent = (
1056
- <DrawerPanelContent
1057
- isResizable
1058
- onResize={this.onResize}
1059
- id="right-resize-panel"
1060
- defaultSize={'500px'}
1061
- minSize={'150px'}
1062
- >
1063
- <DrawerHead>
1064
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
1065
- drawer-panel
1066
- </span>
1067
- <DrawerActions>
1068
- <DrawerCloseButton onClick={this.onCloseClick} />
1069
- </DrawerActions>
1070
- </DrawerHead>
1071
- </DrawerPanelContent>
1072
- );
1073
-
1074
- const drawerContent =
1075
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
1076
-
1077
- return (
1078
- <React.Fragment>
1079
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
1080
- Toggle drawer
1081
- </Button>
1082
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
1083
- <DrawerContent panelContent={panelContent}>
1084
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
1085
- </DrawerContent>
1086
- </Drawer>
1087
- </React.Fragment>
1088
- );
1089
- }
1090
- }
91
+ ```ts file="DrawerResizableOnRight.tsx"
1091
92
  ```
1092
93
 
1093
94
  ### Resizable on left
1094
95
 
1095
- ```js
1096
- import React from 'react';
1097
- import {
1098
- Drawer,
1099
- DrawerPanelContent,
1100
- DrawerContent,
1101
- DrawerContentBody,
1102
- DrawerHead,
1103
- DrawerActions,
1104
- DrawerCloseButton,
1105
- Button
1106
- } from '@patternfly/react-core';
1107
-
1108
- class ResizableDrawer extends React.Component {
1109
- constructor(props) {
1110
- super(props);
1111
- this.state = {
1112
- isExpanded: false,
1113
- isResizing: false
1114
- };
1115
- this.drawerRef = React.createRef();
1116
-
1117
- this.onExpand = () => {
1118
- this.drawerRef.current && this.drawerRef.current.focus();
1119
- };
1120
-
1121
- this.onClick = () => {
1122
- const isExpanded = !this.state.isExpanded;
1123
- this.setState({
1124
- isExpanded
1125
- });
1126
- };
1127
-
1128
- this.onCloseClick = () => {
1129
- this.setState({
1130
- isExpanded: false
1131
- });
1132
- };
1133
- }
1134
-
1135
- render() {
1136
- const { isExpanded } = this.state;
1137
- const panelContent = (
1138
- <DrawerPanelContent isResizable defaultSize={'500px'} minSize={'200px'}>
1139
- <DrawerHead>
1140
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
1141
- drawer-panel
1142
- </span>
1143
- <DrawerActions>
1144
- <DrawerCloseButton onClick={this.onCloseClick} />
1145
- </DrawerActions>
1146
- </DrawerHead>
1147
- </DrawerPanelContent>
1148
- );
1149
-
1150
- const drawerContent =
1151
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
1152
-
1153
- return (
1154
- <React.Fragment>
1155
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
1156
- Toggle drawer
1157
- </Button>
1158
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand} position="left">
1159
- <DrawerContent panelContent={panelContent}>
1160
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
1161
- </DrawerContent>
1162
- </Drawer>
1163
- </React.Fragment>
1164
- );
1165
- }
1166
- }
96
+ ```ts file="DrawerResizableOnLeft.tsx"
1167
97
  ```
1168
98
 
1169
99
  ### Resizable on bottom
1170
100
 
1171
- ```js
1172
- import React from 'react';
1173
- import {
1174
- Drawer,
1175
- DrawerPanelContent,
1176
- DrawerContent,
1177
- DrawerContentBody,
1178
- DrawerHead,
1179
- DrawerActions,
1180
- DrawerCloseButton,
1181
- Button
1182
- } from '@patternfly/react-core';
1183
-
1184
- class ResizableDrawer extends React.Component {
1185
- constructor(props) {
1186
- super(props);
1187
- this.state = {
1188
- isExpanded: false,
1189
- isResizing: false
1190
- };
1191
- this.drawerRef = React.createRef();
1192
-
1193
- this.onExpand = () => {
1194
- this.drawerRef.current && this.drawerRef.current.focus();
1195
- };
1196
-
1197
- this.onClick = () => {
1198
- const isExpanded = !this.state.isExpanded;
1199
- this.setState({
1200
- isExpanded
1201
- });
1202
- };
1203
-
1204
- this.onCloseClick = () => {
1205
- this.setState({
1206
- isExpanded: false
1207
- });
1208
- };
1209
- }
1210
-
1211
- render() {
1212
- const { isExpanded } = this.state;
1213
- const panelContent = (
1214
- <DrawerPanelContent isResizable defaultSize={'200px'} minSize={'100px'}>
1215
- <DrawerHead>
1216
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
1217
- drawer-panel
1218
- </span>
1219
- <DrawerActions>
1220
- <DrawerCloseButton onClick={this.onCloseClick} />
1221
- </DrawerActions>
1222
- </DrawerHead>
1223
- </DrawerPanelContent>
1224
- );
1225
-
1226
- const drawerContent =
1227
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
1228
-
1229
- return (
1230
- <React.Fragment>
1231
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
1232
- Toggle drawer
1233
- </Button>
1234
- <div style={{ height: '400px' }}>
1235
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand} position="bottom">
1236
- <DrawerContent panelContent={panelContent}>
1237
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
1238
- </DrawerContent>
1239
- </Drawer>
1240
- </div>
1241
- </React.Fragment>
1242
- );
1243
- }
1244
- }
101
+ ```ts file="DrawerResizableOnBottom.tsx"
1245
102
  ```
1246
103
 
1247
104
  ### Resizable on inline
1248
105
 
1249
- ```js
1250
- import React from 'react';
1251
- import {
1252
- Drawer,
1253
- DrawerPanelContent,
1254
- DrawerContent,
1255
- DrawerContentBody,
1256
- DrawerHead,
1257
- DrawerActions,
1258
- DrawerCloseButton,
1259
- Button
1260
- } from '@patternfly/react-core';
1261
-
1262
- class ResizableDrawer extends React.Component {
1263
- constructor(props) {
1264
- super(props);
1265
- this.state = {
1266
- isExpanded: false,
1267
- isResizing: false
1268
- };
1269
- this.drawerRef = React.createRef();
1270
-
1271
- this.onExpand = () => {
1272
- this.drawerRef.current && this.drawerRef.current.focus();
1273
- };
1274
-
1275
- this.onClick = () => {
1276
- const isExpanded = !this.state.isExpanded;
1277
- this.setState({
1278
- isExpanded
1279
- });
1280
- };
1281
-
1282
- this.onCloseClick = () => {
1283
- this.setState({
1284
- isExpanded: false
1285
- });
1286
- };
1287
- }
1288
-
1289
- render() {
1290
- const { isExpanded } = this.state;
1291
- const panelContent = (
1292
- <DrawerPanelContent isResizable defaultSize={'500px'} minSize={'150px'}>
1293
- <DrawerHead>
1294
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
1295
- drawer-panel
1296
- </span>
1297
- <DrawerActions>
1298
- <DrawerCloseButton onClick={this.onCloseClick} />
1299
- </DrawerActions>
1300
- </DrawerHead>
1301
- </DrawerPanelContent>
1302
- );
1303
-
1304
- const drawerContent =
1305
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
1306
-
1307
- return (
1308
- <React.Fragment>
1309
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
1310
- Toggle drawer
1311
- </Button>
1312
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand} isInline>
1313
- <DrawerContent panelContent={panelContent}>
1314
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
1315
- </DrawerContent>
1316
- </Drawer>
1317
- </React.Fragment>
1318
- );
1319
- }
1320
- }
106
+ ```ts file="DrawerResizableOnInline.tsx"
1321
107
  ```
1322
108
 
1323
109
  ### Panel with light-200 background
1324
- ```js
1325
- import React from 'react';
1326
- import {
1327
- Checkbox,
1328
- Drawer,
1329
- DrawerPanelContent,
1330
- DrawerContent,
1331
- DrawerContentBody,
1332
- DrawerHead,
1333
- DrawerActions,
1334
- DrawerCloseButton,
1335
- DrawerSection,
1336
- Button,
1337
- DrawerColorVariant
1338
- } from '@patternfly/react-core';
1339
-
1340
- class LightGrayDrawer extends React.Component {
1341
- constructor(props) {
1342
- super(props);
1343
- this.state = {
1344
- isExpanded: false,
1345
- sectionGray: false,
1346
- panelGray: true,
1347
- contentGray: false
1348
- };
1349
- this.drawerRef = React.createRef();
1350
-
1351
- this.onExpand = () => {
1352
- this.drawerRef.current && this.drawerRef.current.focus();
1353
- };
1354
-
1355
- this.onClick = () => {
1356
- const isExpanded = !this.state.isExpanded;
1357
- this.setState({
1358
- isExpanded
1359
- });
1360
- };
1361
-
1362
- this.onCloseClick = () => {
1363
- this.setState({
1364
- isExpanded: false
1365
- });
1366
- };
1367
-
1368
- this.togglePanelGray = (checked) => {
1369
- this.setState({
1370
- panelGray: checked
1371
- })
1372
- };
1373
-
1374
- this.toggleSectionGray = (checked) => {
1375
- this.setState({
1376
- sectionGray: checked
1377
- })
1378
- };
1379
-
1380
- this.toggleContentGray = (checked) => {
1381
- this.setState({
1382
- contentGray: checked
1383
- })
1384
- };
1385
- }
1386
-
1387
- render() {
1388
- const { isExpanded, panelGray, sectionGray, contentGray } = this.state;
1389
- const panelContent = (
1390
- <DrawerPanelContent colorVariant={panelGray ? DrawerColorVariant.light200 : DrawerColorVariant.default}>
1391
- <DrawerHead>
1392
- <span tabIndex={isExpanded ? 0 : -1} ref={this.drawerRef}>
1393
- drawer-panel
1394
- </span>
1395
- <DrawerActions>
1396
- <DrawerCloseButton onClick={this.onCloseClick} />
1397
- </DrawerActions>
1398
- </DrawerHead>
1399
- </DrawerPanelContent>
1400
- );
1401
-
1402
- const drawerContent =
1403
- 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';
1404
110
 
1405
- return (
1406
- <React.Fragment>
1407
- <Checkbox
1408
- label="Gray panel"
1409
- isChecked={this.state.panelGray}
1410
- onChange={this.togglePanelGray}
1411
- aria-label="Gray panel checkbox"
1412
- id="toggle-gray-panel"
1413
- name="toggle-gray-panel"
1414
- />
1415
- <Checkbox
1416
- label="Gray content"
1417
- isChecked={this.state.contentGray}
1418
- onChange={this.toggleContentGray}
1419
- aria-label="Gray content checkbox"
1420
- id="toggle-gray-content"
1421
- name="toggle-gray-content"
1422
- />
1423
- <Checkbox
1424
- label="Gray section"
1425
- isChecked={this.state.sectionGray}
1426
- onChange={this.toggleSectionGray}
1427
- aria-label="Gray section checkbox"
1428
- id="toggle-gray-section"
1429
- name="toggle-gray-section"
1430
- />
1431
- <br />
1432
- <Button aria-expanded={isExpanded} onClick={this.onClick}>
1433
- Toggle drawer
1434
- </Button>
1435
- <Drawer isExpanded={isExpanded} onExpand={this.onExpand}>
1436
- <DrawerSection colorVariant={sectionGray ? DrawerColorVariant.light200 : DrawerColorVariant.default}>
1437
- drawer-section
1438
- </DrawerSection>
1439
- <DrawerContent colorVariant={contentGray ? DrawerColorVariant.light200 : DrawerColorVariant.default} panelContent={panelContent}>
1440
- <DrawerContentBody>{drawerContent}</DrawerContentBody>
1441
- </DrawerContent>
1442
- </Drawer>
1443
- </React.Fragment>
1444
- );
1445
- }
1446
- }
111
+ ```ts file="DrawerLightGray.tsx"
1447
112
  ```