@popsure/dirty-swan 0.55.3 → 0.56.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.
Files changed (127) hide show
  1. package/dist/cjs/index.d.ts +2 -2
  2. package/dist/cjs/index.js +2684 -889
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/lib/components/modal/bottomModal/index.d.ts +1 -1
  5. package/dist/cjs/lib/components/modal/fullScreenModal/index.d.ts +3 -0
  6. package/dist/cjs/lib/components/modal/genericModal/index.d.ts +16 -14
  7. package/dist/cjs/lib/components/modal/index.d.ts +4 -1
  8. package/dist/cjs/lib/components/modal/index.stories.d.ts +19 -1
  9. package/dist/cjs/lib/components/modal/regularModal/index.d.ts +1 -1
  10. package/dist/cjs/lib/hooks/useEscapeKey.d.ts +1 -0
  11. package/dist/cjs/lib/hooks/useFocusWithin.d.ts +1 -0
  12. package/dist/cjs/lib/index.d.ts +4 -2
  13. package/dist/esm/{Calendar-3239814b.js → Calendar-d39056f4.js} +9 -9
  14. package/dist/esm/{Calendar-3239814b.js.map → Calendar-d39056f4.js.map} +1 -1
  15. package/dist/esm/{TableSection-a1be2bd3.js → TableSection-24337bc7.js} +1 -1
  16. package/dist/esm/{TableSection-a1be2bd3.js.map → TableSection-24337bc7.js.map} +1 -1
  17. package/dist/esm/components/accordion/index.js +1 -1
  18. package/dist/esm/components/accordion/index.stories.js +1 -1
  19. package/dist/esm/components/autocompleteAddress/index.test.js +1 -1
  20. package/dist/esm/components/badge/index.test.js +1 -1
  21. package/dist/esm/components/button/index.js +4 -4
  22. package/dist/esm/components/button/index.js.map +1 -1
  23. package/dist/esm/components/button/index.test.js +1 -1
  24. package/dist/esm/components/comparisonTable/components/AccordionItem/AccordionItem.js +1 -1
  25. package/dist/esm/components/comparisonTable/components/AccordionItem/index.js +1 -1
  26. package/dist/esm/components/comparisonTable/components/Row/index.js +2 -2
  27. package/dist/esm/components/comparisonTable/components/Row/index.js.map +1 -1
  28. package/dist/esm/components/comparisonTable/components/TableButton/index.test.js +2 -2
  29. package/dist/esm/components/comparisonTable/components/TableRowHeader/index.test.js +2 -2
  30. package/dist/esm/components/comparisonTable/index.js +2 -2
  31. package/dist/esm/components/comparisonTable/index.stories.js +2 -2
  32. package/dist/esm/components/dateSelector/components/Calendar.js +1 -1
  33. package/dist/esm/components/dateSelector/index.js +1 -1
  34. package/dist/esm/components/dateSelector/index.stories.js +1 -1
  35. package/dist/esm/components/dateSelector/index.test.js +2 -2
  36. package/dist/esm/components/informationBox/index.test.js +1 -1
  37. package/dist/esm/components/input/autoSuggestInput/index.js +8 -998
  38. package/dist/esm/components/input/autoSuggestInput/index.js.map +1 -1
  39. package/dist/esm/components/input/autoSuggestInput/index.stories.js +1 -0
  40. package/dist/esm/components/input/autoSuggestInput/index.stories.js.map +1 -1
  41. package/dist/esm/components/input/autoSuggestMultiSelect/index.js +1 -0
  42. package/dist/esm/components/input/autoSuggestMultiSelect/index.js.map +1 -1
  43. package/dist/esm/components/input/autoSuggestMultiSelect/index.stories.js +1 -0
  44. package/dist/esm/components/input/autoSuggestMultiSelect/index.stories.js.map +1 -1
  45. package/dist/esm/components/input/checkbox/index.test.js +1 -1
  46. package/dist/esm/components/input/currency/index.test.js +1 -1
  47. package/dist/esm/components/input/index.js +2 -2
  48. package/dist/esm/components/input/index.js.map +1 -1
  49. package/dist/esm/components/input/radio/index.test.js +1 -1
  50. package/dist/esm/components/input/toggle/index.test.js +1 -1
  51. package/dist/esm/components/modal/bottomModal/index.js +6 -8
  52. package/dist/esm/components/modal/bottomModal/index.js.map +1 -1
  53. package/dist/esm/components/modal/bottomOrRegularModal/index.js +2 -0
  54. package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +1 -1
  55. package/dist/esm/components/modal/fullScreenModal/index.js +29 -0
  56. package/dist/esm/components/modal/fullScreenModal/index.js.map +1 -0
  57. package/dist/esm/components/modal/genericModal/index.js +1751 -13
  58. package/dist/esm/components/modal/genericModal/index.js.map +1 -1
  59. package/dist/esm/components/modal/index.stories.js +48 -21
  60. package/dist/esm/components/modal/index.stories.js.map +1 -1
  61. package/dist/esm/components/modal/regularModal/index.js +6 -7
  62. package/dist/esm/components/modal/regularModal/index.js.map +1 -1
  63. package/dist/esm/components/multiDropzone/index.js +3 -3
  64. package/dist/esm/components/multiDropzone/index.js.map +1 -1
  65. package/dist/esm/components/multiDropzone/index.stories.js +1 -1
  66. package/dist/esm/components/multiDropzone/index.test.js +3 -3
  67. package/dist/esm/components/segmentedControl/index.test.js +1 -1
  68. package/dist/esm/components/signaturePad/index.js +2 -2
  69. package/dist/esm/components/signaturePad/index.js.map +1 -1
  70. package/dist/esm/components/spinner/index.test.js +1 -1
  71. package/dist/esm/components/table/Table.js +4 -2
  72. package/dist/esm/components/table/Table.js.map +1 -1
  73. package/dist/esm/components/table/Table.stories.js +4 -2
  74. package/dist/esm/components/table/Table.stories.js.map +1 -1
  75. package/dist/esm/components/table/Table.test.js +5 -3
  76. package/dist/esm/components/table/Table.test.js.map +1 -1
  77. package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.js +1 -1
  78. package/dist/esm/components/table/components/TableCell/BaseCell/BaseCell.stories.js +1 -1
  79. package/dist/esm/components/table/components/TableCell/TableCell.js +3 -3
  80. package/dist/esm/components/table/components/TableCell/TableCell.js.map +1 -1
  81. package/dist/esm/components/table/components/TableCell/TableCell.test.js +2 -2
  82. package/dist/esm/components/table/components/TableContents/TableContents.js +2 -2
  83. package/dist/esm/components/table/components/TableContents/TableContents.test.js +3 -3
  84. package/dist/esm/components/table/components/TableControls/TableControls.test.js +1 -1
  85. package/dist/esm/components/table/components/TableSection/TableSection.js +2 -2
  86. package/dist/esm/components/table/components/TableSection/TableSection.test.js +3 -3
  87. package/dist/esm/components/toast/index.js +1 -1
  88. package/dist/esm/components/toast/index.stories.js +1 -1
  89. package/dist/esm/components/toast/index.test.js +2 -2
  90. package/dist/esm/{customRender-d03c10b6.js → customRender-be47569b.js} +4 -4
  91. package/dist/esm/{customRender-d03c10b6.js.map → customRender-be47569b.js.map} +1 -1
  92. package/dist/esm/index-171a0108.js +997 -0
  93. package/dist/esm/index-171a0108.js.map +1 -0
  94. package/dist/esm/{index-3aa7e697.js → index-4b19aafb.js} +4 -4
  95. package/dist/esm/{index-3aa7e697.js.map → index-4b19aafb.js.map} +1 -1
  96. package/dist/esm/{index-6f567b0b.js → index-86558de6.js} +2 -2
  97. package/dist/esm/{index-6f567b0b.js.map → index-86558de6.js.map} +1 -1
  98. package/dist/esm/{index-3d286178.js → index-af1860d8.js} +3 -3
  99. package/dist/esm/{index-3d286178.js.map → index-af1860d8.js.map} +1 -1
  100. package/dist/esm/{index-a0ef2ab4.js → index-e27b50cf.js} +4 -4
  101. package/dist/esm/{index-a0ef2ab4.js.map → index-e27b50cf.js.map} +1 -1
  102. package/dist/esm/index.d.ts +2 -2
  103. package/dist/esm/index.js +36 -6
  104. package/dist/esm/index.js.map +1 -1
  105. package/dist/esm/lib/components/modal/bottomModal/index.d.ts +1 -1
  106. package/dist/esm/lib/components/modal/fullScreenModal/index.d.ts +3 -0
  107. package/dist/esm/lib/components/modal/genericModal/index.d.ts +16 -14
  108. package/dist/esm/lib/components/modal/index.d.ts +4 -1
  109. package/dist/esm/lib/components/modal/index.stories.d.ts +19 -1
  110. package/dist/esm/lib/components/modal/regularModal/index.d.ts +1 -1
  111. package/dist/esm/lib/hooks/useEscapeKey.d.ts +1 -0
  112. package/dist/esm/lib/hooks/useFocusWithin.d.ts +1 -0
  113. package/dist/esm/lib/index.d.ts +4 -2
  114. package/dist/esm/util/testUtils/customRender.js +1 -1
  115. package/package.json +2 -1
  116. package/src/index.tsx +4 -1
  117. package/src/lib/components/modal/bottomModal/index.tsx +17 -13
  118. package/src/lib/components/modal/fullScreenModal/index.tsx +28 -0
  119. package/src/lib/components/modal/fullScreenModal/style.module.scss +49 -0
  120. package/src/lib/components/modal/genericModal/index.tsx +88 -88
  121. package/src/lib/components/modal/hooks/useOnClose.ts +10 -8
  122. package/src/lib/components/modal/index.stories.tsx +133 -80
  123. package/src/lib/components/modal/index.ts +4 -1
  124. package/src/lib/components/modal/regularModal/index.tsx +17 -12
  125. package/src/lib/hooks/useEscapeKey.ts +18 -0
  126. package/src/lib/hooks/useFocusWithin.ts +22 -0
  127. package/src/lib/index.tsx +6 -0
