@indico-data/design-system 3.0.0 → 3.0.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indico-data/design-system",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "main": "lib/index.js",
@@ -1,10 +1,12 @@
1
1
  import { Button } from '../button/Button';
2
2
  import { ButtonVariants } from '../button/types';
3
+ import { Checkbox } from '../forms/checkbox/Checkbox';
3
4
  import { Col, Row } from '../grid';
4
5
  import { Icon } from '../icons/Icon';
5
6
  import { Modal } from './Modal';
6
7
  import { ConfirmationModalProps } from './types';
7
8
  import classNames from 'classnames';
9
+ import { useState } from 'react';
8
10
 
9
11
  const defaultFooter = ({
10
12
  onCancelRequest,
@@ -12,14 +14,35 @@ const defaultFooter = ({
12
14
  confirmationButtonText,
13
15
  confirmationButtonVariant,
14
16
  cancelButtonText,
17
+ hasDontShowAgainCheckbox,
18
+ isChecked,
19
+ onDontShowAgainChange,
15
20
  }: {
16
21
  onCancelRequest?: () => void;
17
- onConfirmRequest?: () => void;
22
+ onConfirmRequest?: ({
23
+ dontShowAgain,
24
+ }: {
25
+ dontShowAgain?: boolean;
26
+ }) => void | Promise<void> | Promise<boolean>;
18
27
  confirmationButtonText?: string;
19
28
  confirmationButtonVariant?: ButtonVariants;
20
29
  cancelButtonText?: string;
30
+ hasDontShowAgainCheckbox?: boolean;
31
+ isChecked?: boolean;
32
+ onDontShowAgainChange?: (checked: boolean) => void;
21
33
  }) => (
22
34
  <Row gutterWidth={12} justify="end" align="center">
35
+ {hasDontShowAgainCheckbox && (
36
+ <Col>
37
+ <Checkbox
38
+ label="Don't display this again."
39
+ onChange={(e) => onDontShowAgainChange?.(e.target.checked)}
40
+ isChecked={isChecked}
41
+ id="dont-show-again"
42
+ name="dont-show-again"
43
+ />
44
+ </Col>
45
+ )}
23
46
  <Col xs="content">
24
47
  <Button onClick={onCancelRequest} ariaLabel={cancelButtonText || 'Cancel'} variant="outline">
25
48
  {cancelButtonText}
@@ -27,7 +50,7 @@ const defaultFooter = ({
27
50
  </Col>
28
51
  <Col xs="content">
29
52
  <Button
30
- onClick={onConfirmRequest}
53
+ onClick={() => onConfirmRequest?.({ dontShowAgain: isChecked })}
31
54
  ariaLabel={confirmationButtonText || 'Confirm'}
32
55
  variant={confirmationButtonVariant}
33
56
  >
@@ -61,7 +84,10 @@ export const ConfirmationModal = ({
61
84
  title,
62
85
  status = 'info',
63
86
  maxWidthInPixels,
87
+ hasDontShowAgainCheckbox,
64
88
  }: ConfirmationModalProps) => {
89
+ const [dontShowAgain, setDontShowAgain] = useState(false);
90
+
65
91
  const modalFooter =
66
92
  footer ||
67
93
  defaultFooter({
@@ -70,6 +96,9 @@ export const ConfirmationModal = ({
70
96
  confirmationButtonText,
71
97
  cancelButtonText,
72
98
  confirmationButtonVariant,
99
+ hasDontShowAgainCheckbox,
100
+ isChecked: dontShowAgain,
101
+ onDontShowAgainChange: setDontShowAgain,
73
102
  });
74
103
 
75
104
  return (
@@ -244,6 +244,16 @@ const meta: Meta = {
244
244
  },
245
245
  },
246
246
  },
247
+ hasDontShowAgainCheckbox: {
248
+ control: 'boolean',
249
+ description: 'Whether the modal should have a checkbox to not show again',
250
+ table: {
251
+ category: 'Confirmation Modal',
252
+ type: {
253
+ summary: 'boolean',
254
+ },
255
+ },
256
+ },
247
257
  },
248
258
  };
249
259
 
@@ -338,11 +348,13 @@ export const ConfirmationModalStory: StoryObj<typeof ConfirmationModal> = {
338
348
  confirmationButtonVariant: 'destructive',
339
349
  cancelButtonText: 'Cancel',
340
350
  shouldCloseOnOverlayClick: true,
351
+ subtitle: '',
341
352
  icon: 'trash',
342
353
  status: 'error',
343
354
  shouldCloseOnEsc: true,
344
355
  parentSelector: () => document.body,
345
356
  maxWidthInPixels: 600,
357
+ hasDontShowAgainCheckbox: false,
346
358
  },
347
359
 
348
360
  render: (args) => {
@@ -375,3 +387,60 @@ export const ConfirmationModalStory: StoryObj<typeof ConfirmationModal> = {
375
387
  );
376
388
  },
377
389
  };
390
+
391
+ export const ConfirmationModalStoryWithCheckbox: StoryObj<typeof ConfirmationModal> = {
392
+ args: {
393
+ className: '',
394
+ onRequestClose: () => {
395
+ console.log('closed');
396
+ },
397
+ title: 'Disable User',
398
+ confirmationButtonText: 'Delete',
399
+ confirmationButtonVariant: 'destructive',
400
+ cancelButtonText: 'Cancel',
401
+ shouldCloseOnOverlayClick: true,
402
+ icon: 'trash',
403
+ status: 'error',
404
+ shouldCloseOnEsc: true,
405
+ parentSelector: () => document.body,
406
+ maxWidthInPixels: 600,
407
+ hasDontShowAgainCheckbox: true,
408
+ },
409
+
410
+ render: (args) => {
411
+ const [isOpen, setIsOpen] = useState<boolean>(false);
412
+
413
+ const handleOpen = () => {
414
+ setIsOpen(true);
415
+ };
416
+
417
+ const handleClose = () => {
418
+ setIsOpen(false);
419
+ };
420
+
421
+ return (
422
+ <Container>
423
+ <Row>
424
+ <Col sm={4}>
425
+ <ConfirmationModal
426
+ {...args}
427
+ isOpen={isOpen}
428
+ onConfirmRequest={({ dontShowAgain }) => {
429
+ console.log('confirmed', dontShowAgain);
430
+ }}
431
+ onRequestClose={handleClose}
432
+ >
433
+ <p>
434
+ Deleting user will no longer allow this person to have access to this organization.
435
+ You can always invite them again if you change your mind.
436
+ </p>
437
+ </ConfirmationModal>
438
+ <Button ariaLabel="open modal" onClick={handleOpen}>
439
+ Open modal
440
+ </Button>
441
+ </Col>
442
+ </Row>
443
+ </Container>
444
+ );
445
+ },
446
+ };
@@ -19,13 +19,17 @@ export interface ModalProps {
19
19
  title?: string;
20
20
  subtitle?: string;
21
21
  footer?: React.ReactNode;
22
-
23
22
  maxWidthInPixels?: number;
24
23
  }
25
24
 
26
25
  export interface ConfirmationModalProps extends ModalProps {
27
- onConfirmRequest?: () => void;
28
- onCancelRequest?: () => void;
26
+ onConfirmRequest?: ({
27
+ dontShowAgain,
28
+ }: {
29
+ dontShowAgain?: boolean;
30
+ }) => void | Promise<void> | Promise<boolean>;
31
+ onCancelRequest?: () => void | Promise<void> | Promise<boolean>;
32
+ hasDontShowAgainCheckbox?: boolean;
29
33
  confirmationButtonVariant?: ButtonVariants;
30
34
  confirmationButtonText?: string;
31
35
  cancelButtonText?: string;
@@ -171,21 +171,21 @@
171
171
  --pf-teal-color-900: #101818;
172
172
 
173
173
  // Brand Color
174
- --pf-brand-color: #2960a3;
174
+ --pf-brand-color: #2989ff;
175
175
 
176
176
  --pf-brand-color-50: #f6fafd;
177
177
  --pf-brand-color-100: #eef4fc;
178
- --pf-brand-color-150: #dce9f9;
179
- --pf-brand-color-200: #eef4fc;
180
- --pf-brand-color-250: #accdf6;
181
- --pf-brand-color-300: #8cbaf2;
182
- --pf-brand-color-400: #3e8bea;
178
+ --pf-brand-color-150: #e5effa;
179
+ --pf-brand-color-200: #d8e9fd;
180
+ --pf-brand-color-250: #bbd8fb;
181
+ --pf-brand-color-300: #9ec7fa;
182
+ --pf-brand-color-400: #2989ff;
183
183
  --pf-brand-color-450: #0070f5;
184
- --pf-brand-color-500: #2960a3;
185
- --pf-brand-color-600: #264973;
186
- --pf-brand-color-700: #233852;
187
- --pf-brand-color-800: #1b2532;
188
- --pf-brand-color-900: #101418;
184
+ --pf-brand-color-500: #005ccc;
185
+ --pf-brand-color-600: #004599;
186
+ --pf-brand-color-700: #06356f;
187
+ --pf-brand-color-800: #082345;
188
+ --pf-brand-color-900: #061323;
189
189
 
190
190
  // Purple Color
191
191
  --pf-purple-color: #5c29a3;
@@ -169,22 +169,21 @@
169
169
  --pf-teal-color-800: #1b3232;
170
170
  --pf-teal-color-900: #101818;
171
171
 
172
- // Brand Color
173
- --pf-brand-color: #2960a3;
172
+ --pf-brand-color: #2989ff;
174
173
 
175
174
  --pf-brand-color-50: #f6fafd;
176
175
  --pf-brand-color-100: #eef4fc;
177
- --pf-brand-color-150: #dce9f9;
178
- --pf-brand-color-200: #eef4fc;
179
- --pf-brand-color-250: #accdf6;
180
- --pf-brand-color-300: #8cbaf2;
181
- --pf-brand-color-400: #3e8bea;
176
+ --pf-brand-color-150: #e5effa;
177
+ --pf-brand-color-200: #d8e9fd;
178
+ --pf-brand-color-250: #bbd8fb;
179
+ --pf-brand-color-300: #9ec7fa;
180
+ --pf-brand-color-400: #2989ff;
182
181
  --pf-brand-color-450: #0070f5;
183
- --pf-brand-color-500: #2960a3;
184
- --pf-brand-color-600: #264973;
185
- --pf-brand-color-700: #233852;
186
- --pf-brand-color-800: #1b2532;
187
- --pf-brand-color-900: #101418;
182
+ --pf-brand-color-500: #005ccc;
183
+ --pf-brand-color-600: #004599;
184
+ --pf-brand-color-700: #06356f;
185
+ --pf-brand-color-800: #082345;
186
+ --pf-brand-color-900: #061323;
188
187
 
189
188
  // Purple Color
190
189
  --pf-purple-color: #5c29a3;