@popsure/dirty-swan 0.56.0 → 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 (31) hide show
  1. package/dist/cjs/index.js +13 -24
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/lib/components/modal/bottomModal/index.d.ts +1 -1
  4. package/dist/cjs/lib/components/modal/fullScreenModal/index.d.ts +2 -2
  5. package/dist/cjs/lib/components/modal/genericModal/index.d.ts +16 -14
  6. package/dist/cjs/lib/components/modal/index.d.ts +2 -0
  7. package/dist/cjs/lib/components/modal/index.stories.d.ts +15 -1
  8. package/dist/cjs/lib/components/modal/regularModal/index.d.ts +1 -1
  9. package/dist/esm/components/modal/bottomModal/index.js +4 -8
  10. package/dist/esm/components/modal/bottomModal/index.js.map +1 -1
  11. package/dist/esm/components/modal/fullScreenModal/index.js +4 -8
  12. package/dist/esm/components/modal/fullScreenModal/index.js.map +1 -1
  13. package/dist/esm/components/modal/genericModal/index.js +1 -1
  14. package/dist/esm/components/modal/genericModal/index.js.map +1 -1
  15. package/dist/esm/components/modal/index.stories.js +31 -17
  16. package/dist/esm/components/modal/index.stories.js.map +1 -1
  17. package/dist/esm/components/modal/regularModal/index.js +4 -7
  18. package/dist/esm/components/modal/regularModal/index.js.map +1 -1
  19. package/dist/esm/lib/components/modal/bottomModal/index.d.ts +1 -1
  20. package/dist/esm/lib/components/modal/fullScreenModal/index.d.ts +2 -2
  21. package/dist/esm/lib/components/modal/genericModal/index.d.ts +16 -14
  22. package/dist/esm/lib/components/modal/index.d.ts +2 -0
  23. package/dist/esm/lib/components/modal/index.stories.d.ts +15 -1
  24. package/dist/esm/lib/components/modal/regularModal/index.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/src/lib/components/modal/bottomModal/index.tsx +17 -13
  27. package/src/lib/components/modal/fullScreenModal/index.tsx +19 -15
  28. package/src/lib/components/modal/genericModal/index.tsx +18 -11
  29. package/src/lib/components/modal/index.stories.tsx +92 -87
  30. package/src/lib/components/modal/index.ts +2 -0
  31. package/src/lib/components/modal/regularModal/index.tsx +17 -12
@@ -1,4 +1,3 @@
1
-
2
1
  import { useState } from 'react';
3
2
  import { BottomModal, BottomOrRegularModal, Props, RegularModal } from '.';
4
3
  import { Button } from '../button';
@@ -9,63 +8,81 @@ const story = {
9
8
  component: BottomOrRegularModal,
10
9
  argTypes: {
11
10
  title: {
12
- description: "The title that needs to be displayed on the modal",
11
+ description: 'The title that needs to be displayed on the modal',
13
12
  },
14
13
  isOpen: {
15
- 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',
16
16
  },
17
17
  dismissible: {
18
- description: "The content that gets displayed on the modal",
18
+ description: 'The content that gets displayed on the modal',
19
19
  },
20
20
  className: {
21
21
  description: 'Any additional className',
22
22
  },
23
+ classNames: {
24
+ description:
25
+ 'Class names for the Modal component and its children elements',
26
+ },
23
27
  size: {
24
28
  description: 'The size of the modal, either large or default.',
25
29
  control: 'radio',
26
30
  options: {
27
31
  default: 'default',
28
32
  large: 'large',
29
- }
33
+ },
30
34
  },
31
35
  children: {
32
36
  description: 'The content that gets displayed on the modal',
33
37
  type: 'text',
34
38
  table: {
35
39
  type: {
36
- summary: 'ReactNode'
37
- }
38
- }
40
+ summary: 'ReactNode',
41
+ },
42
+ },
39
43
  },
40
44
  onClose: {
41
45
  description: 'Callback when the user close the modal',
42
46
  action: true,
43
47
  table: {
44
- category: "Callbacks",
48
+ category: 'Callbacks',
45
49
  },
46
50
  },