@@ -6,18 +6,21 @@ import classNamesUtil from 'classnames';
6
6
  import { Button } from '../../button';
7
7
  import { XIcon } from '../../icon';
8
8
  import { useRef, useEffect } from 'react';
9
+ import FocusLock from 'react-focus-lock';
9
10
 
11
+ export interface GenericModalClassNames {
12
+ wrapper?: string | (({ isClosing }: { isClosing: boolean }) => string);
13
+ container?: string | (({ isClosing }: { isClosing: boolean }) => string);
14
+ overlay?: string;
15
+ header?: string;
16
+ closeButton?: string;
17
+ closeButtonIcon?: string;
18
+ title?: string;
19
+ body?: string;
20
+ footer?: string;
21
+ }
10
22
  interface GenericModalProps extends Props {
11
- classNames?: {
12
- wrapper?: string | (({ isClosing }: { isClosing: boolean }) => string);
13
- container?: string | (({ isClosing }: { isClosing: boolean }) => string);
14
- overlay?: string;
15
- header?: string;
16
- closeButton?: string;
17
- title?: string;
18
- body?: string;
19
- footer?: string;
20
- };
23
+ classNames?: GenericModalClassNames;
21
24
  titleSize?: 'small' | 'default';
22
25
  }
23
26
 
@@ -43,12 +46,12 @@ const InnerModal = ({
43
46
  }
44
47
  const handleOnScroll = () => {
45
48
  if (modalBodyRef.current) {
46
- onModalScroll(modalBodyRef.current.scrollTop, modalBodyRef.current)
49
+ onModalScroll(modalBodyRef.current.scrollTop, modalBodyRef.current);
47
50
  }
48
- }
49
-
51
+ };
52
+
50
53
  modalBodyRef.current.addEventListener('scroll', handleOnScroll);
