@popsure/dirty-swan 0.50.0 → 0.51.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.
- package/Readme.md +7 -0
- package/dist/cjs/index.js +225 -169
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/components/button/index.d.ts +1 -1
- package/dist/cjs/lib/components/button/index.stories.d.ts +1 -1
- package/dist/cjs/lib/components/{card → cards/card}/index.d.ts +3 -1
- package/dist/{esm/lib/components → cjs/lib/components/cards}/card/index.stories.d.ts +9 -2
- package/dist/cjs/lib/components/cards/cardButton/index.d.ts +5 -11
- package/dist/cjs/lib/components/cards/cardButton/index.stories.d.ts +1 -1
- package/dist/cjs/lib/components/icon/icons/ArrowRightFilled.d.ts +4 -0
- package/dist/cjs/lib/components/icon/icons/index.d.ts +4 -1
- package/dist/cjs/lib/components/input/index.d.ts +1 -1
- package/dist/cjs/lib/components/input/input.stories.d.ts +1 -1
- package/dist/cjs/lib/components/modal/bottomModal/index.d.ts +2 -1
- package/dist/cjs/lib/components/modal/genericModal/index.d.ts +20 -0
- package/dist/cjs/lib/components/modal/hooks/useOnClose.d.ts +2 -0
- package/dist/cjs/lib/components/modal/index.d.ts +4 -3
- package/dist/cjs/lib/components/modal/index.stories.d.ts +2 -0
- package/dist/cjs/lib/components/modal/regularModal/index.d.ts +2 -1
- package/dist/cjs/lib/index.d.ts +1 -1
- package/dist/esm/components/{card → cards/card}/index.js +19 -11
- package/dist/esm/components/cards/card/index.js.map +1 -0
- package/dist/esm/components/{card → cards/card}/index.stories.js +21 -16
- package/dist/esm/components/cards/card/index.stories.js.map +1 -0
- package/dist/esm/components/cards/cardButton/index.js +12 -14
- package/dist/esm/components/cards/cardButton/index.js.map +1 -1
- package/dist/esm/components/cards/cardButton/index.stories.js +4 -4
- package/dist/esm/components/cards/cardButton/index.stories.js.map +1 -1
- package/dist/esm/components/cards/index.js +2 -1
- package/dist/esm/components/cards/index.js.map +1 -1
- package/dist/esm/components/cards/infoCard/index.js +2 -1
- package/dist/esm/components/cards/infoCard/index.js.map +1 -1
- package/dist/esm/components/cards/infoCard/index.stories.js +2 -1
- package/dist/esm/components/cards/infoCard/index.stories.js.map +1 -1
- package/dist/esm/components/icon/icons/ArrowRightFilled.js +13 -0
- package/dist/esm/components/icon/icons/ArrowRightFilled.js.map +1 -0
- package/dist/esm/components/icon/icons.stories.js +5 -2
- package/dist/esm/components/icon/icons.stories.js.map +1 -1
- package/dist/esm/components/icon/index.stories.js +5 -2
- package/dist/esm/components/icon/index.stories.js.map +1 -1
- package/dist/esm/components/modal/bottomModal/index.js +19 -24
- package/dist/esm/components/modal/bottomModal/index.js.map +1 -1
- package/dist/esm/components/modal/bottomOrRegularModal/index.js +3 -2
- package/dist/esm/components/modal/bottomOrRegularModal/index.js.map +1 -1
- package/dist/esm/components/modal/genericModal/index.js +94 -0
- package/dist/esm/components/modal/genericModal/index.js.map +1 -0
- package/dist/esm/components/modal/index.stories.js +26 -3
- package/dist/esm/components/modal/index.stories.js.map +1 -1
- package/dist/esm/components/modal/regularModal/index.js +18 -16
- package/dist/esm/components/modal/regularModal/index.js.map +1 -1
- package/dist/esm/{index-e506c4ca.js → index-73378a46.js} +9 -3
- package/dist/esm/{index-e506c4ca.js.map → index-73378a46.js.map} +1 -1
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/components/button/index.d.ts +1 -1
- package/dist/esm/lib/components/button/index.stories.d.ts +1 -1
- package/dist/esm/lib/components/{card → cards/card}/index.d.ts +3 -1
- package/dist/{cjs/lib/components → esm/lib/components/cards}/card/index.stories.d.ts +9 -2
- package/dist/esm/lib/components/cards/cardButton/index.d.ts +5 -11
- package/dist/esm/lib/components/cards/cardButton/index.stories.d.ts +1 -1
- package/dist/esm/lib/components/icon/icons/ArrowRightFilled.d.ts +4 -0
- package/dist/esm/lib/components/icon/icons/index.d.ts +4 -1
- package/dist/esm/lib/components/input/index.d.ts +1 -1
- package/dist/esm/lib/components/input/input.stories.d.ts +1 -1
- package/dist/esm/lib/components/modal/bottomModal/index.d.ts +2 -1
- package/dist/esm/lib/components/modal/genericModal/index.d.ts +20 -0
- package/dist/esm/lib/components/modal/hooks/useOnClose.d.ts +2 -0
- package/dist/esm/lib/components/modal/index.d.ts +4 -3
- package/dist/esm/lib/components/modal/index.stories.d.ts +2 -0
- package/dist/esm/lib/components/modal/regularModal/index.d.ts +2 -1
- package/dist/esm/lib/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/lib/components/{card → cards/card}/index.stories.tsx +12 -5
- package/src/lib/components/{card → cards/card}/index.tsx +19 -6
- package/src/lib/components/{card → cards/card}/style.module.scss +5 -1
- package/src/lib/components/cards/cardButton/index.stories.tsx +11 -15
- package/src/lib/components/cards/cardButton/index.tsx +33 -48
- package/src/lib/components/cards/cardButton/style.module.scss +4 -37
- package/src/lib/components/icon/assets/arrow-right-filled.svg +4 -0
- package/src/lib/components/icon/icons/ArrowRightFilled.tsx +23 -0
- package/src/lib/components/icon/icons/index.ts +4 -1
- package/src/lib/components/modal/bottomModal/index.tsx +18 -78
- package/src/lib/components/modal/bottomModal/style.module.scss +11 -71
- package/src/lib/components/modal/genericModal/index.tsx +133 -0
- package/src/lib/components/modal/genericModal/style.module.scss +71 -0
- package/src/lib/components/modal/hooks/useOnClose.ts +27 -5
- package/src/lib/components/modal/index.stories.tsx +95 -0
- package/src/lib/components/modal/index.ts +4 -2
- package/src/lib/components/modal/regularModal/index.tsx +20 -61
- package/src/lib/components/modal/regularModal/style.module.scss +6 -74
- package/src/lib/index.tsx +1 -1
- package/dist/esm/components/card/index.js.map +0 -1
- package/dist/esm/components/card/index.stories.js.map +0 -1
- package/dist/esm/useOnClose-d818a54f.js +0 -46
- package/dist/esm/useOnClose-d818a54f.js.map +0 -1
- package/src/lib/components/cards/a.stories.mdx +0 -44
- package/src/lib/components/modal/bottomModal/img/close.svg +0 -4
- package/src/lib/components/modal/regularModal/img/close.svg +0 -4
|
@@ -1,22 +1,5 @@
|
|
|
1
1
|
@use '../../../scss/public/grid' as *;
|
|
2
|
-
|
|
3
|
-
@keyframes fade-in {
|
|
4
|
-
0% {
|
|
5
|
-
background-color: rgba($color: #000000, $alpha: 0);
|
|
6
|
-
}
|
|
7
|
-
100% {
|
|
8
|
-
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@keyframes fade-out {
|
|
13
|
-
from {
|
|
14
|
-
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
15
|
-
}
|
|
16
|
-
to {
|
|
17
|
-
background-color: rgba($color: #000000, $alpha: 0);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
2
|
+
@use '../../../scss/public/colors' as *;
|
|
20
3
|
|
|
21
4
|
@keyframes appear-in {
|
|
22
5
|
0% {
|
|
@@ -41,59 +24,31 @@
|
|
|
41
24
|
}
|
|
42
25
|
}
|
|
43
26
|
|
|
44
|
-
.close {
|
|
45
|
-
border: none;
|
|
46
|
-
background-color: transparent;
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.closeIcon {
|
|
51
|
-
margin: 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.overlay {
|
|
55
|
-
position: fixed;
|
|
56
|
-
|
|
57
|
-
z-index: 100;
|
|
58
|
-
|
|
59
|
-
overflow: auto;
|
|
60
|
-
|
|
61
|
-
top: 0;
|
|
62
|
-
bottom: 0;
|
|
63
|
-
left: 0;
|
|
64
|
-
right: 0;
|
|
65
|
-
|
|
66
|
-
animation: fade-in 0.3s both;
|
|
67
|
-
|
|
68
|
-
&--close {
|
|
69
|
-
@extend .overlay;
|
|
70
|
-
animation-delay: 0.1s;
|
|
71
|
-
animation: fade-out 0.3s both;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
27
|
.wrapper {
|
|
76
28
|
position: relative;
|
|
77
29
|
top: 0;
|
|
78
|
-
width: 100%;
|
|
79
30
|
overflow: hidden;
|
|
80
31
|
}
|
|
81
32
|
|
|
82
33
|
.container {
|
|
83
|
-
background-color: white;
|
|
84
|
-
|
|
85
34
|
border-top-left-radius: 8px;
|
|
86
35
|
border-top-right-radius: 8px;
|
|
87
36
|
|
|
88
|
-
|
|
37
|
+
overflow: auto;
|
|
38
|
+
max-height: 90vh;
|
|
39
|
+
bottom: 0;
|
|
40
|
+
position: fixed;
|
|
41
|
+
|
|
42
|
+
@include p-size-mobile {
|
|
43
|
+
padding-bottom: 48px;
|
|
44
|
+
}
|
|
89
45
|
|
|
90
46
|
animation-name: appear-in;
|
|
91
47
|
animation-duration: 0.4s;
|
|
92
48
|
animation-fill-mode: both;
|
|
93
|
-
animation-timing-function: ease-
|
|
49
|
+
animation-timing-function: ease-in;
|
|
94
50
|
|
|
95
|
-
|
|
96
|
-
@extend .container;
|
|
51
|
+
&Close {
|
|
97
52
|
animation-name: disappear-out;
|
|
98
53
|
animation-duration: 0.4s;
|
|
99
54
|
animation-delay: 0s;
|
|
@@ -101,18 +56,3 @@
|
|
|
101
56
|
animation-timing-function: ease-out;
|
|
102
57
|
}
|
|
103
58
|
}
|
|
104
|
-
|
|
105
|
-
.header {
|
|
106
|
-
height: 60px;
|
|
107
|
-
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
|
|
111
|
-
padding: 0 16px;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
.content {
|
|
115
|
-
@include p-size-mobile {
|
|
116
|
-
padding-bottom: 48px;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Props } from '..';
|
|
2
|
+
import useOnClose from '../hooks/useOnClose';
|
|
3
|
+
|
|
4
|
+
import styles from './style.module.scss';
|
|
5
|
+
import classNamesUtil from 'classnames';
|
|
6
|
+
import { Button } from '../../button';
|
|
7
|
+
import { XIcon } from '../../icon';
|
|
8
|
+
|
|
9
|
+
interface GenericModalProps extends Props {
|
|
10
|
+
classNames?: {
|
|
11
|
+
wrapper?: string | (({ isClosing }: { isClosing: boolean }) => string);
|
|
12
|
+
container?: string | (({ isClosing }: { isClosing: boolean }) => string);
|
|
13
|
+
overlay?: string;
|
|
14
|
+
header?: string;
|
|
15
|
+
closeButton?: string;
|
|
16
|
+
title?: string;
|
|
17
|
+
body?: string;
|
|
18
|
+
footer?: string;
|
|
19
|
+
};
|
|
20
|
+
titleSize?: 'small' | 'default';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const GenericModal = ({
|
|
24
|
+
title,
|
|
25
|
+
isOpen,
|
|
26
|
+
children,
|
|
27
|
+
onClose,
|
|
28
|
+
classNames,
|
|
29
|
+
dismissible = true,
|
|
30
|
+
footer,
|
|
31
|
+
titleSize = 'default',
|
|
32
|
+
}: GenericModalProps) => {
|
|
33
|
+
const {
|
|
34
|
+
isClosing,
|
|
35
|
+
isVisible,
|
|
36
|
+
handleContainerClick,
|
|
37
|
+
handleOnCloseAnimationEnded,
|
|
38
|
+
handleOnClose,
|
|
39
|
+
handleOnOverlayClick,
|
|
40
|
+
} = useOnClose(onClose, isOpen, dismissible);
|
|
41
|
+
|
|
42
|
+
return !isVisible ? null : (
|
|
43
|
+
<div
|
|
44
|
+
className={classNamesUtil(
|
|
45
|
+
classNames?.overlay,
|
|
46
|
+
styles.overlay, {
|
|
47
|
+
[styles.overlayClose]: isClosing,
|
|
48
|
+
}
|
|
49
|
+
)}
|
|
50
|
+
onAnimationEnd={handleOnCloseAnimationEnded}
|
|
51
|
+
onClick={handleOnOverlayClick}
|
|
52
|
+
>
|
|
53
|
+
<div
|
|
54
|
+
className={
|
|
55
|
+
typeof classNames?.wrapper === 'string'
|
|
56
|
+
? classNames?.wrapper
|
|
57
|
+
: classNames?.wrapper?.({ isClosing })
|
|
58
|
+
}
|
|
59
|
+
>
|
|
60
|
+
<div
|
|
61
|
+
className={
|
|
62
|
+
typeof classNames?.container === 'string'
|
|
63
|
+
? classNames?.container
|
|
64
|
+
: classNames?.container?.({ isClosing })
|
|
65
|
+
}
|
|
66
|
+
onClick={handleContainerClick}
|
|
67
|
+
>
|
|
68
|
+
|
|
69
|
+
<div
|
|
70
|
+
className={classNamesUtil(
|
|
71
|
+
'bg-white d-flex ai-center w100 px24 pt24 pb16',
|
|
72
|
+
styles.header, {
|
|
73
|
+
'jc-between': !!children,
|
|
74
|
+
'jc-end': !children,
|
|
75
|
+
}
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{title && (
|
|
79
|
+
<div
|
|
80
|
+
className={classNamesUtil(
|
|
81
|
+
styles.title,
|
|
82
|
+
titleSize === 'small' ? 'p-h4' : 'p-h2'
|
|
83
|
+
)}
|
|
84
|
+
>
|
|
85
|
+
{title}
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
{dismissible && (
|
|
90
|
+
<Button
|
|
91
|
+
hideLabel
|
|
92
|
+
leftIcon={<XIcon color="grey-700" />}
|
|
93
|
+
onClick={handleOnClose}
|
|
94
|
+
type="button"
|
|
95
|
+
variant="textColor"
|
|
96
|
+
className={classNamesUtil(
|
|
97
|
+
classNames?.closeButton,
|
|
98
|
+
'p0',
|
|
99
|
+
styles.closeButton
|
|
100
|
+
)}
|
|
101
|
+
>
|
|
102
|
+
Close modal
|
|
103
|
+
</Button>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<div
|
|
108
|
+
className={classNamesUtil(
|
|
109
|
+
classNames?.body,
|
|
110
|
+
styles.body
|
|
111
|
+
)}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
{footer && (
|
|
117
|
+
<div
|
|
118
|
+
className={classNamesUtil(
|
|
119
|
+
classNames?.footer,
|
|
120
|
+
'bg-white',
|
|
121
|
+
styles.footer
|
|
122
|
+
)}
|
|
123
|
+
>
|
|
124
|
+
<div className="px24 py16">
|
|
125
|
+
{footer}
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
@use "../../../scss/public/colors" as *;
|
|
2
|
+
|
|
3
|
+
@keyframes fade-in {
|
|
4
|
+
0% {
|
|
5
|
+
background-color: rgba($color: #000, $alpha: 0);
|
|
6
|
+
visibility: hidden;
|
|
7
|
+
}
|
|
8
|
+
100% {
|
|
9
|
+
background-color: rgba($color: #000, $alpha: 0.3);
|
|
10
|
+
visibility: visible;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@keyframes fade-out {
|
|
15
|
+
from {
|
|
16
|
+
background-color: rgba($color: #000, $alpha: 0.3);
|
|
17
|
+
visibility: visible;
|
|
18
|
+
}
|
|
19
|
+
to {
|
|
20
|
+
background-color: rgba($color: #000, $alpha: 0);
|
|
21
|
+
visibility: hidden;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.overlay {
|
|
26
|
+
z-index: 100;
|
|
27
|
+
overflow: auto;
|
|
28
|
+
|
|
29
|
+
position: fixed;
|
|
30
|
+
top: 0;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
left: 0;
|
|
33
|
+
right: 0;
|
|
34
|
+
|
|
35
|
+
animation: fade-in 0.3s both;
|
|
36
|
+
|
|
37
|
+
&Close {
|
|
38
|
+
animation-delay: 0.1s;
|
|
39
|
+
animation: fade-out 0.3s both;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.header {
|
|
44
|
+
position: sticky;
|
|
45
|
+
top: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.closeButton {
|
|
49
|
+
width: 32px;
|
|
50
|
+
height: 32px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.body {
|
|
54
|
+
flex-grow: 1;
|
|
55
|
+
overflow: auto;
|
|
56
|
+
|
|
57
|
+
background:
|
|
58
|
+
linear-gradient($ds-white 30%, $ds-white),
|
|
59
|
+
linear-gradient($ds-white, $ds-white 70%),
|
|
60
|
+
linear-gradient($ds-grey-300 30%, $ds-grey-300),
|
|
61
|
+
linear-gradient($ds-grey-300, $ds-grey-300 70%) 0 100%;
|
|
62
|
+
background-repeat: no-repeat;
|
|
63
|
+
background-size: 100% 1px;
|
|
64
|
+
background-attachment: local, local, scroll, scroll;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.footer {
|
|
68
|
+
width: 100%;
|
|
69
|
+
position: sticky;
|
|
70
|
+
bottom: 0;
|
|
71
|
+
}
|
|
@@ -2,6 +2,8 @@ import React, { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
interface OnCloseReturn {
|
|
4
4
|
isClosing: boolean;
|
|
5
|
+
isVisible: boolean;
|
|
6
|
+
handleOnCloseAnimationEnded: () => void;
|
|
5
7
|
handleContainerClick: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
6
8
|
handleOnClose: () => void;
|
|
7
9
|
handleOnOverlayClick: () => void;
|
|
@@ -12,15 +14,20 @@ const useOnClose = (
|
|
|
12
14
|
isOpen: boolean,
|
|
13
15
|
dismissable: boolean
|
|
14
16
|
): OnCloseReturn => {
|
|
17
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
15
18
|
const [isClosing, setIsClosing] = useState(false);
|
|
16
19
|
|
|
17
20
|
const handleOnClose = useCallback(() => {
|
|
18
21
|
setIsClosing(true);
|
|
19
|
-
|
|
22
|
+
}, []);
|
|
23
|
+
|
|
24
|
+
const handleOnCloseAnimationEnded = useCallback(() => {
|
|
25
|
+
if (isVisible && isClosing) {
|
|
20
26
|
onClose();
|
|
27
|
+
setIsVisible(false);
|
|
21
28
|
setIsClosing(false);
|
|
22
|
-
}
|
|
23
|
-
}, [
|
|
29
|
+
}
|
|
30
|
+
}, [isClosing, isVisible, onClose]);
|
|
24
31
|
|
|
25
32
|
const handleOnOverlayClick = useCallback(() => {
|
|
26
33
|
if (!dismissable) {
|
|
@@ -50,12 +57,20 @@ const useOnClose = (
|
|
|
50
57
|
}, [handleEscKey]);
|
|
51
58
|
|
|
52
59
|
useEffect(() => {
|
|
60
|
+
if (isOpen) {
|
|
61
|
+
setIsVisible(true);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!isOpen && isVisible){
|
|
65
|
+
handleOnClose();
|
|
66
|
+
}
|
|
67
|
+
|
|
53
68
|
document.body.style.overflow = isOpen ? 'hidden' : 'auto';
|
|
54
69
|
|
|
55
70
|
return () => {
|
|
56
71
|
document.body.style.overflow = 'auto';
|
|
57
72
|
};
|
|
58
|
-
}, [isOpen]);
|
|
73
|
+
}, [handleOnClose, isOpen, isVisible]);
|
|
59
74
|
|
|
60
75
|
const handleContainerClick = (
|
|
61
76
|
e: React.MouseEvent<HTMLDivElement, MouseEvent>
|
|
@@ -63,7 +78,14 @@ const useOnClose = (
|
|
|
63
78
|
e.stopPropagation();
|
|
64
79
|
};
|
|
65
80
|
|
|
66
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
isClosing,
|
|
83
|
+
isVisible,
|
|
84
|
+
handleContainerClick,
|
|
85
|
+
handleOnCloseAnimationEnded,
|
|
86
|
+
handleOnClose,
|
|
87
|
+
handleOnOverlayClick
|
|
88
|
+
};
|
|
67
89
|
};
|
|
68
90
|
|
|
69
91
|
export default useOnClose;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { BottomModal, BottomOrRegularModal, Props, RegularModal } from '.';
|
|
4
4
|
import { Markdown } from '../markdown';
|
|
5
|
+
import { Button } from '../button';
|
|
5
6
|
|
|
6
7
|
const story = {
|
|
7
8
|
title: 'JSX/Modals',
|
|
@@ -251,4 +252,98 @@ export const NonDismissibleModal = ({
|
|
|
251
252
|
);
|
|
252
253
|
}
|
|
253
254
|
|
|
255
|
+
export const ModalWithFooter = ({
|
|
256
|
+
children,
|
|
257
|
+
isOpen,
|
|
258
|
+
onClose,
|
|
259
|
+
title,
|
|
260
|
+
}: Props) => {
|
|
261
|
+
const [display, setDisplay] = useState(isOpen);
|
|
262
|
+
const handleOnClose = () => {
|
|
263
|
+
onClose();
|
|
264
|
+
setDisplay(false);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<>
|
|
269
|
+
<button
|
|
270
|
+
className="p-btn--primary wmn2"
|
|
271
|
+
onClick={() => setDisplay(true)}
|
|
272
|
+
>
|
|
273
|
+
Click to open modal
|
|
274
|
+
</button>
|
|
275
|
+
|
|
276
|
+
<BottomOrRegularModal
|
|
277
|
+
title={title}
|
|
278
|
+
isOpen={display}
|
|
279
|
+
onClose={handleOnClose}
|
|
280
|
+
footer={(
|
|
281
|
+
<div className='d-flex fd-row gap8'>
|
|
282
|
+
<Button variant='textColor' className='w100' onClick={handleOnClose}>
|
|
283
|
+
Skip
|
|
284
|
+
</Button>
|
|
285
|
+
<Button className='w100' onClick={handleOnClose}>
|
|
286
|
+
Continue
|
|
287
|
+
</Button>
|
|
288
|
+
</div>
|
|
289
|
+
)}
|
|
290
|
+
>
|
|
291
|
+
<div className='p24'>
|
|
292
|
+
<div>
|
|
293
|
+
{children}
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</BottomOrRegularModal>
|
|
297
|
+
</>
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export const ModalWithFooterAndScroll = ({
|
|
302
|
+
children,
|
|
303
|
+
isOpen,
|
|
304
|
+
onClose,
|
|
305
|
+
title,
|
|
306
|
+
}: Props) => {
|
|
307
|
+
const [display, setDisplay] = useState(isOpen);
|
|
308
|
+
const handleOnClose = () => {
|
|
309
|
+
onClose();
|
|
310
|
+
setDisplay(false);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<>
|
|
315
|
+
<button
|
|
316
|
+
className="p-btn--primary wmn2"
|
|
317
|
+
onClick={() => setDisplay(true)}
|
|
318
|
+
>
|
|
319
|
+
Click to open modal
|
|
320
|
+
</button>
|
|
321
|
+
|
|
322
|
+
<BottomOrRegularModal
|
|
323
|
+
title={title}
|
|
324
|
+
isOpen={display}
|
|
325
|
+
onClose={handleOnClose}
|
|
326
|
+
footer={(
|
|
327
|
+
<div className='d-flex fd-row gap8'>
|
|
328
|
+
<Button variant='textColor' className='w100' onClick={handleOnClose}>
|
|
329
|
+
Skip
|
|
330
|
+
</Button>
|
|
331
|
+
<Button className='w100' onClick={handleOnClose}>
|
|
332
|
+
Continue
|
|
333
|
+
</Button>
|
|
334
|
+
</div>
|
|
335
|
+
)}
|
|
336
|
+
>
|
|
337
|
+
<div className='p24'>
|
|
338
|
+
<div>
|
|
339
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
340
|
+
<div style={{ height: '840px' }} />
|
|
341
|
+
{children}
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
</BottomOrRegularModal>
|
|
345
|
+
</>
|
|
346
|
+
);
|
|
347
|
+
}
|
|
348
|
+
|
|
254
349
|
export default story;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { BottomModal } from './bottomModal';
|
|
2
2
|
import { RegularModal } from './regularModal';
|
|
3
3
|
import { BottomOrRegularModal } from './bottomOrRegularModal';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
4
5
|
|
|
5
6
|
export interface Props {
|
|
6
|
-
title?:
|
|
7
|
+
title?: ReactNode;
|
|
7
8
|
isOpen: boolean;
|
|
8
|
-
children:
|
|
9
|
+
children: ReactNode;
|
|
9
10
|
onClose: () => void;
|
|
10
11
|
className?: string;
|
|
11
12
|
dismissible?: boolean;
|
|
13
|
+
footer?: ReactNode;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export { BottomModal, RegularModal, BottomOrRegularModal };
|
|
@@ -1,66 +1,25 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { Props } from '..';
|
|
4
|
-
import useOnClose from '../hooks/useOnClose';
|
|
5
|
-
|
|
6
2
|
import styles from './style.module.scss';
|
|
7
|
-
import { XIcon } from '../../icon/icons';
|
|
8
3
|
import classNames from 'classnames';
|
|
4
|
+
import { GenericModal } from '../genericModal';
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
const RegularModal = ({ className = '', ...rest }: Props) => (
|
|
7
|
+
<GenericModal
|
|
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(
|
|
17
|
+
'bg-white br8 d-flex ai-center fd-column mx-auto my0 wmx8',
|
|
18
|
+
styles.container
|
|
19
|
+
)
|
|
20
|
+
}}
|
|
21
|
+
{...rest}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
<div
|
|
31
|
-
className={isClosing ? styles['overlay--close'] : styles.overlay}
|
|
32
|
-
onClick={handleOnOverlayClick}
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
className={`${
|
|
36
|
-
isClosing ? styles['container--close'] : styles.container
|
|
37
|
-
} ${className}`}
|
|
38
|
-
>
|
|
39
|
-
<div className={styles.body} onClick={handleContainerClick}>
|
|
40
|
-
<div
|
|
41
|
-
className={classNames(styles.header, {
|
|
42
|
-
'jc-between': !!title,
|
|
43
|
-
'jc-end': !title,
|
|
44
|
-
})}
|
|
45
|
-
>
|
|
46
|
-
{title && <div className={`p-h2 ${styles.title}`}>{title}</div>}
|
|
47
|
-
{dismissible && (
|
|
48
|
-
<button
|
|
49
|
-
type="button"
|
|
50
|
-
className={styles.close}
|
|
51
|
-
onClick={handleOnClose}
|
|
52
|
-
>
|
|
53
|
-
<XIcon
|
|
54
|
-
size={24}
|
|
55
|
-
color={'grey-700'}
|
|
56
|
-
className={`${styles.closeIcon}`}
|
|
57
|
-
/>
|
|
58
|
-
</button>
|
|
59
|
-
)}
|
|
60
|
-
</div>
|
|
61
|
-
{children}
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
25
|
+
export { RegularModal };
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
@
|
|
2
|
-
0% {
|
|
3
|
-
background-color: rgba($color: #000000, $alpha: 0);
|
|
4
|
-
visibility: hidden;
|
|
5
|
-
}
|
|
6
|
-
100% {
|
|
7
|
-
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
8
|
-
visibility: visible;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
@keyframes fade-out {
|
|
13
|
-
from {
|
|
14
|
-
background-color: rgba($color: #000000, $alpha: 0.3);
|
|
15
|
-
visibility: visible;
|
|
16
|
-
}
|
|
17
|
-
to {
|
|
18
|
-
background-color: rgba($color: #000000, $alpha: 0);
|
|
19
|
-
visibility: hidden;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
@use "../../../scss/public/colors" as *;
|
|
22
2
|
|
|
23
3
|
@keyframes appear-in {
|
|
24
4
|
0% {
|
|
@@ -46,46 +26,16 @@
|
|
|
46
26
|
}
|
|
47
27
|
}
|
|
48
28
|
|
|
49
|
-
.
|
|
50
|
-
position: fixed;
|
|
51
|
-
|
|
52
|
-
z-index: 100;
|
|
53
|
-
|
|
54
|
-
overflow: auto;
|
|
55
|
-
|
|
56
|
-
top: 0;
|
|
57
|
-
bottom: 0;
|
|
58
|
-
left: 0;
|
|
59
|
-
right: 0;
|
|
60
|
-
|
|
61
|
-
animation: fade-in 0.3s both;
|
|
62
|
-
|
|
63
|
-
&--close {
|
|
64
|
-
@extend .overlay;
|
|
65
|
-
animation-delay: 0.1s;
|
|
66
|
-
animation: fade-out 0.3s both;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.container {
|
|
29
|
+
.wrapper {
|
|
71
30
|
position: relative;
|
|
72
|
-
|
|
73
|
-
display: flex;
|
|
74
|
-
align-items: center;
|
|
75
|
-
|
|
76
|
-
max-width: 592px;
|
|
77
|
-
width: 100%;
|
|
78
31
|
min-height: 100%;
|
|
79
32
|
|
|
80
|
-
margin: 0 auto;
|
|
81
|
-
|
|
82
33
|
animation-name: appear-in;
|
|
83
34
|
animation-duration: 0.4s;
|
|
84
35
|
animation-fill-mode: both;
|
|
85
36
|
animation-timing-function: ease-out;
|
|
86
37
|
|
|
87
|
-
|
|
88
|
-
@extend .container;
|
|
38
|
+
&Close {
|
|
89
39
|
animation-name: disappear-out;
|
|
90
40
|
animation-duration: 0.4s;
|
|
91
41
|
animation-delay: 0s;
|
|
@@ -94,25 +44,7 @@
|
|
|
94
44
|
}
|
|
95
45
|
}
|
|
96
46
|
|
|
97
|
-
.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
margin: 80px auto;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.header {
|
|
104
|
-
display: flex;
|
|
105
|
-
align-items: center;
|
|
106
|
-
|
|
107
|
-
padding: 24px 24px 0 24px;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
.close {
|
|
111
|
-
border: none;
|
|
112
|
-
background-color: transparent;
|
|
113
|
-
cursor: pointer;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.closeIcon {
|
|
117
|
-
margin: 0;
|
|
47
|
+
.container {
|
|
48
|
+
max-height: 96vh;
|
|
49
|
+
overflow: hidden;
|
|
118
50
|
}
|
package/src/lib/index.tsx
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
BottomOrRegularModal,
|
|
23
23
|
} from './components/modal';
|
|
24
24
|
import { InfoCard, CardButton } from './components/cards';
|
|
25
|
-
import { Card, CardProps } from './components/card';
|
|
25
|
+
import { Card, CardProps } from './components/cards/card';
|
|
26
26
|
import { Button } from './components/button';
|
|
27
27
|
import { AutoSuggestMultiSelect } from './components/input/autoSuggestMultiSelect';
|
|
28
28
|
import Chip from './components/chip';
|