@platformatic/ui-components 0.6.7 → 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
CHANGED
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({})
|