51
-
54
+
52
55
  return () => {
53
56
  modalBodyRef.current?.removeEventListener('scroll', handleOnScroll);
54
57
  };
@@ -56,105 +59,102 @@ const InnerModal = ({
56
59
 
57
60
  return (
58
61
  <div
59
- className={classNamesUtil(
60
- classNames?.overlay,
61
- styles.overlay, {
62
- [styles.overlayClose]: isClosing,
63
- }
64
- )}
62
+ className={classNamesUtil(classNames?.overlay, styles.overlay, {
63
+ [styles.overlayClose]: isClosing,
64
+ })}
65
65
  onAnimationEnd={handleOnCloseAnimationEnded}
66
66
  onClick={handleOnOverlayClick}
67
67
  >
68
- <div
68
+ <div
69
69
  className={
70
- typeof classNames?.wrapper === 'string'
71
- ? classNames?.wrapper
70
+ typeof classNames?.wrapper === 'string'
71
+ ? classNames?.wrapper
72
72
  : classNames?.wrapper?.({ isClosing })
73
73
  }
74
74
  >
75
75
  <div
76
+ aria-modal="true"
77
+ role="dialog"
76
78
  className={
77
- typeof classNames?.container === 'string'
78
- ? classNames?.container
79
- : classNames?.container?.({ isClosing })
79
+ typeof classNames?.container === 'string'
80
+ ? classNames?.container
81
+ : classNames?.container?.({ isClosing })
80
82
  }
81
83
  onClick={handleContainerClick}
82
84
  >
85
+ <FocusLock returnFocus>
86
+ <div
87
+ className={classNamesUtil(
88
+ 'bg-white d-flex ai-center w100 px24 pt24 pb16',
89
+ styles.header,
90
+ {
91
+ 'jc-between': !!title,
92
+ 'jc-end': !title,
93
+ }
94
+ )}
95
+ >
96
+ {title && (
97
+ <div
98
+ className={classNamesUtil(
99
+ styles.title,
100
+ titleSize === 'small' ? 'p-h4' : 'p-h2'
101
+ )}
102
+ >
103
+ {title}
104
+ </div>
105
+ )}
83
106
 
84
- <div
85
- className={classNamesUtil(
86
- 'bg-white d-flex ai-center w100 px24 pt24 pb16',
87
- styles.header, {
88
- 'jc-between': !!title,
89
- 'jc-end': !title,
90
- }
91
- )}
92
- >
93
- {title && (
107
+ {dismissible && (
108
+ <Button
109
+ hideLabel
110
+ leftIcon={
111
+ <XIcon
112
+ color="grey-700"
113
+ className={classNames?.closeButtonIcon}
114
+ />
115
+ }
116
+ onClick={handleOnClose}
117
+ type="button"
118
+ variant="textColor"
119
+ className={classNamesUtil(
120
+ classNames?.closeButton,
121
+ 'p0',
122
+ styles.closeButton
123
+ )}
124
+ >
125
+ Close modal
126
+ </Button>
127
+ )}
128
+ </div>
129
+
130
+ <div
131
+ className={classNamesUtil('w100', classNames?.body, styles.body)}
132
+ ref={modalBodyRef}
133
+ >
134
+ {children}
135
+ </div>
136
+
137
+ {footer && (
94
138
  <div
95
139
  className={classNamesUtil(
96
- styles.title,
97
- titleSize === 'small' ? 'p-h4' : 'p-h2'
140
+ classNames?.footer,
141
+ 'w100 bg-white',
142
+ styles.footer
98
143
  )}
99
144
  >
100
- {title}
145
+ <div className="p24 pt16">{footer}</div>
101
146
  </div>
102
147
  )}
103
-
104
- {dismissible && (
105
- <Button
106
- hideLabel
107
- leftIcon={<XIcon color="grey-700" />}
108
- onClick={handleOnClose}
109
- type="button"
110
- variant="textColor"
111
- className={classNamesUtil(
112
- classNames?.closeButton,
113
- 'p0',
114
- styles.closeButton
115
- )}
116
- >
117
- Close modal
118
- </Button>
119
- )}
120
- </div>
121
-
122
- <div
123
- className={classNamesUtil(
124
- 'w100',
125
- classNames?.body,
126
- styles.body
127
- )}
128
- ref={modalBodyRef}
129
- >
130
- {children}
131
- </div>
132
-
133
- {footer && (
134
- <div
135
- className={classNamesUtil(
136
- classNames?.footer,
137
- 'w100 bg-white',
138
- styles.footer
139
- )}
140
- >
141
- <div className="p24 pt16">
142
- {footer}
143
- </div>
144
- </div>
145
- )}
148
+ </FocusLock>
146
149
  </div>
147
150
  </div>
148
151
  </div>
149
152
  );
150
- }
153
+ };
151
154
 
152
155
  export const GenericModal = (props: GenericModalProps) => {
153
- const { isOpen, onClose, dismissible = true } = props;
154
- const {
155
- isVisible,
156
- ...rest
157
- } = useOnClose(onClose, isOpen, dismissible);
156
+ const { isOpen, onClose, dismissible = true } = props;
157
+ const { isVisible, ...rest } = useOnClose(onClose, isOpen, dismissible);
158
158
 
159
159
  if (!isVisible) {
160
160
  return null;
@@ -1,10 +1,12 @@
1
- import React, { useCallback, useEffect, useState } from 'react';
1
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  export interface OnCloseReturn {
4
4
  isClosing: boolean;
5
5
  isVisible: boolean;
6
6
  handleOnCloseAnimationEnded: () => void;
7
- handleContainerClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
7
+ handleContainerClick: (
8
+ event: React.MouseEvent<HTMLDivElement, MouseEvent>
9
+ ) => void;
8
10
  handleOnClose: () => void;
9
11
  handleOnOverlayClick: () => void;
10
12
  }
@@ -39,9 +41,9 @@ const useOnClose = (
39
41
 
40
42
  const handleEscKey = useCallback(
41
43
  (e: KeyboardEvent) => {
42
- if (e.code !== 'Escape') return;
43
- if (!dismissable) return null;
44
- if (!isOpen) return null;
44
+ if (e.code !== 'Escape' || !dismissable || !isOpen) {
45
+ return null;
46
+ }
45
47
 
46
48
  handleOnClose();
47
49
  },
@@ -60,8 +62,8 @@ const useOnClose = (
60
62
  if (isOpen) {
61
63
  setIsVisible(true);
62
64
  }
63
-
64
- if (!isOpen && isVisible){
65
+
66
+ if (!isOpen && isVisible) {
65
67
  handleOnClose();
66
68
  }
67
69
 
@@ -84,7 +86,7 @@ const useOnClose = (
84
86
  handleContainerClick,
85
87
  handleOnCloseAnimationEnded,
86
88
  handleOnClose,
87
- handleOnOverlayClick
89
+ handleOnOverlayClick,
88
90
  };
89
91
  };
90
92
 
@@ -1,70 +1,88 @@
1
-
2
1
  import { useState } from 'react';
3
2
  import { BottomModal, BottomOrRegularModal, Props, RegularModal } from '.';
4
3
  import { Button } from '../button';
4
+ import { FullScreenModal } from './fullScreenModal';
5
5
 
6
6
  const story = {
7
7
  title: 'JSX/Modals',
8
8
  component: BottomOrRegularModal,
9
9
  argTypes: {
10
10
  title: {
11
- description: "The title that needs to be displayed on the modal",
11
+ description: 'The title that needs to be displayed on the modal',
12
12
  },
13
13
  isOpen: {
14
- description: "When set to `true`, the modal is displayed. When set to `false` the modal gets removed",
14
+ description:
15
+ 'When set to `true`, the modal is displayed. When set to `false` the modal gets removed',
15
16
  },
16
17
  dismissible: {
17
- description: "The content that gets displayed on the modal",
18
+ description: 'The content that gets displayed on the modal',
18
19
  },
19
20
  className: {
20
21
  description: 'Any additional className',
21
22
  },
23
+ classNames: {
24
+ description:
25
+ 'Class names for the Modal component and its children elements',
26
+ },
22
27
  size: {
23
28
  description: 'The size of the modal, either large or default.',
24
29
  control: 'radio',
25
30
  options: {
26
31
  default: 'default',
27
32
  large: 'large',
28
- }
33
+ },
29
34
  },
30
35
  children: {
31
36
  description: 'The content that gets displayed on the modal',
32
37
  type: 'text',
33
38
  table: {
34
39
  type: {
35
- summary: 'ReactNode'
36
- }
37
- }
40
+ summary: 'ReactNode',
41
+ },
42
+ },
38
43
  },
39
44
  onClose: {
40
45
  description: 'Callback when the user close the modal',
41
46
  action: true,
42
47
  table: {
43
- category: "Callbacks",
48
+ category: 'Callbacks',
44
49
  },
45
50
  },
46
51
  onModalScroll: {
47
52
  description: 'Callback when the user scroll the modal',
48
53
  action: true,
49
54
  table: {
50
- category: "Callbacks",
51
- }
52
- }
55
+ category: 'Callbacks',
56
+ },
57
+ },
53
58
  },
54
59
  args: {
55
- title: "Modal title",
60
+ title: 'Modal title',
56
61
  isOpen: false,
57
62
  dismissible: true,
58
63
  className: '',
64
+ classNames: {
65
+ wrapper: '',
66
+ container: '',
67
+ overlay: '',
68
+ header: '',
69
+ closeButton: '',
70
+ closeButtonIcon: '',
71
+ title: '',
72
+ body: '',
73
+ footer: '',
74
+ },
59
75
  children: 'Modal content to be displayed',
60
76
  size: 'default',
61
77
  },
62
78
  parameters: {
63
- componentSubtitle: 'Bottom or Regular modal will automatically choose what’s best to display based on the users screen width.',
79
+ componentSubtitle:
80
+ 'Bottom or Regular modal will automatically choose what’s best to display based on the users screen width.',
64
81
  docs: {
65
82
  description: {
66
- component: 'Modals are dialog overlays that prevent the user from interacting with the rest of the website until an action is taken or the dialog is dismissed. Modals are purposefully disruptive and should be used thoughtfully and sparingly.',
67
- }
83
+ component:
84
+ 'Modals are dialog overlays that prevent the user from interacting with the rest of the website until an action is taken or the dialog is dismissed. Modals are purposefully disruptive and should be used thoughtfully and sparingly.',
85
+ },
68
86
  },
69
87
  },
70
88
  };
@@ -72,6 +90,7 @@ const story = {
72
90
  export const BottomOrRegularModalStory = ({
73
91
  children,
74
92
  className,
93
+ classNames,
75
94
  dismissible,
76
95
  isOpen,
77
96
  onClose,
@@ -88,7 +107,7 @@ export const BottomOrRegularModalStory = ({
88
107
  return (
89
108
  <>
90
109
  <button
91
- className="p-btn--primary wmn2"
110
+ className="d-flex p-btn--primary wmn2"
92
111
  onClick={() => setDisplay(true)}
93
112
  >
94
113
  Click to open modal
@@ -97,6 +116,7 @@ export const BottomOrRegularModalStory = ({
97
116
  <BottomOrRegularModal
98
117
  dismissible={dismissible}
99
118
  className={className}
119
+ classNames={classNames}
100
120
  title={title}
101
121
  isOpen={display}
102
122
  size={size}
@@ -104,9 +124,7 @@ export const BottomOrRegularModalStory = ({
104
124
  onClose={handleOnClose}
105
125
  >
106
126
  <div style={{ padding: '0 24px 24px 24px' }}>
107
- <div>
108
- {children}
109
- </div>
127
+ <div>{children}</div>
110
128
  <button
111
129
  className="p-btn--primary mt24 wmn3"
112
130
  onClick={() => setDisplay(false)}
@@ -117,7 +135,7 @@ export const BottomOrRegularModalStory = ({
117
135
  </BottomOrRegularModal>
118
136
  </>
119
137
  );
120
- }
138
+ };
121
139
 
122
140
  BottomOrRegularModalStory.storyName = 'BottomOrRegularModal';
123
141
 
@@ -135,26 +153,21 @@ export const RegularModalStory = ({
135
153
 
136
154
  return (
137
155
  <>
138
- Regular modals are primary meant to be used on Desktop or Tablet environment. The modal will appear in the middle of the screen and the user will be able to dismiss them using the top left "X" icon.
139
- If you want to use it for Mobile only, you should check BottomModal instead.
140
- Want to use either Regular Modal or Bottom Modal based on the screen width? You can use Bottom or Regular modal.
141
-
156
+ Regular modals are primary meant to be used on Desktop or Tablet
157
+ environment. The modal will appear in the middle of the screen and the
158
+ user will be able to dismiss them using the top left "X" icon. If you want
159
+ to use it for Mobile only, you should check BottomModal instead. Want to
160
+ use either Regular Modal or Bottom Modal based on the screen width? You
161
+ can use Bottom or Regular modal.
142
162
  <button
143
- className="p-btn--primary wmn2 mt24"
163
+ className="d-flex p-btn--primary wmn2 mt24"
144
164
  onClick={() => setDisplay(true)}
145
165
  >
146
166
  Click to open modal
147
167
  </button>
148
-
149
- <RegularModal
150
- title={title}
151
- isOpen={display}
152
- onClose={handleOnClose}
153
- >
168
+ <RegularModal title={title} isOpen={display} onClose={handleOnClose}>
154
169
  <div style={{ padding: '0 24px 24px 24px' }}>
155
- <div>
156
- {children}
157
- </div>
170
+ <div>{children}</div>
158
171
  <button
159
172
  className="p-btn--primary mt24 wmn3"
160
173
  onClick={() => setDisplay(false)}
@@ -165,7 +178,7 @@ export const RegularModalStory = ({
165
178
  </RegularModal>
166
179
  </>
167
180
  );
168
- }
181
+ };
169
182
 
170
183
  RegularModalStory.storyName = 'RegularModal';
171
184
 
@@ -183,26 +196,21 @@ export const BottomModalStory = ({
183
196
 
184
197
  return (
185
198
  <>
186
- Bottom modals are primary meant to be used on Mobile environment. The modal will appear from the bottom of the screen and the user will be able to dismiss them using the top left "X" icon.
187
- If you want to use it for Desktop only, you should check Regular modal instead.
188
- Want to use either Regular Modal or Bottom Modal based on the screen width? You can use Bottom or Regular modal.
189
-
199
+ Bottom modals are primary meant to be used on Mobile environment. The
200
+ modal will appear from the bottom of the screen and the user will be able
201
+ to dismiss them using the top left "X" icon. If you want to use it for
202
+ Desktop only, you should check Regular modal instead. Want to use either
203
+ Regular Modal or Bottom Modal based on the screen width? You can use
204
+ Bottom or Regular modal.
190
205
  <button
191
- className="p-btn--primary wmn2 mt24"
206
+ className="d-flex p-btn--primary wmn2 mt24"
192
207
  onClick={() => setDisplay(true)}
193
208
  >
194
209
  Click to open modal
195
210
  </button>
196
-
197
- <BottomModal
198
- title={title}
199
- isOpen={display}
200
- onClose={handleOnClose}
201
- >
211
+ <BottomModal title={title} isOpen={display} onClose={handleOnClose}>
202
212
  <div style={{ padding: '0 24px 24px 24px' }}>
203
- <div>
204
- {children}
205
- </div>
213
+ <div>{children}</div>
206
214
  <button
207
215
  className="p-btn--primary mt24 wmn3"
208
216
  onClick={() => setDisplay(false)}
@@ -213,11 +221,11 @@ export const BottomModalStory = ({
213
221
  </BottomModal>
214
222
  </>
215
223
  );
216
- }
224
+ };
217
225
 
218
226
  BottomModalStory.storyName = 'BottomModal';
219
227
 
220
- export const NonDismissibleModal = ({
228
+ export const FullScreenModalStory = ({
221
229
  children,
222
230
  isOpen,
223
231
  onClose,
@@ -231,18 +239,59 @@ export const NonDismissibleModal = ({
231
239
 
232
240
  return (
233
241
  <>
234
- Setting the dismissible prop to false will hide the close button and prevent the user from closing it using the escape key or clicking outside.
235
- This prop can be useful if we want the user to explicitly interact with the modal options.
242
+ Full screen modals are primary meant to be used as blocker screens. The
243
+ modal will cover the entire screen and the user will be able to dismiss
244
+ them using the top left "X" icon.
245
+ <button
246
+ className="d-flex p-btn--primary wmn2 mt24"
247
+ onClick={() => setDisplay(true)}
248
+ >
249
+ Click to open modal
250
+ </button>
251
+ <FullScreenModal title={title} isOpen={display} onClose={handleOnClose}>
252
+ <div style={{ padding: '0 24px 24px 24px' }}>
253
+ <div>{children}</div>
254
+
255
+ <button
256
+ className="p-btn--primary mt24 wmn3"
257
+ onClick={() => setDisplay(false)}
258
+ >
259
+ Continue
260
+ </button>
261
+ </div>
262
+ </FullScreenModal>
263
+ </>
264
+ );
265
+ };
236
266
 
237
- <strong>Warning:</strong> a modal with the dismissible prop can only be closed by changing the isOpen prop to false.
267
+ FullScreenModalStory.storyName = 'FullScreenModal';
238
268
 
269
+ export const NonDismissibleModal = ({
270
+ children,
271
+ isOpen,
272
+ onClose,
273
+ title,
274
+ }: Props) => {
275
+ const [display, setDisplay] = useState(isOpen);
276
+ const handleOnClose = () => {
277
+ onClose();
278
+ setDisplay(false);
279
+ };
280
+
281
+ return (
282
+ <>
283
+ Setting the dismissible prop to false will hide the close button and
284
+ prevent the user from closing it using the escape key or clicking outside.
285
+ This prop can be useful if we want the user to explicitly interact with
286
+ the modal options.
287
+ <strong>Warning:</strong> a modal with the dismissible prop can only be
288
+ closed by changing the isOpen prop to false.
239
289
  <button
240
- className="p-btn--primary wmn2 mt24"
290
+ className="d-flex p-btn--primary wmn2 mt24"
241
291
  onClick={() => setDisplay(true)}
242
292
  >
243
293
  Click to open modal
244
294
  </button>
245
-
246
295
  <BottomOrRegularModal
247
296
  dismissible={false}
248
297
  title={title}
@@ -250,9 +299,7 @@ export const NonDismissibleModal = ({
250
299
  onClose={handleOnClose}
251
300
  >
252
301
  <div style={{ padding: '0 24px 24px 24px' }}>
253
- <div>
254
- {children}
255
- </div>
302
+ <div>{children}</div>
256
303
  <button
257
304
  className="p-btn--primary mt24 wmn3"
258
305
  onClick={() => setDisplay(false)}
@@ -263,7 +310,7 @@ export const NonDismissibleModal = ({
263
310
  </BottomOrRegularModal>
264
311
  </>
265
312
  );
266
- }
313
+ };
267
314
 
268
315
  export const ModalWithFooter = ({
269
316
  children,
@@ -280,7 +327,7 @@ export const ModalWithFooter = ({
280
327
  return (
281
328
  <>
282
329
  <button
283
- className="p-btn--primary wmn2"
330
+ className="d-flex p-btn--primary wmn2"
284
331
  onClick={() => setDisplay(true)}
285
332
  >
286
333
  Click to open modal
@@ -290,26 +337,28 @@ export const ModalWithFooter = ({
290
337
  title={title}
291
338
  isOpen={display}
292
339
  onClose={handleOnClose}
293
- footer={(
294
- <div className='d-flex fd-row gap8'>
295
- <Button variant='textColor' className='w100' onClick={handleOnClose}>
340
+ footer={
341
+ <div className="d-flex fd-row gap8">
342
+ <Button
343
+ variant="textColor"
344
+ className="w100"
345
+ onClick={handleOnClose}
346
+ >
296
347
  Skip
297
348
  </Button>
298
- <Button className='w100' onClick={handleOnClose}>
349
+ <Button className="w100" onClick={handleOnClose}>
299
350
  Continue
300
351
  </Button>
301
352
  </div>
302
- )}
353
+ }
303
354
  >
304
- <div className='p24'>
305
- <div>
306
- {children}
307
- </div>
355
+ <div className="p24">
356
+ <div>{children}</div>
308
357
  </div>
309
358
  </BottomOrRegularModal>
310
359
  </>
311
360
  );
312
- }
361
+ };
313
362
 
314
363
  export const ModalWithFooterAndScroll = ({
315
364
  children,
@@ -326,7 +375,7 @@ export const ModalWithFooterAndScroll = ({
326
375
  return (
327
376
  <>
328
377
  <button
329
- className="p-btn--primary wmn2"
378
+ className="d-flex p-btn--primary wmn2"
330
379
  onClick={() => setDisplay(true)}
331
380
  >
332
381
  Click to open modal
@@ -336,18 +385,22 @@ export const ModalWithFooterAndScroll = ({
336
385
  title={title}
337
386
  isOpen={display}
338
387
  onClose={handleOnClose}
339
- footer={(
340
- <div className='d-flex fd-row gap8'>
341
- <Button variant='textColor' className='w100' onClick={handleOnClose}>
388
+ footer={
389
+ <div className="d-flex fd-row gap8">
390
+ <Button
391
+ variant="textColor"
392
+ className="w100"
393
+ onClick={handleOnClose}
394
+ >
342
395
  Skip
343
396
  </Button>
344
- <Button className='w100' onClick={handleOnClose}>
397
+ <Button className="w100" onClick={handleOnClose}>
345
398
  Continue
346
399
  </Button>
347
400
  </div>
348
- )}
401
+ }
349
402
  >
350
- <div className='p24'>
403
+ <div className="p24">
351
404
  <div>
352
405
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
353
406
  <div style={{ height: '840px' }} />
@@ -357,6 +410,6 @@ export const ModalWithFooterAndScroll = ({
357
410
  </BottomOrRegularModal>
358
411
  </>
359
412
  );
360
- }
413
+ };
361
414
 
362
415
  export default story;