@platformatic/ui-components 0.1.148 → 0.1.150

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.
@@ -15,7 +15,7 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  steps:
17
17
  - uses: actions/checkout@v4
18
- - uses: actions/setup-node@v3
18
+ - uses: actions/setup-node@v4
19
19
  with:
20
20
  node-version: 18
21
21
  - run: npm ci
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 18.18.0
1
+ 18.19.0
package/index.js CHANGED
@@ -4,6 +4,7 @@ import BorderedBox from './src/components/BorderedBox'
4
4
  import Box from './src/components/Box'
5
5
  import Button from './src/components/Button'
6
6
  import ButtonFullRounded from './src/components/ButtonFullRounded'
7
+ import ButtonOnlyIcon from './src/components/ButtonOnlyIcon'
7
8
  import Backgrounds from './src/components/backgrounds'
8
9
  import CopyAndPaste from './src/components/CopyAndPaste'
9
10
  import Checkbox from './src/components/Checkbox'
@@ -49,6 +50,7 @@ export {
49
50
  Box,
50
51
  Button,
51
52
  ButtonFullRounded,
53
+ ButtonOnlyIcon,
52
54
  Checkbox,
53
55
  CopyAndPaste,
54
56
  DetailedMetric,
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.1.148",
4
+ "version": "0.1.150",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -0,0 +1,165 @@
1
+ 'use strict'
2
+ import React, { useEffect, useState } from 'react'
3
+ import PropTypes from 'prop-types'
4
+ import styles from './Button.module.css'
5
+ import commonStyles from './Common.module.css'
6
+ import PlatformaticIcon from './PlatformaticIcon'
7
+ import { SIZES, COLORS_BUTTON, BOX_SHADOW, UNDERLINE, HOVER_EFFECTS_BUTTONS, BACKGROUND_COLOR_OPAQUE, MAIN_DARK_BLUE, LARGE, MEDIUM } from './constants'
8
+
9
+ function ButtonOnlyIcon ({
10
+ textClass,
11
+ paddingClass,
12
+ altLabel,
13
+ color,
14
+ backgroundColor,
15
+ size,
16
+ disabled,
17
+ bold,
18
+ hoverEffect,
19
+ bordered,
20
+ fullWidth,
21
+ platformaticIcon,
22
+ platformaticIconAfter,
23
+ selected,
24
+ ...rest
25
+ }) {
26
+ let buttonClassName = textClass
27
+ buttonClassName += ` ${styles.button} ${styles['color-' + color]} `
28
+ let contentClassName = `${styles.content} `
29
+ if (paddingClass) {
30
+ contentClassName += `${paddingClass} `
31
+ } else {
32
+ contentClassName += `${styles['button-' + size]} `
33
+ }
34
+ if (disabled) {
35
+ buttonClassName += ' ' + commonStyles[`bordered--${color}-30`]
36
+ contentClassName += ` ${styles.disabled}`
37
+ } else {
38
+ buttonClassName += bordered ? commonStyles[`bordered--${color}-100`] : ''
39
+ }
40
+ if (!bordered) buttonClassName += ` ${styles['no-border']}`
41
+ if (bold) buttonClassName += ` ${styles.fontBold}`
42
+ if (fullWidth) {
43
+ buttonClassName += ` ${styles.fullWidth}`
44
+ }
45
+ if (selected) buttonClassName += ' ' + commonStyles[`selected-background-color-${color}`]
46
+ const [hover, setHover] = useState(false)
47
+ const [backgroundClassName, setBackgroundClassName] = useState(restClassName())
48
+
49
+ useEffect(() => {
50
+ if (!disabled) {
51
+ if (hover) {
52
+ switch (hoverEffect) {
53
+ case BACKGROUND_COLOR_OPAQUE:
54
+ setBackgroundClassName(restClassName() + ' ' + commonStyles[`hover-${BACKGROUND_COLOR_OPAQUE}-${color}`])
55
+ break
56
+ case BOX_SHADOW:
57
+ setBackgroundClassName(restClassName() + ' ' + styles[`hover-${BOX_SHADOW}-${backgroundColor}`])
58
+ break
59
+ case UNDERLINE:
60
+ setBackgroundClassName(`${restClassName()} ${styles['underline-effect']}`)
61
+ break
62
+ default:
63
+ break
64
+ }
65
+ } else {
66
+ setBackgroundClassName(restClassName())
67
+ }
68
+ }
69
+ }, [disabled, hover, hoverEffect])
70
+
71
+ function restClassName () {
72
+ return `${commonStyles['background-color-' + backgroundColor]} `
73
+ }
74
+
75
+ return (
76
+ <button className={`${buttonClassName} ${restClassName()}`} disabled={disabled} alt={altLabel} {...rest} onMouseLeave={() => setHover(false)} onMouseOver={() => setHover(true)}>
77
+ <div className={`${contentClassName} ${backgroundClassName}`}>
78
+ {platformaticIcon ? <PlatformaticIcon key='center' iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' size={MEDIUM} onClick={null} disabled={disabled} /> : null}
79
+ </div>
80
+ </button>
81
+ )
82
+ }
83
+
84
+ ButtonOnlyIcon.propTypes = {
85
+ /**
86
+ * textClass
87
+ */
88
+ textClass: PropTypes.string,
89
+ /**
90
+ * paddingClass
91
+ */
92
+ paddingClass: PropTypes.string,
93
+ /**
94
+ * altLabel
95
+ */
96
+ altLabel: PropTypes.string,
97
+ /**
98
+ * color of text, icon and borders
99
+ */
100
+ color: PropTypes.oneOf(COLORS_BUTTON),
101
+ /**
102
+ * background color of the button
103
+ */
104
+ backgroundColor: PropTypes.oneOf(COLORS_BUTTON),
105
+ /**
106
+ * Size
107
+ */
108
+ size: PropTypes.oneOf(SIZES),
109
+ /**
110
+ * Disabled
111
+ */
112
+ disabled: PropTypes.bool,
113
+ /**
114
+ * Bold
115
+ */
116
+ bold: PropTypes.bool,
117
+ /**
118
+ * Effect on hover
119
+ */
120
+ hoverEffect: PropTypes.oneOf(HOVER_EFFECTS_BUTTONS),
121
+ /**
122
+ * Apply border: default true
123
+ */
124
+ bordered: PropTypes.bool,
125
+ /**
126
+ * Full Width: default false
127
+ */
128
+ fullWidth: PropTypes.bool,
129
+ /**
130
+ * platformaticIcon: should be removed
131
+ */
132
+ platformaticIcon: PropTypes.shape({
133
+ iconName: PropTypes.string,
134
+ color: PropTypes.string
135
+ }),
136
+ /**
137
+ * platformaticIconAfter: should be removed
138
+ */
139
+ platformaticIconAfter: PropTypes.shape({
140
+ iconName: PropTypes.string,
141
+ color: PropTypes.string
142
+ }),
143
+ /**
144
+ * Selected: default false
145
+ */
146
+ selected: PropTypes.bool
147
+ }
148
+
149
+ ButtonOnlyIcon.defaultProps = {
150
+ textClass: '',
151
+ paddingClass: '',
152
+ altLabel: '',
153
+ color: MAIN_DARK_BLUE,
154
+ backgroundColor: 'transparent',
155
+ disabled: false,
156
+ size: LARGE,
157
+ bold: false,
158
+ hoverEffect: BACKGROUND_COLOR_OPAQUE,
159
+ bordered: true,
160
+ fullWidth: false,
161
+ platformaticIcon: null,
162
+ selected: false
163
+ }
164
+
165
+ export default ButtonOnlyIcon
@@ -22,7 +22,9 @@ import {
22
22
  BASIC,
23
23
  MODAL_FULL_DARK,
24
24
  MODAL_FULL_LIGHT,
25
- WHITE
25
+ MODAL_FULL_RICH_BLACK,
26
+ WHITE,
27
+ RICH_BLACK
26
28
  } from './constants'
27
29
  import PlatformaticIcon from './PlatformaticIcon'
28
30
 
@@ -62,6 +64,13 @@ 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
@@ -129,7 +138,7 @@ function Modal ({
129
138
  <div className={modalCoverClassName}>
130
139
  <div className={headerClassName}>
131
140
  <ButtonFullRounded
132
- className={buttonFullRoundedClassName}
141
+ buttonClassName={buttonFullRoundedClassName}
133
142
  iconName='CircleCloseIcon'
134
143
  iconSize={LARGE}
135
144
  iconColor={MAIN_DARK_BLUE}
@@ -172,6 +181,31 @@ function Modal ({
172
181
  )
173
182
  break
174
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
+
175
209
  default:
176
210
  break
177
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 py-4 pl-20 pr-4 overflow-y-auto;
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-full mt-4 mb-10;
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={styles.modalLefty}>
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 MODAL_LAYOUTS = [MODAL_POPUP_V2, MODAL_POPUP, MODAL_COVER, MODAL_FULL_DARK, MODAL_FULL_LIGHT]
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'
@@ -0,0 +1,75 @@
1
+ 'use strict'
2
+ import React from 'react'
3
+ import ButtonOnlyIcon from '../components/ButtonOnlyIcon'
4
+ import { COLORS_BUTTON, HOVER_EFFECTS_BUTTONS, SIZES, WHITE, RICH_BLACK, BACKGROUND_COLOR_OPAQUE, SMALL } from '../components/constants'
5
+
6
+ const divStyle = {
7
+ width: '100%',
8
+ height: 'auto',
9
+ padding: '2px',
10
+ backgroundColor: 'white'
11
+ }
12
+
13
+ export default {
14
+ title: 'Platformatic/ButtonOnlyIcon',
15
+ component: ButtonOnlyIcon,
16
+ decorators: [
17
+ (Story) => (
18
+ <div style={divStyle}>
19
+ <Story />
20
+ </div>
21
+ )
22
+ ],
23
+ argTypes: {
24
+ altLabel: {
25
+ type: 'string',
26
+ control: 'text'
27
+ },
28
+ bold: {
29
+ type: 'boolean'
30
+ },
31
+ backgroundColor: {
32
+ type: 'radio',
33
+ options: COLORS_BUTTON
34
+ },
35
+ color: {
36
+ type: 'radio',
37
+ options: COLORS_BUTTON
38
+ },
39
+ disabled: {
40
+ type: 'boolean'
41
+ },
42
+ size: {
43
+ type: 'string',
44
+ control: {
45
+ type: 'radio',
46
+ options: SIZES
47
+ }
48
+ },
49
+ hoverEffect: {
50
+ type: 'radio',
51
+ options: HOVER_EFFECTS_BUTTONS
52
+ },
53
+ bordered: {
54
+ type: 'boolean'
55
+ },
56
+ fullWidth: {
57
+ type: 'boolean'
58
+ },
59
+ selected: {
60
+ type: 'boolean'
61
+ }
62
+ }
63
+ }
64
+
65
+ const OnlyIconTemplate = (args) => (<ButtonOnlyIcon {...args} />)
66
+
67
+ export const OnlyIcon = OnlyIconTemplate.bind({})
68
+
69
+ OnlyIcon.args = {
70
+ color: WHITE,
71
+ backgroundColor: RICH_BLACK,
72
+ onClick: () => { alert('hit!') },
73
+ hoverEffect: BACKGROUND_COLOR_OPAQUE,
74
+ platformaticIcon: { size: SMALL, iconName: 'RunningIcon', color: WHITE }
75
+ }