@platformatic/ui-components 0.1.134 → 0.1.136
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 +1 -1
- package/src/components/Button.jsx +12 -6
- package/src/components/Button.module.css +8 -0
- package/src/components/ButtonFullRounded.jsx +16 -10
- package/src/components/FollowUs.jsx +49 -21
- package/src/components/forms/Input.jsx +10 -5
- package/src/components/forms/Input.module.css +1 -1
- package/src/components/forms/InputWithSeparator.jsx +51 -20
- package/src/components/forms/InputWithSeparator.module.css +15 -3
- package/tailwind.config.cjs +2 -1
package/package.json
CHANGED
|
@@ -22,6 +22,7 @@ function Button ({
|
|
|
22
22
|
selected,
|
|
23
23
|
...rest
|
|
24
24
|
}) {
|
|
25
|
+
let containerClassName = `${styles.container} ${styles['color-' + color]} ${commonStyles['background-color-' + backgroundColor]} `
|
|
25
26
|
let buttonClassName = classes
|
|
26
27
|
buttonClassName += ` ${styles.button} ${commonStyles['background-color-' + backgroundColor]} ${styles['color-' + color]} ${styles['button-' + size]}`
|
|
27
28
|
if (!bordered) buttonClassName += ` ${styles['no-border']}`
|
|
@@ -43,14 +44,19 @@ function Button ({
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
if (bold) buttonClassName += ` ${styles.fontBold}`
|
|
46
|
-
if (fullWidth)
|
|
47
|
+
if (fullWidth) {
|
|
48
|
+
buttonClassName += ` ${styles.fullWidth}`
|
|
49
|
+
containerClassName += ` ${styles.fullWidth}`
|
|
50
|
+
}
|
|
47
51
|
if (selected) buttonClassName += ' ' + commonStyles[`selected-background-color-${color}`]
|
|
48
52
|
return (
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
<div className={containerClassName}>
|
|
54
|
+
<button className={buttonClassName} disabled={disabled} alt={label} {...rest}>
|
|
55
|
+
{platformaticIcon ? <PlatformaticIcon key='left' iconName={platformaticIcon.iconName} color={platformaticIcon.color} data-testid='button-icon' onClick={null} disabled={disabled} /> : null}
|
|
56
|
+
<span className={styles.label}>{label}</span>
|
|
57
|
+
{platformaticIconAfter ? <PlatformaticIcon key='right' iconName={platformaticIconAfter.iconName} color={platformaticIconAfter.color} data-testid='button-icon' onClick={null} disabled={disabled} /> : null}
|
|
58
|
+
</button>
|
|
59
|
+
</div>
|
|
54
60
|
)
|
|
55
61
|
}
|
|
56
62
|
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
@apply rounded border-0
|
|
3
|
+
}
|
|
1
4
|
.button {
|
|
2
5
|
@apply rounded text-center cursor-pointer font-normal border border-solid box-border flex items-center justify-center gap-x-2;
|
|
6
|
+
background: inherit;
|
|
3
7
|
}
|
|
4
8
|
.fontBold {
|
|
5
9
|
@apply font-semibold;
|
|
@@ -57,6 +61,10 @@
|
|
|
57
61
|
.color-transparent{
|
|
58
62
|
@apply text-transparent border-transparent;
|
|
59
63
|
}
|
|
64
|
+
.color-rich-black{
|
|
65
|
+
@apply text-rich-black border-rich-black;
|
|
66
|
+
}
|
|
67
|
+
|
|
60
68
|
.no-border {
|
|
61
69
|
@apply border-0;
|
|
62
70
|
}
|
|
@@ -17,32 +17,33 @@ function ButtonFullRounded ({
|
|
|
17
17
|
hoverEffect,
|
|
18
18
|
bordered,
|
|
19
19
|
tip,
|
|
20
|
-
selected
|
|
20
|
+
selected,
|
|
21
|
+
buttonClassName
|
|
21
22
|
}) {
|
|
22
23
|
const padding = commonStyles[`padding--${paddingSize}`]
|
|
23
24
|
const containerClassName = `${className} border-0 ${styles.roundedFull}`
|
|
24
|
-
let
|
|
25
|
+
let innerButtonClassName = `${buttonClassName} ${styles.roundedFull} ${styles.buttonRoundedFull} ${padding}`
|
|
25
26
|
if (bordered) {
|
|
26
|
-
|
|
27
|
+
innerButtonClassName += ` ${styles.applyBorder} ` + commonStyles[`bordered--${iconColor}`]
|
|
27
28
|
} else {
|
|
28
|
-
|
|
29
|
+
innerButtonClassName += ` ${styles.borderLess} `
|
|
29
30
|
}
|
|
30
31
|
if (disabled) {
|
|
31
|
-
|
|
32
|
+
innerButtonClassName += ` ${styles.disabled}`
|
|
32
33
|
} else {
|
|
33
34
|
switch (hoverEffect) {
|
|
34
35
|
case BACKGROUND_COLOR_OPAQUE:
|
|
35
|
-
|
|
36
|
+
innerButtonClassName += ' ' + commonStyles[`hover-${BACKGROUND_COLOR_OPAQUE}-${iconColor}`]
|
|
36
37
|
break
|
|
37
38
|
default:
|
|
38
39
|
break
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
if (selected)
|
|
42
|
+
if (selected) innerButtonClassName += ' ' + commonStyles[`selected-background-color-${iconColor}`]
|
|
42
43
|
|
|
43
44
|
return (
|
|
44
45
|
<div className={containerClassName}>
|
|
45
|
-
<button className={
|
|
46
|
+
<button className={innerButtonClassName} disabled={disabled} onClick={onClick} alt={alt} type='button'>
|
|
46
47
|
<PlatformaticIcon iconName={iconName} size={iconSize} color={iconColor} data-testid='button-icon' onClick={null} tip={tip} />
|
|
47
48
|
</button>
|
|
48
49
|
</div>
|
|
@@ -93,7 +94,11 @@ ButtonFullRounded.propTypes = {
|
|
|
93
94
|
/**
|
|
94
95
|
* Selected: default false
|
|
95
96
|
*/
|
|
96
|
-
selected: PropTypes.bool
|
|
97
|
+
selected: PropTypes.bool,
|
|
98
|
+
/**
|
|
99
|
+
* buttonClassName
|
|
100
|
+
*/
|
|
101
|
+
buttonClassName: PropTypes.string
|
|
97
102
|
|
|
98
103
|
}
|
|
99
104
|
|
|
@@ -109,7 +114,8 @@ ButtonFullRounded.defaultProps = {
|
|
|
109
114
|
hoverEffect: '',
|
|
110
115
|
bordered: false,
|
|
111
116
|
tip: '',
|
|
112
|
-
selected: false
|
|
117
|
+
selected: false,
|
|
118
|
+
buttonClassName: ''
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
export default ButtonFullRounded
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import styles from './FollowUs.module.css'
|
|
4
4
|
import Icons from './icons'
|
|
5
5
|
import { MAIN_GREEN, WHITE, MEDIUM, SMALL, MAIN_DARK_BLUE, LIGHT_GREEN } from './constants'
|
|
6
6
|
|
|
7
|
+
function SocialElement ({ href, iconName, iconClassName, iconColor, iconSize }) {
|
|
8
|
+
const [hover, setHover] = useState(false)
|
|
9
|
+
|
|
10
|
+
const icon = React.createElement(Icons[`${iconName}`], {
|
|
11
|
+
color: iconColor,
|
|
12
|
+
size: iconSize,
|
|
13
|
+
tip: '',
|
|
14
|
+
disabled: !hover
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<div className={iconClassName} onMouseLeave={() => setHover(false)} onMouseOver={() => setHover(true)}>
|
|
19
|
+
<a href={href} target='_blank' rel='noopener noreferrer'>
|
|
20
|
+
{icon}
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
7
26
|
function FollowUs ({ label, labelClassName, useOnFrontpage, iconColor, iconSize, labelColor }) {
|
|
8
27
|
const suffix = useOnFrontpage ? 'Frontpage' : 'Dashboard'
|
|
9
28
|
const className = styles[`container${suffix}`]
|
|
@@ -14,26 +33,35 @@ function FollowUs ({ label, labelClassName, useOnFrontpage, iconColor, iconSize,
|
|
|
14
33
|
<div className={labelClassName}>
|
|
15
34
|
{label}
|
|
16
35
|
</div>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
<SocialElement
|
|
38
|
+
href='https://twitter.com/platformatic'
|
|
39
|
+
iconName='SocialXIcon'
|
|
40
|
+
iconClassName={iconClassName}
|
|
41
|
+
iconColor={iconColor}
|
|
42
|
+
iconSize={iconSize}
|
|
43
|
+
/>
|
|
44
|
+
<SocialElement
|
|
45
|
+
href='https://www.linkedin.com/company/platformatic/'
|
|
46
|
+
iconName='SocialLinkedInIcon'
|
|
47
|
+
iconClassName={iconClassName}
|
|
48
|
+
iconColor={iconColor}
|
|
49
|
+
iconSize={iconSize}
|
|
50
|
+
/>
|
|
51
|
+
<SocialElement
|
|
52
|
+
href='https://github.com/platformatic'
|
|
53
|
+
iconName='SocialGitHubIcon'
|
|
54
|
+
iconClassName={iconClassName}
|
|
55
|
+
iconColor={iconColor}
|
|
56
|
+
iconSize={iconSize}
|
|
57
|
+
/>
|
|
58
|
+
<SocialElement
|
|
59
|
+
href='https://discord.gg/platformatic'
|
|
60
|
+
iconName='SocialDiscordIcon'
|
|
61
|
+
iconClassName={iconClassName}
|
|
62
|
+
iconColor={iconColor}
|
|
63
|
+
iconSize={iconSize}
|
|
64
|
+
/>
|
|
37
65
|
</div>
|
|
38
66
|
)
|
|
39
67
|
}
|
|
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import styles from './Input.module.css'
|
|
5
5
|
import commonStyles from '../Common.module.css'
|
|
6
6
|
import PlatformaticIcon from '../PlatformaticIcon'
|
|
7
|
-
import { MAIN_DARK_BLUE, MAIN_GREEN, WHITE } from '../constants'
|
|
7
|
+
import { MAIN_DARK_BLUE, MAIN_GREEN, RICH_BLACK, TRANSPARENT, WHITE } from '../constants'
|
|
8
8
|
import BorderedBox from '../BorderedBox'
|
|
9
9
|
|
|
10
10
|
function Input ({
|
|
@@ -19,7 +19,7 @@ function Input ({
|
|
|
19
19
|
afterIcon,
|
|
20
20
|
focused,
|
|
21
21
|
placeholderApart,
|
|
22
|
-
|
|
22
|
+
backgroundColor,
|
|
23
23
|
inputTextClassName,
|
|
24
24
|
verticalPaddingClassName,
|
|
25
25
|
dataAttrName,
|
|
@@ -29,7 +29,8 @@ function Input ({
|
|
|
29
29
|
let inputClassName = `${commonStyles.fullWidth} ${styles.input} ${inputTextClassName}`
|
|
30
30
|
inputClassName += verticalPaddingClassName || `${styles.inputDefaultVerticalPadding}`
|
|
31
31
|
inputClassName += commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`]
|
|
32
|
-
|
|
32
|
+
inputClassName += ' ' + commonStyles[`background-color-${backgroundColor}`]
|
|
33
|
+
|
|
33
34
|
const showError = errorMessage.length > 0
|
|
34
35
|
if (showError) inputClassName += ' ' + commonStyles['bordered--error-red']
|
|
35
36
|
if (disabled) inputClassName += ' ' + commonStyles['apply-opacity-30']
|
|
@@ -83,7 +84,11 @@ Input.propTypes = {
|
|
|
83
84
|
/**
|
|
84
85
|
* color of border
|
|
85
86
|
*/
|
|
86
|
-
borderColor: PropTypes.oneOf([MAIN_GREEN, MAIN_DARK_BLUE, WHITE]),
|
|
87
|
+
borderColor: PropTypes.oneOf([MAIN_GREEN, MAIN_DARK_BLUE, WHITE, RICH_BLACK]),
|
|
88
|
+
/**
|
|
89
|
+
* color of border
|
|
90
|
+
*/
|
|
91
|
+
backgroundColor: PropTypes.oneOf([MAIN_GREEN, MAIN_DARK_BLUE, WHITE, RICH_BLACK, TRANSPARENT]),
|
|
87
92
|
/**
|
|
88
93
|
* onChange
|
|
89
94
|
*/
|
|
@@ -147,6 +152,7 @@ Input.defaultProps = {
|
|
|
147
152
|
value: '',
|
|
148
153
|
name: '',
|
|
149
154
|
borderColor: MAIN_GREEN,
|
|
155
|
+
backgroundColor: WHITE,
|
|
150
156
|
errorMessage: '',
|
|
151
157
|
onChange: () => {},
|
|
152
158
|
disabled: false,
|
|
@@ -154,7 +160,6 @@ Input.defaultProps = {
|
|
|
154
160
|
afterIcon: null,
|
|
155
161
|
focused: false,
|
|
156
162
|
shadowPlaceholder: false,
|
|
157
|
-
backgroundTransparent: false,
|
|
158
163
|
inputTextClassName: '',
|
|
159
164
|
verticalPaddingClassName: '',
|
|
160
165
|
dataAttrName: '',
|
|
@@ -4,20 +4,41 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import inputStyles from './Input.module.css'
|
|
5
5
|
import styles from './InputWithSeparator.module.css'
|
|
6
6
|
import commonStyles from '../Common.module.css'
|
|
7
|
-
import { BACKGROUND_COLOR_OPAQUE, MAIN_DARK_BLUE, MAIN_GREEN, MEDIUM, TRANSPARENT } from '../constants'
|
|
7
|
+
import { BACKGROUND_COLOR_OPAQUE, MAIN_DARK_BLUE, MAIN_GREEN, MEDIUM, OPACITY_30, RICH_BLACK, SMALL, TRANSPARENT, WHITE } from '../constants'
|
|
8
8
|
import BorderedBox from '../BorderedBox'
|
|
9
9
|
import ButtonFullRounded from '../ButtonFullRounded'
|
|
10
10
|
|
|
11
|
-
function InputWithSeparator ({
|
|
11
|
+
function InputWithSeparator ({
|
|
12
|
+
placeholder,
|
|
13
|
+
name,
|
|
14
|
+
borderColor,
|
|
15
|
+
backgroundColor,
|
|
16
|
+
errorMessage,
|
|
17
|
+
onChange,
|
|
18
|
+
disabled,
|
|
19
|
+
afterIcon,
|
|
20
|
+
value,
|
|
21
|
+
separator,
|
|
22
|
+
inputTextClassName
|
|
23
|
+
}) {
|
|
24
|
+
const baseClassName = `${styles.input} ${styles.flexNone} ${styles.smallMargin} ${inputTextClassName} ` + commonStyles[`background-color-${backgroundColor}`]
|
|
25
|
+
const buttonClassName = commonStyles[`background-color-${borderColor}`] + ' ' + commonStyles['background-color-opaque-30']
|
|
12
26
|
const [chunks, setChunks] = useState([])
|
|
13
|
-
const [inputClassName, setInputClassName] = useState(
|
|
27
|
+
const [inputClassName, setInputClassName] = useState(normalClassName())
|
|
14
28
|
const chunkClasses = `${styles.flexNone} ${styles.smallPadding} ${styles.smallMargin}`
|
|
15
|
-
|
|
16
|
-
let className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}`] + ' ' + commonStyles[`text--${borderColor}`] + ' ' + styles.smallPadding
|
|
29
|
+
let className = styles.inputContainer + ' ' + commonStyles[`bordered--${borderColor}-30`] + ' ' + commonStyles[`text--${borderColor}`]
|
|
17
30
|
const showError = errorMessage.length > 0
|
|
18
31
|
if (showError) className += ' ' + commonStyles['bordered--error-red']
|
|
19
32
|
if (disabled) className += ' ' + commonStyles['apply-opacity-30']
|
|
20
33
|
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (chunks.length > 0) {
|
|
36
|
+
setInputClassName(withChunksClassName())
|
|
37
|
+
} else {
|
|
38
|
+
setInputClassName(normalClassName())
|
|
39
|
+
}
|
|
40
|
+
}, [chunks.length])
|
|
41
|
+
|
|
21
42
|
function handleRemove (chunk) {
|
|
22
43
|
const index = chunks.findIndex(c => c === chunk)
|
|
23
44
|
if (index > -1) {
|
|
@@ -40,24 +61,24 @@ function InputWithSeparator ({ placeholder, name, borderColor, errorMessage, onC
|
|
|
40
61
|
onChange({ value: event.target.value, chunks })
|
|
41
62
|
}
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
64
|
+
function normalClassName () {
|
|
65
|
+
return `${baseClassName} ${commonStyles.fullWidth} `
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function withChunksClassName () {
|
|
69
|
+
return baseClassName
|
|
70
|
+
}
|
|
50
71
|
|
|
51
72
|
function renderChunk (chunk, index) {
|
|
52
73
|
return (
|
|
53
|
-
<BorderedBox color={TRANSPARENT} backgroundColor={
|
|
74
|
+
<BorderedBox color={TRANSPARENT} backgroundColor={borderColor} backgroundColorOpacity={OPACITY_30} classes={chunkClasses} key={index}>
|
|
54
75
|
<div className={styles.chunkContent}>
|
|
55
|
-
<span className={styles.chunkText}>{chunk}</span>
|
|
76
|
+
<span className={`${styles.chunkText} ${inputTextClassName}`}>{chunk}</span>
|
|
56
77
|
<ButtonFullRounded
|
|
57
78
|
iconName='CircleCloseIcon'
|
|
58
|
-
iconSize={
|
|
59
|
-
iconColor={
|
|
60
|
-
|
|
79
|
+
iconSize={SMALL}
|
|
80
|
+
iconColor={WHITE}
|
|
81
|
+
buttonClassName={buttonClassName}
|
|
61
82
|
onClick={() => handleRemove(chunk)}
|
|
62
83
|
bordered={false}
|
|
63
84
|
alt='Close'
|
|
@@ -109,10 +130,18 @@ InputWithSeparator.propTypes = {
|
|
|
109
130
|
* separator
|
|
110
131
|
*/
|
|
111
132
|
separator: PropTypes.string,
|
|
133
|
+
/**
|
|
134
|
+
* inputTextClassName
|
|
135
|
+
*/
|
|
136
|
+
inputTextClassName: PropTypes.string,
|
|
137
|
+
/**
|
|
138
|
+
* color of border
|
|
139
|
+
*/
|
|
140
|
+
borderColor: PropTypes.oneOf([MAIN_GREEN, MAIN_DARK_BLUE, WHITE, RICH_BLACK]),
|
|
112
141
|
/**
|
|
113
142
|
* color of border
|
|
114
143
|
*/
|
|
115
|
-
|
|
144
|
+
backgroundColor: PropTypes.oneOf([MAIN_GREEN, MAIN_DARK_BLUE, WHITE, RICH_BLACK, TRANSPARENT]),
|
|
116
145
|
/**
|
|
117
146
|
* onChange
|
|
118
147
|
*/
|
|
@@ -136,12 +165,14 @@ InputWithSeparator.defaultProps = {
|
|
|
136
165
|
placeholder: '',
|
|
137
166
|
value: '',
|
|
138
167
|
name: '',
|
|
139
|
-
borderColor:
|
|
168
|
+
borderColor: MAIN_GREEN,
|
|
169
|
+
backgroundColor: WHITE,
|
|
140
170
|
errorMessage: '',
|
|
141
171
|
onChange: () => {},
|
|
142
172
|
disabled: false,
|
|
143
173
|
afterIcon: null,
|
|
144
|
-
separator: ''
|
|
174
|
+
separator: '',
|
|
175
|
+
inputTextClassName: ''
|
|
145
176
|
}
|
|
146
177
|
|
|
147
178
|
export default InputWithSeparator
|
|
@@ -2,14 +2,20 @@
|
|
|
2
2
|
@apply flex gap-x-2 w-full items-center;
|
|
3
3
|
}
|
|
4
4
|
.chunkText {
|
|
5
|
-
@apply text-sm
|
|
5
|
+
@apply text-sm;
|
|
6
6
|
}
|
|
7
7
|
.inputContainer {
|
|
8
|
-
@apply flex min-h-[46px] border border-solid box-border rounded-md items-center gap-[0.1rem] flex-wrap relative grow;
|
|
8
|
+
@apply flex min-h-[46px] border border-solid box-border rounded-md items-center gap-[0.1rem] flex-wrap relative grow px-2;
|
|
9
|
+
}
|
|
10
|
+
.input {
|
|
11
|
+
@apply h-full m-0 border-0;
|
|
12
|
+
padding-block: 0;
|
|
13
|
+
padding-inline: 0;
|
|
14
|
+
background: inherit;
|
|
9
15
|
}
|
|
10
16
|
.smallPadding {
|
|
11
17
|
@apply p-1 !important
|
|
12
|
-
}
|
|
18
|
+
}
|
|
13
19
|
.flexNone {
|
|
14
20
|
@apply flex-none !important;
|
|
15
21
|
}
|
|
@@ -25,3 +31,9 @@
|
|
|
25
31
|
.container {
|
|
26
32
|
@apply flex w-full items-center;
|
|
27
33
|
}
|
|
34
|
+
|
|
35
|
+
.input.active,
|
|
36
|
+
.input:focus {
|
|
37
|
+
@apply shadow-white;
|
|
38
|
+
outline: none;
|
|
39
|
+
}
|
package/tailwind.config.cjs
CHANGED
|
@@ -23,7 +23,8 @@ module.exports = {
|
|
|
23
23
|
'dark-blue': '0px 0px 4px rgba(0, 52, 79, 0.5)',
|
|
24
24
|
'light-blue': '0px 0px 4px rgba(233, 247, 255, 0.5)',
|
|
25
25
|
'error-red': '0px 0px 4px rgba(250, 33, 33, 0.5)',
|
|
26
|
-
'tertiary-blue': '0px 0px 4px rgba(37, 136, 228, 0.5)'
|
|
26
|
+
'tertiary-blue': '0px 0px 4px rgba(37, 136, 228, 0.5)',
|
|
27
|
+
white: '0px 0px 4px rgba(255, 255, 255, 0.5)'
|
|
27
28
|
},
|
|
28
29
|
opacity: {
|
|
29
30
|
15: '.15'
|