@platformatic/ui-components 0.2.19 → 0.3.0

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.
@@ -1,71 +0,0 @@
1
- 'use strict'
2
- import PropTypes from 'prop-types'
3
- import styles from './TooltipV2.module.css'
4
- import { useEffect, useRef, useState } from 'react'
5
- import { ALIGNMENT_LEFT, ALIGNMENTS } from './constants'
6
-
7
- function TooltipV2 ({ tooltipClassName, text, visible, alignment, elementClassName }) {
8
- const ref = useRef(null)
9
- const alignmentClassName = styles[`${alignment}PltTooltip`]
10
- const [className, setClassName] = useState(normalClassName())
11
-
12
- useEffect(() => {
13
- if (visible) {
14
- setClassName(visibleClassName())
15
- if (ref.current) {
16
- const referenceBoundingClientRect = document.getElementsByClassName(elementClassName)[0]?.getBoundingClientRect()
17
- if (referenceBoundingClientRect) {
18
- const topPosition = referenceBoundingClientRect.y - (referenceBoundingClientRect.height)
19
- const leftPosition = referenceBoundingClientRect.x + (referenceBoundingClientRect.width / 2)
20
- ref.current.style.top = `${topPosition}px`
21
- ref.current.style.left = `${leftPosition}px`
22
- }
23
- }
24
- } else {
25
- setClassName(normalClassName())
26
- }
27
- }, [visible])
28
-
29
- function normalClassName () {
30
- return `${styles.pltTooltipText} ${tooltipClassName} ${alignmentClassName}`
31
- }
32
-
33
- function visibleClassName () {
34
- return `${normalClassName()} ${styles.pltTooltipTextVisible}`
35
- }
36
-
37
- return <span ref={ref} className={className}>{text}</span>
38
- }
39
-
40
- TooltipV2.propTypes = {
41
- /**
42
- * text
43
- */
44
- text: PropTypes.string,
45
- /**
46
- * tooltipClassName
47
- */
48
- tooltipClassName: PropTypes.string,
49
- /**
50
- * visible
51
- */
52
- visible: PropTypes.bool,
53
- /**
54
- * alignment
55
- */
56
- alignment: PropTypes.oneOf(ALIGNMENTS),
57
- /**
58
- * alignment
59
- */
60
- elementClassName: PropTypes.string
61
- }
62
-
63
- TooltipV2.defaultProps = {
64
- text: '',
65
- tooltipClassName: '',
66
- visible: false,
67
- alignment: ALIGNMENT_LEFT,
68
- elementClassName: ''
69
- }
70
-
71
- export default TooltipV2
@@ -1,31 +0,0 @@
1
-
2
- .pltTooltipText {
3
- @apply bg-white text-rich-black text-center p-2;
4
- z-index: 20;
5
- position: fixed;
6
- visibility: hidden;
7
- border-radius: 6px;
8
- padding: 0.25rem;
9
- opacity: 0;
10
- transition: opacity 0.3s;
11
- transform: translateX(-50%);
12
- }
13
-
14
- .pltTooltipText::after {
15
- content: "";
16
- position: absolute;
17
- top: 100%;
18
- border-width: 5px;
19
- border-style: solid;
20
- border-color: white transparent transparent transparent;
21
- left: 50%;
22
- }
23
-
24
- .leftPltTooltip::after {
25
-
26
- }
27
-
28
- .pltTooltipTextVisible {
29
- visibility: visible;
30
- opacity: 1;
31
- }