@meduza/ui-kit-2 0.1.15 → 0.1.17
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/dist/ui-kit-2.cjs.development.js +40 -11
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +40 -11
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +1156 -1151
- package/package.json +1 -1
- package/src/DotsOnImage/DotsOnImage.module.css +11 -5
- package/src/DotsOnImage/index.tsx +44 -13
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
width: 100%;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
.isVisible .
|
|
11
|
+
.isVisible .marker {
|
|
12
12
|
animation: show 400ms ease both 500ms;
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -18,7 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
width: 28px;
|
|
20
20
|
height: 28px;
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
will-change: opacity;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.marker {
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
22
28
|
padding: 0;
|
|
23
29
|
|
|
24
30
|
cursor: pointer;
|
|
@@ -41,14 +47,14 @@
|
|
|
41
47
|
will-change: opacity;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
.
|
|
50
|
+
.marker svg {
|
|
45
51
|
display: block;
|
|
46
52
|
|
|
47
53
|
will-change: opacity;
|
|
48
54
|
}
|
|
49
55
|
|
|
50
|
-
.
|
|
51
|
-
.
|
|
56
|
+
.marker:hover,
|
|
57
|
+
.marker.isActive {
|
|
52
58
|
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 1);
|
|
53
59
|
}
|
|
54
60
|
|
|
@@ -17,6 +17,7 @@ import styles from './DotsOnImage.module.css'
|
|
|
17
17
|
export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
18
18
|
block: { optimized, width, height, credit, display, dots }
|
|
19
19
|
}) => {
|
|
20
|
+
const [ratio, setRatio] = useState(1)
|
|
20
21
|
const [ref, inView, entry] = useInView({
|
|
21
22
|
threshold: 0.5
|
|
22
23
|
})
|
|
@@ -31,6 +32,7 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
31
32
|
})
|
|
32
33
|
|
|
33
34
|
const [visible, setVisible] = useState(false)
|
|
35
|
+
const defaultWidth = 375
|
|
34
36
|
|
|
35
37
|
useEffect(() => {
|
|
36
38
|
if (entry && entry.boundingClientRect && entry.boundingClientRect.y < 0) {
|
|
@@ -54,6 +56,24 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
54
56
|
return () => document.removeEventListener('click', handleClickOutside)
|
|
55
57
|
}, [popover])
|
|
56
58
|
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setDotSize()
|
|
61
|
+
window.addEventListener('resize', setDotSize)
|
|
62
|
+
|
|
63
|
+
return () => document.removeEventListener('resize', setDotSize)
|
|
64
|
+
}, [visible])
|
|
65
|
+
|
|
66
|
+
const setDotSize = () => {
|
|
67
|
+
const width = window.innerWidth
|
|
68
|
+
|
|
69
|
+
if (width < defaultWidth) {
|
|
70
|
+
const ratio = width / defaultWidth
|
|
71
|
+
setRatio(ratio)
|
|
72
|
+
} else {
|
|
73
|
+
setRatio(1)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
57
77
|
const handleClickOutside = (event: MouseEvent): void => {
|
|
58
78
|
const path = event.composedPath()
|
|
59
79
|
|
|
@@ -100,25 +120,36 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
100
120
|
|
|
101
121
|
<div ref={container}>
|
|
102
122
|
{dots.map((dot) => (
|
|
103
|
-
<
|
|
104
|
-
className={
|
|
105
|
-
[styles.dot, true],
|
|
106
|
-
[styles.isActive, dot.id === popover.id]
|
|
107
|
-
])}
|
|
108
|
-
type="button"
|
|
123
|
+
<div
|
|
124
|
+
className={styles.dot}
|
|
109
125
|
key={dot.id}
|
|
110
126
|
style={{
|
|
111
127
|
top: `${dot.position.y}%`,
|
|
112
128
|
left: `${dot.position.x}%`,
|
|
113
|
-
|
|
129
|
+
transform: `scale(${ratio}) translate(-${50 / ratio}%, -${
|
|
130
|
+
50 / ratio
|
|
131
|
+
}%)`
|
|
114
132
|
}}
|
|
115
|
-
onClick={(): void => handleDotClick(dot)}
|
|
116
133
|
>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
134
|
+
<button
|
|
135
|
+
className={makeClassName([
|
|
136
|
+
[styles.marker, true],
|
|
137
|
+
[styles.isActive, dot.id === popover.id]
|
|
138
|
+
])}
|
|
139
|
+
type="button"
|
|
140
|
+
style={{
|
|
141
|
+
backgroundColor: dot.icon.color
|
|
142
|
+
}}
|
|
143
|
+
onClick={(): void => handleDotClick(dot)}
|
|
144
|
+
>
|
|
145
|
+
{dot.icon.type === 'svg' && (
|
|
146
|
+
<div
|
|
147
|
+
dangerouslySetInnerHTML={{ __html: dot.icon.svg_string }}
|
|
148
|
+
/>
|
|
149
|
+
)}
|
|
150
|
+
{dot.icon.type === 'number' && dot.icon.number}
|
|
151
|
+
</button>
|
|
152
|
+
</div>
|
|
122
153
|
))}
|
|
123
154
|
|
|
124
155
|
{popover.show && (
|