@platformatic/ui-components 0.3.4 → 0.3.6

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,7 +1,7 @@
1
1
  {
2
2
  "name": "@platformatic/ui-components",
3
3
  "description": "Platformatic UI Components",
4
- "version": "0.3.4",
4
+ "version": "0.3.6",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -119,4 +119,7 @@
119
119
  }
120
120
  .active {
121
121
  @apply opacity-100;
122
+ }
123
+ .cursorDefault {
124
+ @apply cursor-default;
122
125
  }
@@ -62,7 +62,7 @@ function ButtonOnlyIcon ({
62
62
 
63
63
  useEffect(() => {
64
64
  if (disabled) {
65
- setButtonClassName(buttonRestClassName())
65
+ setButtonClassName(buttonRestClassName() + ` ${styles.cursorDefault}`)
66
66
  } else {
67
67
  setButtonClassName(buttonActiveClassName())
68
68
  }
@@ -40,7 +40,8 @@ function Modal ({
40
40
  backgroundClassName,
41
41
  titleClassName,
42
42
  childrenClassContainer,
43
- modalCloseClassName
43
+ modalCloseClassName,
44
+ permanent
44
45
  }) {
45
46
  let contentFullscreen
46
47
  let titleFullscreen
@@ -96,7 +97,10 @@ function Modal ({
96
97
  }
97
98
 
98
99
  function closeModal (event) {
100
+ console.log('closeModal', event)
99
101
  if (event.target === blurRef.current) {
102
+ event.preventDefault()
103
+ event.stopPropagation()
100
104
  setIsOpen(false)
101
105
  }
102
106
  }
@@ -105,7 +109,7 @@ function Modal ({
105
109
  case MODAL_POPUP_V2:
106
110
  whichModal = (
107
111
 
108
- <div className={`${styles['blur-fixed']}`} onClick={(event) => closeModal(event)} ref={blurRef}>
112
+ <div className={`${styles['blur-fixed']}`} onClick={(event) => permanent ? {} : closeModal(event)} ref={blurRef}>
109
113
  <div className={styles.content}>
110
114
  <div className={modalClassName}>
111
115
  <div className={headerClassName}>
@@ -124,7 +128,7 @@ function Modal ({
124
128
  case MODAL_POPUP:
125
129
  whichModal = (
126
130
  <>
127
- <div className={styles.blur} onClick={() => setIsOpen(false)} />
131
+ <div className={styles.blur} onClick={() => permanent ? {} : setIsOpen(false)} />
128
132
  <div className={`${styles.container} ${styles.centered}`}>
129
133
  <div className={modalClassName}>
130
134
  <div className={headerClassName}>
@@ -242,37 +246,41 @@ Modal.propTypes = {
242
246
  */
243
247
  childrenClassContainer: PropTypes.string,
244
248
  /**
245
- * setIsOpen
249
+ * setIsOpen: function from Parent for close/pen
246
250
  */
247
251
  setIsOpen: PropTypes.func,
248
252
  /**
249
- * title
253
+ * title: Title on top for small Modals (check MODAL_LAYOUTS)
250
254
  */
251
255
  title: PropTypes.string,
252
256
  /**
253
- * layout
257
+ * layout: type of Layout of the modal
254
258
  */
255
259
  layout: PropTypes.oneOf(MODAL_LAYOUTS),
256
260
  /**
257
- * Size
261
+ * Size: of the modal
258
262
  */
259
263
  size: PropTypes.oneOf(MODAL_SIZES),
260
264
  /**
261
- * profile
265
+ * profile: deprecated
262
266
  */
263
267
  profile: PropTypes.oneOf(PROFILES),
264
268
  /**
265
- * backgroundClassName
269
+ * backgroundClassName: background of the full screen modal
266
270
  */
267
271
  backgroundClassName: PropTypes.string,
268
272
  /**
269
- * titleClassName
273
+ * titleClassName: classes of the title
270
274
  */
271
275
  titleClassName: PropTypes.string,
272
276
  /**
273
- * modalCloseClassName
277
+ * modalCloseClassName: classes for the closing icon
274
278
  */
275
- modalCloseClassName: PropTypes.string
279
+ modalCloseClassName: PropTypes.string,
280
+ /**
281
+ * permanent: modal could be closed only with Esc, X or Cancel
282
+ */
283
+ permanent: PropTypes.bool
276
284
  }
277
285
 
278
286
  Modal.defaultProps = {
@@ -285,7 +293,8 @@ Modal.defaultProps = {
285
293
  profile: '',
286
294
  backgroundClassName: '',
287
295
  titleClassName: '',
288
- modalCloseClassName: ''
296
+ modalCloseClassName: '',
297
+ permanent: false
289
298
  }
290
299
 
291
300
  export default Modal
@@ -17,7 +17,8 @@ function ModalDirectional ({
17
17
  titleClassName,
18
18
  children,
19
19
  smallLayout,
20
- classNameModalLefty
20
+ classNameModalLefty,
21
+ permanent
21
22
  }) {
22
23
  const className = `${styles.container} ${styles.modalLeftCover} ${smallLayout ? styles.smallLayout : styles.normalLayout}`
23
24
  const [modalClassName] = useState(className)
@@ -39,7 +40,7 @@ function ModalDirectional ({
39
40
 
40
41
  return (
41
42
  <>
42
- <div className={styles.blur} onClick={() => closeModal()} />
43
+ <div className={styles.blur} onClick={() => permanent ? {} : closeModal()} />
43
44
  <div className={variantModalClassName}>
44
45
  <div className={classNameLefty}>
45
46
  <div className={styles.headerClassName}>
@@ -89,7 +90,11 @@ ModalDirectional.propTypes = {
89
90
  /**
90
91
  * classNameLefty
91
92
  */
92
- classNameLefty: PropTypes.string
93
+ classNameLefty: PropTypes.string,
94
+ /**
95
+ * permanent: modal could be closed only with Esc, X or Cancel
96
+ */
97
+ permanent: PropTypes.bool
93
98
  }
94
99
 
95
100
  ModalDirectional.defaultProps = {
@@ -98,7 +103,8 @@ ModalDirectional.defaultProps = {
98
103
  title: '',
99
104
  titleClassName: '',
100
105
  smallLayout: false,
101
- classNameLefty: ''
106
+ classNameLefty: '',
107
+ permanent: false
102
108
  }
103
109
 
104
110
  export default ModalDirectional
@@ -33,7 +33,7 @@
33
33
  left: 12px;
34
34
  }
35
35
 
36
- .center {
36
+ .center, .center::before {
37
37
  left: 50%;
38
38
  transform: translateX(-50%);
39
39
  }
@@ -42,7 +42,7 @@
42
42
  transform: translateX(-100%);
43
43
  }
44
44
  .end::before {
45
- right: 4px;
45
+ right: 12px;
46
46
  }
47
47
 
48
48
 
@@ -4,7 +4,7 @@ import Button from '../components/Button'
4
4
  import BorderedBox from '../components/BorderedBox'
5
5
  import DropDown from '../components/DropDown'
6
6
  import HorizontalSeparator from '../components/HorizontalSeparator'
7
- import { FULL_WIDTH, MAIN_DARK_BLUE, MAIN_GREEN, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT, MODAL_LAYOUTS, MODAL_SIZES } from '../components/constants'
7
+ import { FULL_WIDTH, MAIN_DARK_BLUE, MAIN_GREEN, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT, MODAL_LAYOUTS, MODAL_POPUP_V2, MODAL_SIZES } from '../components/constants'
8
8
  export default {
9
9
  title: 'Platformatic/Modal',
10
10
  component: Modal,
@@ -107,3 +107,54 @@ FullscreenLayoutLight.args = {
107
107
  size: FULL_WIDTH,
108
108
  layout: MODAL_FULL_LIGHT
109
109
  }
110
+
111
+ const NestedModalsTemplate = () => {
112
+ const [isOpen1, setIsOpen1] = useState(false)
113
+ const [isOpen2, setIsOpen2] = useState(false)
114
+ const [isOpen3, setIsOpen3] = useState(false)
115
+
116
+ return (
117
+ <main style={{ height: '1440px', overflow: 'scroll' }}>
118
+ <Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen1(true)} label='Open 1st Modal' />
119
+ {isOpen1 && (
120
+ <Modal
121
+ setIsOpen={setIsOpen1}
122
+ title='Fist One'
123
+ layout={MODAL_POPUP_V2}
124
+ >
125
+ <p style={{ color: 'white' }}>This Is the first</p>
126
+ <Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen2(true)} label='Open 2nd Modal' />
127
+ {isOpen2 && (
128
+ <Modal
129
+ setIsOpen={setIsOpen2}
130
+ title='Second One'
131
+ layout={MODAL_POPUP_V2}
132
+ >
133
+ <p style={{ color: 'white' }}>This Is the second</p>
134
+ <Button color={MAIN_GREEN} backgroundColor={MAIN_DARK_BLUE} onClick={() => setIsOpen3(true)} label='Open 3rd Modal' />
135
+ {isOpen3 && (
136
+ <Modal
137
+ setIsOpen={setIsOpen3}
138
+ title='Third One'
139
+ layout={MODAL_POPUP_V2}
140
+ >
141
+ <p style={{ color: 'white' }}>This Is the third</p>
142
+ </Modal>
143
+ )}
144
+ </Modal>
145
+ )}
146
+ </Modal>
147
+ )}
148
+ </main>
149
+ )
150
+ }
151
+
152
+ export const NestedModals = NestedModalsTemplate.bind({})
153
+ NestedModals.args = {}
154
+
155
+ export const Permanent = Template.bind({})
156
+ Permanent.args = {
157
+ title: 'Permanent modal',
158
+ text: 'Close clicking on Cancel or X or Esc',
159
+ permanent: true
160
+ }