@platformatic/ui-components 0.1.147 → 0.1.149
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
package/src/components/Modal.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
import React from 'react'
|
|
2
|
+
import React, { useRef } from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import ButtonFullRounded from './ButtonFullRounded'
|
|
5
5
|
import useEscapeKey from '../hooks/useEscapeKey'
|
|
@@ -22,7 +22,9 @@ import {
|
|
|
22
22
|
BASIC,
|
|
23
23
|
MODAL_FULL_DARK,
|
|
24
24
|
MODAL_FULL_LIGHT,
|
|
25
|
-
|
|
25
|
+
MODAL_FULL_RICH_BLACK,
|
|
26
|
+
WHITE,
|
|
27
|
+
RICH_BLACK
|
|
26
28
|
} from './constants'
|
|
27
29
|
import PlatformaticIcon from './PlatformaticIcon'
|
|
28
30
|
|
|
@@ -41,8 +43,8 @@ function Modal ({
|
|
|
41
43
|
let modalClassName = `${styles.modal}`
|
|
42
44
|
modalClassName += ' ' + styles[`modal--${layout}`]
|
|
43
45
|
modalClassName += ' ' + styles[`modal--${size}`]
|
|
44
|
-
|
|
45
46
|
let buttonFullRoundedClassName
|
|
47
|
+
const blurRef = useRef()
|
|
46
48
|
|
|
47
49
|
const headerClassName = styles[`header--${layout}`]
|
|
48
50
|
let modalCoverClassName = `${styles.container} ${styles.fullscreen} `
|
|
@@ -62,11 +64,17 @@ function Modal ({
|
|
|
62
64
|
case MODAL_FULL_LIGHT:
|
|
63
65
|
modalCoverClassName += commonStyles['background-color-light-blue']
|
|
64
66
|
break
|
|
67
|
+
case MODAL_FULL_RICH_BLACK:
|
|
68
|
+
contentFullscreen = styles[`content--${layout}`]
|
|
69
|
+
modalCoverClassName += commonStyles[`background-color-${RICH_BLACK}`]
|
|
70
|
+
modalCoverClassName += ` ${backgroundClassName}`
|
|
71
|
+
buttonFullRoundedClassName = `${styles['close--cover']} `
|
|
72
|
+
buttonFullRoundedClassName += commonStyles[`background-color-${RICH_BLACK}`]
|
|
73
|
+
break
|
|
65
74
|
|
|
66
75
|
default:
|
|
67
76
|
break
|
|
68
77
|
}
|
|
69
|
-
|
|
70
78
|
useEscapeKey(() => setIsOpen(false))
|
|
71
79
|
let whichModal = <></>
|
|
72
80
|
|
|
@@ -80,10 +88,17 @@ function Modal ({
|
|
|
80
88
|
return <Logo width={100} heigth={80} color={MAIN_DARK_BLUE} />
|
|
81
89
|
}
|
|
82
90
|
|
|
91
|
+
function closeModal (event) {
|
|
92
|
+
if (event.target === blurRef.current) {
|
|
93
|
+
setIsOpen(false)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
83
97
|
switch (layout) {
|
|
84
98
|
case MODAL_POPUP_V2:
|
|
85
99
|
whichModal = (
|
|
86
|
-
|
|
100
|
+
|
|
101
|
+
<div className={`${styles['blur-fixed']}`} onClick={(event) => closeModal(event)} ref={blurRef}>
|
|
87
102
|
<div className={styles.content}>
|
|
88
103
|
<div className={modalClassName}>
|
|
89
104
|
<div className={headerClassName}>
|
|
@@ -96,6 +111,7 @@ function Modal ({
|
|
|
96
111
|
</div>
|
|
97
112
|
</div>
|
|
98
113
|
</div>
|
|
114
|
+
|
|
99
115
|
)
|
|
100
116
|
break
|
|
101
117
|
case MODAL_POPUP:
|
|
@@ -122,7 +138,7 @@ function Modal ({
|
|
|
122
138
|
<div className={modalCoverClassName}>
|
|
123
139
|
<div className={headerClassName}>
|
|
124
140
|
<ButtonFullRounded
|
|
125
|
-
|
|
141
|
+
buttonClassName={buttonFullRoundedClassName}
|
|
126
142
|
iconName='CircleCloseIcon'
|
|
127
143
|
iconSize={LARGE}
|
|
128
144
|
iconColor={MAIN_DARK_BLUE}
|
|
@@ -165,6 +181,31 @@ function Modal ({
|
|
|
165
181
|
)
|
|
166
182
|
break
|
|
167
183
|
|
|
184
|
+
case MODAL_FULL_RICH_BLACK:
|
|
185
|
+
whichModal = (
|
|
186
|
+
<div className={modalCoverClassName}>
|
|
187
|
+
<div className={headerClassName}>
|
|
188
|
+
<ButtonFullRounded
|
|
189
|
+
buttonClassName={buttonFullRoundedClassName}
|
|
190
|
+
iconName='CircleCloseIcon'
|
|
191
|
+
iconSize={LARGE}
|
|
192
|
+
iconColor={WHITE}
|
|
193
|
+
hoverEffect={BACKGROUND_COLOR_OPAQUE}
|
|
194
|
+
onClick={() => { setIsOpen(false) }}
|
|
195
|
+
bordered={false}
|
|
196
|
+
alt='Close'
|
|
197
|
+
/>
|
|
198
|
+
</div>
|
|
199
|
+
<div className={contentFullscreen}>
|
|
200
|
+
<div className={titleFullscreen}>
|
|
201
|
+
<Logo width={70} heigth={56} color={WHITE} />
|
|
202
|
+
</div>
|
|
203
|
+
<div>{children}</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
)
|
|
207
|
+
break
|
|
208
|
+
|
|
168
209
|
default:
|
|
169
210
|
break
|
|
170
211
|
}
|
|
@@ -32,12 +32,13 @@
|
|
|
32
32
|
@apply bg-light-blue;
|
|
33
33
|
}
|
|
34
34
|
.fullscreen {
|
|
35
|
-
@apply fixed top-0 left-0 h-screen w-full min-h-screen min-w-full
|
|
35
|
+
@apply fixed top-0 left-0 h-screen w-full min-h-screen min-w-full overflow-y-auto;
|
|
36
36
|
}
|
|
37
37
|
.header--popup-v2,
|
|
38
38
|
.header--popup {
|
|
39
39
|
@apply flex justify-between items-center;
|
|
40
40
|
}
|
|
41
|
+
.header--full-rich-black,
|
|
41
42
|
.header--full-dark,
|
|
42
43
|
.header--full-light,
|
|
43
44
|
.header--cover {
|
|
@@ -49,10 +50,11 @@
|
|
|
49
50
|
.title {
|
|
50
51
|
@apply font-bold text-[20px];
|
|
51
52
|
}
|
|
53
|
+
.content--full-rich-black,
|
|
52
54
|
.content--full-dark,
|
|
53
55
|
.header--full-light,
|
|
54
56
|
.content--cover {
|
|
55
|
-
@apply h-auto w-
|
|
57
|
+
@apply h-auto w-auto p-4 md:pt-4 md:pb-10 md:px-40;
|
|
56
58
|
}
|
|
57
59
|
.title--cover {
|
|
58
60
|
@apply inline-flex items-center;
|
|
@@ -14,11 +14,13 @@ function ModalDirectional ({
|
|
|
14
14
|
title,
|
|
15
15
|
titleClassName,
|
|
16
16
|
children,
|
|
17
|
-
smallLayout
|
|
17
|
+
smallLayout,
|
|
18
|
+
classNameModalLefty
|
|
18
19
|
}) {
|
|
19
20
|
const className = `${styles.container} ${styles.modalLeftCover} ${smallLayout ? styles.smallLayout : styles.normalLayout}`
|
|
20
21
|
const [modalClassName] = useState(className)
|
|
21
22
|
const [variantModalClassName, setVariantModalClassName] = useState(`${styles.container} ${styles.modalLeftCover}`)
|
|
23
|
+
const classNameLefty = classNameModalLefty || styles.modalLefty
|
|
22
24
|
|
|
23
25
|
useEffect(() => {
|
|
24
26
|
setVariantModalClassName(`${modalClassName} ${styles.modalLeftCoverEntering}`)
|
|
@@ -37,7 +39,7 @@ function ModalDirectional ({
|
|
|
37
39
|
<>
|
|
38
40
|
<div className={styles.blur} onClick={() => closeModal()} />
|
|
39
41
|
<div className={variantModalClassName}>
|
|
40
|
-
<div className={
|
|
42
|
+
<div className={classNameLefty}>
|
|
41
43
|
<div className={styles.headerClassName}>
|
|
42
44
|
<PlatformaticIcon iconName='ArrowLongLeftIcon' color={WHITE} size={SMALL} onClick={() => closeModal()} />
|
|
43
45
|
<span className={titleClassName}>{title}</span>
|
|
@@ -69,7 +71,11 @@ ModalDirectional.propTypes = {
|
|
|
69
71
|
/**
|
|
70
72
|
* smallLayout
|
|
71
73
|
*/
|
|
72
|
-
smallLayout: PropTypes.bool
|
|
74
|
+
smallLayout: PropTypes.bool,
|
|
75
|
+
/**
|
|
76
|
+
* classNameLefty
|
|
77
|
+
*/
|
|
78
|
+
classNameLefty: PropTypes.string
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
ModalDirectional.defaultProps = {
|
|
@@ -77,7 +83,8 @@ ModalDirectional.defaultProps = {
|
|
|
77
83
|
setIsOpen: () => {},
|
|
78
84
|
title: '',
|
|
79
85
|
titleClassName: '',
|
|
80
|
-
smallLayout: false
|
|
86
|
+
smallLayout: false,
|
|
87
|
+
classNameLefty: ''
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
export default ModalDirectional
|
|
@@ -36,7 +36,9 @@ export const MODAL_POPUP_V2 = 'popup-v2'
|
|
|
36
36
|
export const MODAL_COVER = 'cover'
|
|
37
37
|
export const MODAL_FULL_DARK = 'full-dark'
|
|
38
38
|
export const MODAL_FULL_LIGHT = 'full-light'
|
|
39
|
-
export const
|
|
39
|
+
export const MODAL_FULL_RICH_BLACK = 'full-rich-black'
|
|
40
|
+
|
|
41
|
+
export const MODAL_LAYOUTS = [MODAL_POPUP_V2, MODAL_POPUP, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT, MODAL_FULL_RICH_BLACK]
|
|
40
42
|
|
|
41
43
|
export const FREE = 'free'
|
|
42
44
|
export const BASIC = 'basic'
|