@platformatic/ui-components 0.6.6 → 0.6.8
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/ButtonOnlyIcon.jsx +6 -1
- package/src/components/ButtonOnlyIcon.module.css +129 -0
- package/src/components/Tag.jsx +24 -7
- package/src/components/Tag.module.css +7 -1
- package/src/components/Tooltip.jsx +11 -7
- package/src/components/Tooltip.module.css +2 -1
- package/src/stories/ButtonOnlyIcon.stories.jsx +4 -0
- package/src/stories/Tag.stories.jsx +22 -1
- package/src/stories/Tooltip.stories.jsx +13 -11
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
import React, { useEffect, useState } from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
-
import styles from './
|
|
4
|
+
import styles from './ButtonOnlyIcon.module.css'
|
|
5
5
|
import commonStyles from './Common.module.css'
|
|
6
6
|
import PlatformaticIcon from './PlatformaticIcon'
|
|
7
7
|
import { SIZES, COLORS_BUTTON, BOX_SHADOW, UNDERLINE, HOVER_EFFECTS_BUTTONS, DULLS_BACKGROUND_COLOR, MAIN_DARK_BLUE, LARGE, MEDIUM, TRANSPARENT } from './constants'
|
|
@@ -19,6 +19,7 @@ function ButtonOnlyIcon ({
|
|
|
19
19
|
fullWidth = false,
|
|
20
20
|
platformaticIcon = null,
|
|
21
21
|
selected = false,
|
|
22
|
+
fullRounded = false,
|
|
22
23
|
...rest
|
|
23
24
|
}) {
|
|
24
25
|
let contentClassName = `${styles.content} `
|
|
@@ -32,6 +33,10 @@ function ButtonOnlyIcon ({
|
|
|
32
33
|
if (fullWidth) {
|
|
33
34
|
baseButtonClassName += ` ${styles.fullWidth}`
|
|
34
35
|
}
|
|
36
|
+
if (fullRounded) {
|
|
37
|
+
baseButtonClassName += ` ${styles.fullRounded}`
|
|
38
|
+
contentClassName += ` ${styles.fullRounded} `
|
|
39
|
+
}
|
|
35
40
|
if (selected) baseButtonClassName += ' ' + commonStyles[`selected-background-color-${color}`]
|
|
36
41
|
const [hover, setHover] = useState(false)
|
|
37
42
|
const [backgroundClassName, setBackgroundClassName] = useState(restClassName())
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
.button {
|
|
2
|
+
@apply rounded text-center cursor-pointer font-normal border border-solid box-border;
|
|
3
|
+
padding-block: 0px;
|
|
4
|
+
padding-inline: 0px;
|
|
5
|
+
}
|
|
6
|
+
.content {
|
|
7
|
+
@apply rounded flex items-center justify-center gap-x-2;
|
|
8
|
+
background: transparent;
|
|
9
|
+
}
|
|
10
|
+
.fontBold {
|
|
11
|
+
@apply font-semibold;
|
|
12
|
+
}
|
|
13
|
+
.button-small {
|
|
14
|
+
@apply p-1 text-sm;
|
|
15
|
+
}
|
|
16
|
+
.button-medium {
|
|
17
|
+
@apply p-1;
|
|
18
|
+
}
|
|
19
|
+
.button-large {
|
|
20
|
+
@apply p-2;
|
|
21
|
+
}
|
|
22
|
+
.button-extra-large {
|
|
23
|
+
@apply p-2 md:p-2.5;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.margin-right-medium,
|
|
27
|
+
.margin-right-small {
|
|
28
|
+
@apply mr-1;
|
|
29
|
+
}
|
|
30
|
+
.margin-right-large {
|
|
31
|
+
@apply mr-2;
|
|
32
|
+
}
|
|
33
|
+
.margin-right-extra-large {
|
|
34
|
+
@apply mr-3;
|
|
35
|
+
}
|
|
36
|
+
.color-main-green {
|
|
37
|
+
@apply text-main-green border-main-green;
|
|
38
|
+
}
|
|
39
|
+
.color-light-green {
|
|
40
|
+
@apply text-light-green border-light-green;
|
|
41
|
+
}
|
|
42
|
+
.color-dark-green {
|
|
43
|
+
@apply text-dark-green border-dark-green;
|
|
44
|
+
}
|
|
45
|
+
.color-main-dark-blue {
|
|
46
|
+
@apply text-main-dark-blue border-main-dark-blue;
|
|
47
|
+
}
|
|
48
|
+
.color-dark-blue{
|
|
49
|
+
@apply text-dark-blue border-dark-blue;
|
|
50
|
+
}
|
|
51
|
+
.color-light-blue{
|
|
52
|
+
@apply text-light-blue border-light-blue;
|
|
53
|
+
}
|
|
54
|
+
.color-white{
|
|
55
|
+
@apply text-white;
|
|
56
|
+
}
|
|
57
|
+
.color-error-red{
|
|
58
|
+
@apply text-error-red border-error-red;
|
|
59
|
+
}
|
|
60
|
+
.color-tertiary-blue{
|
|
61
|
+
@apply text-tertiary-blue border-tertiary-blue;
|
|
62
|
+
}
|
|
63
|
+
.color-transparent{
|
|
64
|
+
@apply text-transparent border-transparent;
|
|
65
|
+
}
|
|
66
|
+
.color-rich-black{
|
|
67
|
+
@apply text-rich-black border-rich-black;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.no-border {
|
|
71
|
+
@apply border-0;
|
|
72
|
+
}
|
|
73
|
+
.disabled {
|
|
74
|
+
@apply opacity-30 cursor-default;
|
|
75
|
+
}
|
|
76
|
+
.hover-box-shadow-main-green {
|
|
77
|
+
@apply hover:shadow-main-green;
|
|
78
|
+
}
|
|
79
|
+
.hover-box-shadow-light-green {
|
|
80
|
+
@apply hover:shadow-light-green;
|
|
81
|
+
}
|
|
82
|
+
.hover-box-shadow-dark-green {
|
|
83
|
+
@apply hover:shadow-dark-green;
|
|
84
|
+
}
|
|
85
|
+
.hover-box-shadow-main-dark-blue {
|
|
86
|
+
@apply hover:shadow-main-dark-blue;
|
|
87
|
+
}
|
|
88
|
+
.hover-box-shadow-dark-blue {
|
|
89
|
+
@apply hover:shadow-dark-blue;
|
|
90
|
+
}
|
|
91
|
+
.hover-box-shadow-light-blue {
|
|
92
|
+
@apply hover:shadow-light-blue;
|
|
93
|
+
}
|
|
94
|
+
.hover-box-shadow-white {
|
|
95
|
+
@apply hover:shadow-white;
|
|
96
|
+
}
|
|
97
|
+
.hover-box-shadow-error-red {
|
|
98
|
+
@apply hover:shadow-error-red;
|
|
99
|
+
}
|
|
100
|
+
.hover-box-shadow-tertiary-blue {
|
|
101
|
+
@apply hover:shadow-tertiary-blue;
|
|
102
|
+
}
|
|
103
|
+
.hover-box-shadow-rich-black {
|
|
104
|
+
@apply hover:shadow-rich-black;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.underline-effect {
|
|
108
|
+
@apply hover:underline;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.fullWidth {
|
|
112
|
+
@apply w-full;
|
|
113
|
+
}
|
|
114
|
+
.label {
|
|
115
|
+
@apply w-max;
|
|
116
|
+
}
|
|
117
|
+
.inactive {
|
|
118
|
+
@apply opacity-70;
|
|
119
|
+
}
|
|
120
|
+
.active {
|
|
121
|
+
@apply opacity-100;
|
|
122
|
+
}
|
|
123
|
+
.cursorDefault {
|
|
124
|
+
@apply cursor-default;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.fullRounded {
|
|
128
|
+
@apply rounded-full;
|
|
129
|
+
}
|
package/src/components/Tag.jsx
CHANGED
|
@@ -3,7 +3,8 @@ import React from 'react'
|
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
4
|
import commonStyles from './Common.module.css'
|
|
5
5
|
import styles from './Tag.module.css'
|
|
6
|
-
import { COLORS_BUTTON, OPACITY_100, OPACITY_20, OPACITY_30, OPACITY_60, WHITE } from './constants'
|
|
6
|
+
import { COLORS_BUTTON, OPACITY_100, OPACITY_20, OPACITY_30, OPACITY_60, SIZES, WHITE } from './constants'
|
|
7
|
+
import PlatformaticIcon from './PlatformaticIcon'
|
|
7
8
|
|
|
8
9
|
function Tag ({
|
|
9
10
|
text = '',
|
|
@@ -12,7 +13,9 @@ function Tag ({
|
|
|
12
13
|
backgroundColor = '',
|
|
13
14
|
bordered = true,
|
|
14
15
|
opaque = OPACITY_100,
|
|
15
|
-
fullRounded = false
|
|
16
|
+
fullRounded = false,
|
|
17
|
+
platformaticIcon = null,
|
|
18
|
+
paddingClass = ''
|
|
16
19
|
}) {
|
|
17
20
|
const stylesColor = textClassName || commonStyles[`text--${color}`]
|
|
18
21
|
let stylesBorderColor = ''
|
|
@@ -25,10 +28,14 @@ function Tag ({
|
|
|
25
28
|
}
|
|
26
29
|
const stylesBackgroundColor = backgroundColor ? commonStyles[`background-color-${backgroundColor}`] : ''
|
|
27
30
|
const opacity = commonStyles[`background-color-opaque-${opaque}`]
|
|
28
|
-
|
|
31
|
+
let className = `${styles.container} ${styles.tag} ${stylesBorderColor} ${stylesBackgroundColor} ${opacity} `
|
|
32
|
+
className += paddingClass || `${styles.padding} `
|
|
29
33
|
|
|
30
34
|
return (
|
|
31
|
-
<
|
|
35
|
+
<div className={className}>
|
|
36
|
+
{platformaticIcon && <PlatformaticIcon iconName={platformaticIcon.iconName} color={platformaticIcon.color} size={platformaticIcon.size} onClick={null} />}
|
|
37
|
+
<span className={stylesColor}>{text}</span>
|
|
38
|
+
</div>
|
|
32
39
|
)
|
|
33
40
|
}
|
|
34
41
|
Tag.propTypes = {
|
|
@@ -40,7 +47,6 @@ Tag.propTypes = {
|
|
|
40
47
|
* text
|
|
41
48
|
*/
|
|
42
49
|
text: PropTypes.string,
|
|
43
|
-
/**
|
|
44
50
|
/**
|
|
45
51
|
* textClassName
|
|
46
52
|
*/
|
|
@@ -60,8 +66,19 @@ Tag.propTypes = {
|
|
|
60
66
|
/**
|
|
61
67
|
* fullRounded
|
|
62
68
|
*/
|
|
63
|
-
fullRounded: PropTypes.bool
|
|
64
|
-
|
|
69
|
+
fullRounded: PropTypes.bool,
|
|
70
|
+
/**
|
|
71
|
+
* platformaticIcon
|
|
72
|
+
*/
|
|
73
|
+
platformaticIcon: PropTypes.shape({
|
|
74
|
+
iconName: PropTypes.string,
|
|
75
|
+
color: PropTypes.oneOf(COLORS_BUTTON),
|
|
76
|
+
size: PropTypes.oneOf(SIZES)
|
|
77
|
+
}),
|
|
78
|
+
/**
|
|
79
|
+
* paddingClass
|
|
80
|
+
*/
|
|
81
|
+
paddingClass: PropTypes.string
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
export default Tag
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
.tag {
|
|
2
|
-
@apply rounded-md
|
|
2
|
+
@apply rounded-md w-fit;
|
|
3
3
|
}
|
|
4
4
|
.bordered {
|
|
5
5
|
@apply border border-solid;
|
|
6
6
|
}
|
|
7
7
|
.fullRounded {
|
|
8
8
|
@apply rounded-full;
|
|
9
|
+
}
|
|
10
|
+
.container {
|
|
11
|
+
@apply flex flex-row gap-x-2 items-center border-0;
|
|
12
|
+
}
|
|
13
|
+
.padding {
|
|
14
|
+
@apply px-3 py-1
|
|
9
15
|
}
|
|
@@ -15,8 +15,8 @@ function Tooltip ({
|
|
|
15
15
|
offset = 0
|
|
16
16
|
}) {
|
|
17
17
|
let timeout
|
|
18
|
-
const [active, setActive] = useState(activeDependsOnVisible ? visible : false)
|
|
19
|
-
|
|
18
|
+
// const [active, setActive] = useState(activeDependsOnVisible ? visible : false)
|
|
19
|
+
const [active, setActive] = useState(true)
|
|
20
20
|
let componentClassName = tooltipClassName || styles.tooltipTipBaseClass
|
|
21
21
|
componentClassName += ` ${styles.tooltipTip} ` + styles[`${direction}`]
|
|
22
22
|
const fixedStyle = { top: '0px', left: '0px' }
|
|
@@ -31,17 +31,21 @@ function Tooltip ({
|
|
|
31
31
|
if (wrapperRef.current) {
|
|
32
32
|
const referenceBoundingClientRect = wrapperRef.current.getBoundingClientRect()
|
|
33
33
|
if (referenceBoundingClientRect) {
|
|
34
|
-
let topPosition
|
|
35
34
|
let leftPosition
|
|
36
35
|
|
|
37
36
|
switch (direction) {
|
|
38
37
|
case DIRECTION_BOTTOM:
|
|
39
|
-
|
|
40
|
-
fixedStyle.
|
|
41
|
-
|
|
38
|
+
fixedStyle.top = `${referenceBoundingClientRect.y + referenceBoundingClientRect.height + offset}px`
|
|
39
|
+
fixedStyle.left = `${referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2)}px`
|
|
40
|
+
fixedStyle.transform = 'translateX(-50%)'
|
|
42
41
|
break
|
|
43
|
-
case DIRECTION_RIGHT:
|
|
44
42
|
case DIRECTION_LEFT:
|
|
43
|
+
fixedStyle.top = `${referenceBoundingClientRect.y + referenceBoundingClientRect.height / 2}px`
|
|
44
|
+
leftPosition = referenceBoundingClientRect.x - (2 * referenceBoundingClientRect.width) + offset
|
|
45
|
+
fixedStyle.left = `${leftPosition}px`
|
|
46
|
+
break
|
|
47
|
+
case DIRECTION_RIGHT:
|
|
48
|
+
fixedStyle.top = `${referenceBoundingClientRect.y + referenceBoundingClientRect.height / 2}px`
|
|
45
49
|
leftPosition = referenceBoundingClientRect.x + referenceBoundingClientRect.width + offset
|
|
46
50
|
fixedStyle.left = `${leftPosition}px`
|
|
47
51
|
break
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
import Tag from '../components/Tag'
|
|
3
|
+
import { MAIN_GREEN, OPACITY_30, SMALL, TERTIARY_BLUE, WHITE } from '../components/constants'
|
|
3
4
|
export default {
|
|
4
5
|
title: 'Platformatic/Tag',
|
|
5
6
|
component: Tag,
|
|
@@ -17,10 +18,30 @@ export const Sample = Template.bind({})
|
|
|
17
18
|
Sample.args = {
|
|
18
19
|
text: 'Hello Platformatic!'
|
|
19
20
|
}
|
|
21
|
+
|
|
20
22
|
export const Version = Template.bind({})
|
|
21
23
|
Version.args = {
|
|
22
24
|
text: 'v1.2.3',
|
|
23
|
-
backgroundColor:
|
|
25
|
+
backgroundColor: MAIN_GREEN,
|
|
24
26
|
bordered: false,
|
|
25
27
|
opaque: 30
|
|
26
28
|
}
|
|
29
|
+
|
|
30
|
+
export const FullRounded = Template.bind({})
|
|
31
|
+
FullRounded.args = {
|
|
32
|
+
text: 'v1.2.3',
|
|
33
|
+
backgroundColor: WHITE,
|
|
34
|
+
bordered: false,
|
|
35
|
+
opaque: OPACITY_30,
|
|
36
|
+
fullRounded: true
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const WithIcon = Template.bind({})
|
|
40
|
+
WithIcon.args = {
|
|
41
|
+
text: 'adding some icon',
|
|
42
|
+
backgroundColor: TERTIARY_BLUE,
|
|
43
|
+
bordered: false,
|
|
44
|
+
opaque: OPACITY_30,
|
|
45
|
+
fullRounded: true,
|
|
46
|
+
platformaticIcon: { iconName: 'AddIcon', size: SMALL, color: WHITE }
|
|
47
|
+
}
|
|
@@ -71,17 +71,19 @@ export default {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const TemplateWithButton = (args) => (
|
|
74
|
-
<
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
74
|
+
<div style={{ width: '100%', textAlign: 'center' }}>
|
|
75
|
+
<Tooltip {...args}>
|
|
76
|
+
<Button
|
|
77
|
+
color={RICH_BLACK}
|
|
78
|
+
backgroundColor={WHITE}
|
|
79
|
+
onClick={() => alert('clicked Disabled WHITE')}
|
|
80
|
+
bordered={false}
|
|
81
|
+
hoverEffect={CHANGE_BACKGROUND_COLOR}
|
|
82
|
+
hoverEffectProperties={{ changeBackgroundColor: ANTI_FLASH_WHITE }}
|
|
83
|
+
label='Test button'
|
|
84
|
+
/>
|
|
85
|
+
</Tooltip>
|
|
86
|
+
</div>
|
|
85
87
|
)
|
|
86
88
|
|
|
87
89
|
export const TooltipBase = TemplateWithButton.bind({})
|