47
51
  onModalScroll: {
48
52
  description: 'Callback when the user scroll the modal',
49
53
  action: true,
50
54
  table: {
51
- category: "Callbacks",
52
- }
53
- }
55
+ category: 'Callbacks',
56
+ },
57
+ },
54
58
  },
55
59
  args: {
56
- title: "Modal title",
60
+ title: 'Modal title',
57
61
  isOpen: false,
58
62
  dismissible: true,
59
63
  className: '',
64
+ classNames: {
65
+ wrapper: '',
66
+ container: '',
67
+ overlay: '',
68
+ header: '',
69
+ closeButton: '',
70
+ closeButtonIcon: '',
71
+ title: '',
72
+ body: '',
73
+ footer: '',
74
+ },
60
75
  children: 'Modal content to be displayed',
61
76
  size: 'default',
62
77
  },
63
78
  parameters: {
64
- 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.',
65
81
  docs: {
66
82
  description: {
67
- 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.',
68
- }
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
+ },
69
86
  },
70
87
  },
71
88
  };
@@ -73,6 +90,7 @@ const story = {
73
90
  export const BottomOrRegularModalStory = ({
74
91
  children,
75
92
  className,
93
+ classNames,
76
94
  dismissible,
77
95
  isOpen,
78
96
  onClose,
@@ -98,6 +116,7 @@ export const BottomOrRegularModalStory = ({
98
116
  <BottomOrRegularModal
99
117
  dismissible={dismissible}
100
118
  className={className}
119
+ classNames={classNames}
101
120
  title={title}
102
121
  isOpen={display}
103
122
  size={size}
@@ -105,9 +124,7 @@ export const BottomOrRegularModalStory = ({
105
124
  onClose={handleOnClose}
106
125
  >
107
126
  <div style={{ padding: '0 24px 24px 24px' }}>
108
- <div>
109
- {children}
110
- </div>
127
+ <div>{children}</div>
111
128
  <button
112
129
  className="p-btn--primary mt24 wmn3"
113
130
  onClick={() => setDisplay(false)}
@@ -118,7 +135,7 @@ export const BottomOrRegularModalStory = ({
118
135
  </BottomOrRegularModal>
119
136
  </>
120
137
  );
121
- }
138
+ };
122
139
 
123
140
  BottomOrRegularModalStory.storyName = 'BottomOrRegularModal';
124
141
 
@@ -136,26 +153,21 @@ export const RegularModalStory = ({
136
153
 
137
154
  return (
138
155
  <>
139
- 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.
140
- If you want to use it for Mobile only, you should check BottomModal instead.
141
- Want to use either Regular Modal or Bottom Modal based on the screen width? You can use Bottom or Regular modal.
142
-
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.
143
162
  <button
144
163
  className="d-flex p-btn--primary wmn2 mt24"
145
164
  onClick={() => setDisplay(true)}
146
165
  >
147
166
  Click to open modal
148
167
  </button>
149
-
150
- <RegularModal
151
- title={title}
152
- isOpen={display}
153
- onClose={handleOnClose}
154
- >
168
+ <RegularModal title={title} isOpen={display} onClose={handleOnClose}>
155
169
  <div style={{ padding: '0 24px 24px 24px' }}>
156
- <div>
157
- {children}
158
- </div>
170
+ <div>{children}</div>
159
171
  <button
160
172
  className="p-btn--primary mt24 wmn3"
161
173
  onClick={() => setDisplay(false)}
@@ -166,7 +178,7 @@ export const RegularModalStory = ({
166
178
  </RegularModal>
167
179
  </>
168
180
  );
169
- }
181
+ };
170
182
 
171
183
  RegularModalStory.storyName = 'RegularModal';
172
184
 
@@ -184,26 +196,21 @@ export const BottomModalStory = ({
184
196
 
185
197
  return (
186
198
  <>
187
- 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.
188
- If you want to use it for Desktop only, you should check Regular modal instead.
189
- Want to use either Regular Modal or Bottom Modal based on the screen width? You can use Bottom or Regular modal.
190
-
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.
191
205
  <button
192
206
  className="d-flex p-btn--primary wmn2 mt24"
193
207
  onClick={() => setDisplay(true)}
194
208
  >
195
209
  Click to open modal
196
210
  </button>
197
-
198
- <BottomModal
199
- title={title}
200
- isOpen={display}
201
- onClose={handleOnClose}
202
- >
211
+ <BottomModal title={title} isOpen={display} onClose={handleOnClose}>
203
212
  <div style={{ padding: '0 24px 24px 24px' }}>
204
- <div>
205
- {children}
206
- </div>
213
+ <div>{children}</div>
207
214
  <button
208
215
  className="p-btn--primary mt24 wmn3"
209
216
  onClick={() => setDisplay(false)}
@@ -214,7 +221,7 @@ export const BottomModalStory = ({
214
221
  </BottomModal>
215
222
  </>
216
223
  );
217
- }
224
+ };
218
225
 
219
226
  BottomModalStory.storyName = 'BottomModal';
220
227
 
@@ -232,24 +239,18 @@ export const FullScreenModalStory = ({
232
239
 
233
240
  return (
234
241
  <>
235
- Full screen modals are primary meant to be used as blocker screens. The modal will cover the entire screen and the user will be able to dismiss them using the top left "X" icon.
236
-
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.
237
245
  <button
238
246
  className="d-flex p-btn--primary wmn2 mt24"
239
247
  onClick={() => setDisplay(true)}
240
248
  >
241
249
  Click to open modal
242
250
  </button>
243
-
244
- <FullScreenModal
245
- title={title}
246
- isOpen={display}
247
- onClose={handleOnClose}
248
- >
251
+ <FullScreenModal title={title} isOpen={display} onClose={handleOnClose}>
249
252
  <div style={{ padding: '0 24px 24px 24px' }}>
250
- <div>
251
- {children}
252
- </div>
253
+ <div>{children}</div>
253
254
 
254
255
  <button
255
256
  className="p-btn--primary mt24 wmn3"
@@ -261,7 +262,7 @@ export const FullScreenModalStory = ({
261
262
  </FullScreenModal>
262
263
  </>
263
264
  );
264
- }
265
+ };
265
266
 
266
267
  FullScreenModalStory.storyName = 'FullScreenModal';
267
268
 
@@ -279,18 +280,18 @@ export const NonDismissibleModal = ({
279
280
 
280
281
  return (
281
282
  <>
282
- 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.
283
- This prop can be useful if we want the user to explicitly interact with the modal options.
284
-
285
- <strong>Warning:</strong> a modal with the dismissible prop can only be closed by changing the isOpen prop to false.
286
-
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.
287
289
  <button
288
290
  className="d-flex p-btn--primary wmn2 mt24"
289
291
  onClick={() => setDisplay(true)}
290
292
  >
291
293
  Click to open modal
292
294
  </button>
293
-
294
295
  <BottomOrRegularModal
295
296
  dismissible={false}
296
297
  title={title}
@@ -298,9 +299,7 @@ export const NonDismissibleModal = ({
298
299
  onClose={handleOnClose}
299
300
  >
300
301
  <div style={{ padding: '0 24px 24px 24px' }}>
301
- <div>
302
- {children}
303
- </div>
302
+ <div>{children}</div>
304
303
  <button
305
304
  className="p-btn--primary mt24 wmn3"
306
305
  onClick={() => setDisplay(false)}
@@ -311,7 +310,7 @@ export const NonDismissibleModal = ({
311
310
  </BottomOrRegularModal>
312
311
  </>
313
312
  );
314
- }
313
+ };
315
314
 
316
315
  export const ModalWithFooter = ({
317
316
  children,
@@ -338,26 +337,28 @@ export const ModalWithFooter = ({
338
337
  title={title}
339
338
  isOpen={display}
340
339
  onClose={handleOnClose}
341
- footer={(
342
- <div className='d-flex fd-row gap8'>
343
- <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
+ >
344
347
  Skip
345
348
  </Button>
346
- <Button className='w100' onClick={handleOnClose}>
349
+ <Button className="w100" onClick={handleOnClose}>
347
350
  Continue
348
351
  </Button>
349
352
  </div>
350
- )}
353
+ }
351
354
  >
352
- <div className='p24'>
353
- <div>
354
- {children}
355
- </div>
355
+ <div className="p24">
356
+ <div>{children}</div>
356
357
  </div>
357
358
  </BottomOrRegularModal>
358
359
  </>
359
360
  );
360
- }
361
+ };
361
362
 
362
363
  export const ModalWithFooterAndScroll = ({
363
364
  children,
@@ -384,18 +385,22 @@ export const ModalWithFooterAndScroll = ({
384
385
  title={title}
385
386
  isOpen={display}
386
387
  onClose={handleOnClose}
387
- footer={(
388
- <div className='d-flex fd-row gap8'>
389
- <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
+ >
390
395
  Skip
391
396
  </Button>
392
- <Button className='w100' onClick={handleOnClose}>
397
+ <Button className="w100" onClick={handleOnClose}>
393
398
  Continue
394
399
  </Button>
395
400
  </div>
396
- )}
401
+ }
397
402
  >
398
- <div className='p24'>
403
+ <div className="p24">
399
404
  <div>
400
405
  Lorem ipsum dolor sit amet, consectetur adipiscing elit.
401
406
  <div style={{ height: '840px' }} />
@@ -405,6 +410,6 @@ export const ModalWithFooterAndScroll = ({
405
410
  </BottomOrRegularModal>
406
411
  </>
407
412
  );
408
- }
413
+ };
409
414
 
410
415
  export default story;
@@ -3,6 +3,7 @@ import { RegularModal } from './regularModal';
3
3
  import { BottomOrRegularModal } from './bottomOrRegularModal';
4
4
  import { FullScreenModal } from './fullScreenModal';
5
5
  import { ReactNode } from 'react';
6
+ import { GenericModalClassNames } from './genericModal';
6
7
 
7
8
  export interface Props {
8
9
  title?: ReactNode;
@@ -11,6 +12,7 @@ export interface Props {
11
12
  onClose: () => void;
12
13
  onModalScroll?: (scrollTop: number, element: HTMLDivElement) => void;
13
14
  className?: string;
15
+ classNames?: GenericModalClassNames;
14
16
  dismissible?: boolean;
15
17
  size?: 'default' | 'large';
16
18
  footer?: ReactNode;
@@ -1,23 +1,28 @@
1
1
  import { Props } from '..';
2
2
  import styles from './style.module.scss';
3
- import classNames from 'classnames';
3
+ import classNamesUtil from 'classnames';
4
4
  import { GenericModal } from '../genericModal';
5
5
 
6
- const RegularModal = ({ className = '', size, ...rest }: Props) => (
6
+ const RegularModal = ({ className = '', classNames, size, ...rest }: Props) => (
7
7
  <GenericModal
8
8
  classNames={{
9
- wrapper: ({ isClosing }) => classNames(
10
- 'd-flex ai-center w90 mx-auto my0',
11
- className,
12
- styles.wrapper, {
13
- [styles.wrapperClose]: isClosing,
14
- }
15
- ),
16
- container: classNames(
9
+ ...classNames,
10
+ wrapper: ({ isClosing }) =>
11
+ classNamesUtil(
12
+ 'd-flex ai-center w90 mx-auto my0',
13
+ className,
14
+ styles.wrapper,
15
+ classNames?.wrapper,
16
+ {
17
+ [styles.wrapperClose]: isClosing,
18
+ }
19
+ ),
20
+ container: classNamesUtil(
17
21
  'bg-white br8 d-flex ai-center fd-column mx-auto my0',
18
22
  styles.container,
19
- size === 'large' ? 'wmx10' : 'wmx8'
20
- )
23
+ size === 'large' ? 'wmx10' : 'wmx8',
24
+ classNames?.container
25
+ ),
21
26
  }}
22
27
  {...rest}
23
28
  />