@meduza/ui-kit-2 0.1.12 → 0.1.14
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 +66 -22
- 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 +67 -23
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +848 -831
- package/package.json +1 -1
- package/src/DocumentItemsCount/DocumentItemsCount.stories.tsx +4 -6
- package/src/DotsOnImage/DotsOnImage.module.css +37 -43
- package/src/DotsOnImage/index.tsx +92 -42
- package/src/EmbedBlock/EmbedBlock.tsx +1 -1
- package/src/QuoteBlock/QuoteBlock.module.css +1 -1
package/package.json
CHANGED
|
@@ -16,12 +16,10 @@ const Example: React.FC = () => {
|
|
|
16
16
|
return (
|
|
17
17
|
<>
|
|
18
18
|
<div className={styles.root}>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<
|
|
23
|
-
<DocumentItemsCount type="podcast" items={4} />
|
|
24
|
-
</p>
|
|
19
|
+
<DocumentItemsCount type="card" items={4} />
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
<DocumentItemsCount type="podcast" items={4} />
|
|
25
23
|
</div>
|
|
26
24
|
</>
|
|
27
25
|
)
|
|
@@ -4,6 +4,12 @@
|
|
|
4
4
|
position: relative;
|
|
5
5
|
|
|
6
6
|
display: block;
|
|
7
|
+
|
|
8
|
+
width: 100%;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.isVisible .dot {
|
|
12
|
+
animation: show 400ms ease both 500ms;
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
.dot {
|
|
@@ -15,20 +21,23 @@
|
|
|
15
21
|
margin: 0;
|
|
16
22
|
padding: 0;
|
|
17
23
|
|
|
18
|
-
|
|
24
|
+
color: #fff;
|
|
25
|
+
font-weight: 600;
|
|
26
|
+
font-size: 13px;
|
|
27
|
+
|
|
28
|
+
font-family: $secondaryFont;
|
|
29
|
+
line-height: 28px;
|
|
19
30
|
text-align: center;
|
|
20
31
|
|
|
21
|
-
color: #
|
|
32
|
+
background-color: #000;
|
|
22
33
|
border-width: 0;
|
|
23
34
|
border-radius: 30px;
|
|
24
35
|
outline-width: 0;
|
|
25
|
-
|
|
26
|
-
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
|
|
36
|
+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
|
|
27
37
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
line-height: 28px;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
|
|
40
|
+
opacity: 0;
|
|
32
41
|
|
|
33
42
|
appearance: none;
|
|
34
43
|
will-change: opacity;
|
|
@@ -40,6 +49,11 @@
|
|
|
40
49
|
will-change: opacity;
|
|
41
50
|
}
|
|
42
51
|
|
|
52
|
+
.dot:hover,
|
|
53
|
+
.dot.isActive {
|
|
54
|
+
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 1);
|
|
55
|
+
}
|
|
56
|
+
|
|
43
57
|
.popover {
|
|
44
58
|
position: absolute;
|
|
45
59
|
z-index: 10;
|
|
@@ -58,46 +72,26 @@
|
|
|
58
72
|
}
|
|
59
73
|
|
|
60
74
|
.popover.isLeft.isBottom {
|
|
61
|
-
transform: translateX(-100%) translateX(-22px) translateY(-100%)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
.popoverTitle {
|
|
65
|
-
margin-bottom: 16px;
|
|
66
|
-
|
|
67
|
-
font-weight: 600;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.popoverBody {
|
|
71
|
-
font-family: $secondaryFont;
|
|
72
|
-
font-size: 16px;
|
|
73
|
-
line-height: 22px;
|
|
75
|
+
transform: translateX(-100%) translateX(-22px) translateY(-100%)
|
|
76
|
+
translateY(22px);
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
@keyframes show {
|
|
80
|
+
0% {
|
|
81
|
+
transform: scale(0.4);
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
+
opacity: 0;
|
|
84
|
+
}
|
|
83
85
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
top: 0;
|
|
87
|
-
right: 0;
|
|
86
|
+
90% {
|
|
87
|
+
transform: scale(1.1);
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
opacity: 1;
|
|
90
|
+
}
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
color: #b3b3b3;
|
|
95
|
-
border-width: 0;
|
|
96
|
-
outline: none;
|
|
97
|
-
background-color: transparent;
|
|
98
|
-
}
|
|
92
|
+
100% {
|
|
93
|
+
transform: scale(1);
|
|
99
94
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
height: 10px;
|
|
95
|
+
opacity: 1;
|
|
96
|
+
}
|
|
103
97
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react'
|
|
2
|
+
import { useInView } from 'react-intersection-observer'
|
|
3
|
+
|
|
2
4
|
import { PopoverData, DotsOnImageProps, SingleDot } from './DotsOnImage.types'
|
|
5
|
+
|
|
3
6
|
import { Image } from '../Image'
|
|
4
7
|
import { Popover } from '../Popover'
|
|
5
8
|
import { Footnote } from '../Footnote'
|
|
@@ -14,6 +17,12 @@ import styles from './DotsOnImage.module.css'
|
|
|
14
17
|
export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
15
18
|
block: { optimized, width, height, credit, display, dots }
|
|
16
19
|
}) => {
|
|
20
|
+
const [ref, inView, entry] = useInView({
|
|
21
|
+
threshold: 0.5
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const container = useRef(null)
|
|
25
|
+
|
|
17
26
|
const [popover, setPopover] = useState<PopoverData>({
|
|
18
27
|
title: null,
|
|
19
28
|
body: null,
|
|
@@ -21,6 +30,38 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
21
30
|
id: null
|
|
22
31
|
})
|
|
23
32
|
|
|
33
|
+
const [visible, setVisible] = useState(false)
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (entry && entry.boundingClientRect && entry.boundingClientRect.y < 0) {
|
|
37
|
+
setVisible(true)
|
|
38
|
+
}
|
|
39
|
+
}, [entry])
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (inView) {
|
|
43
|
+
setVisible(true)
|
|
44
|
+
}
|
|
45
|
+
}, [inView])
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (popover.id) {
|
|
49
|
+
document.addEventListener('click', handleClickOutside)
|
|
50
|
+
} else {
|
|
51
|
+
document.removeEventListener('click', handleClickOutside)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return () => document.removeEventListener('click', handleClickOutside)
|
|
55
|
+
}, [popover])
|
|
56
|
+
|
|
57
|
+
const handleClickOutside = (event: MouseEvent): void => {
|
|
58
|
+
const path = event.composedPath()
|
|
59
|
+
|
|
60
|
+
if (path.indexOf(container.current) === -1) {
|
|
61
|
+
setPopover({ show: false })
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
24
65
|
const handleDotClick = (dot: SingleDot): void => {
|
|
25
66
|
const shouldShow = dot.id !== popover.id
|
|
26
67
|
const side = dot.position.x > 50 ? 'isLeft' : 'isRight'
|
|
@@ -40,11 +81,30 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
40
81
|
}
|
|
41
82
|
|
|
42
83
|
return (
|
|
43
|
-
<div
|
|
44
|
-
|
|
84
|
+
<div
|
|
85
|
+
className={makeClassName([
|
|
86
|
+
[styles.root, true],
|
|
87
|
+
[styles.isVisible, visible]
|
|
88
|
+
])}
|
|
89
|
+
data-testid="dots-on-image"
|
|
90
|
+
ref={ref}
|
|
91
|
+
>
|
|
92
|
+
<Image
|
|
93
|
+
optimized={optimized}
|
|
94
|
+
width={width}
|
|
95
|
+
height={height}
|
|
96
|
+
alt={credit}
|
|
97
|
+
display={display}
|
|
98
|
+
fullscreen={{ mobile: false, desktop: false }}
|
|
99
|
+
/>
|
|
100
|
+
|
|
101
|
+
<div ref={container}>
|
|
45
102
|
{dots.map((dot) => (
|
|
46
103
|
<button
|
|
47
|
-
className={
|
|
104
|
+
className={makeClassName([
|
|
105
|
+
[styles.dot, true],
|
|
106
|
+
[styles.isActive, dot.id === popover.id]
|
|
107
|
+
])}
|
|
48
108
|
type="button"
|
|
49
109
|
key={dot.id}
|
|
50
110
|
style={{
|
|
@@ -60,50 +120,40 @@ export const DotsOnImage: React.FC<DotsOnImageProps> = ({
|
|
|
60
120
|
{dot.icon.type === 'number' && dot.icon.number}
|
|
61
121
|
</button>
|
|
62
122
|
))}
|
|
63
|
-
</div>
|
|
64
|
-
<div className={styles.image}>
|
|
65
|
-
<Image
|
|
66
|
-
optimized={optimized}
|
|
67
|
-
width={width}
|
|
68
|
-
height={height}
|
|
69
|
-
alt={credit}
|
|
70
|
-
display={display}
|
|
71
|
-
fullscreen={{ mobile: false, desktop: false }}
|
|
72
|
-
/>
|
|
73
|
-
</div>
|
|
74
123
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
124
|
+
{popover.show && (
|
|
125
|
+
<>
|
|
126
|
+
{viewportSize().width >= MediaQuerySizes.LANDSCAPE_TABLET ? (
|
|
127
|
+
<div
|
|
128
|
+
className={makeClassName([
|
|
129
|
+
[styles.popover, true],
|
|
130
|
+
[styles[popover.side], !!popover.side],
|
|
131
|
+
[styles[popover.align], !!popover.align]
|
|
132
|
+
])}
|
|
133
|
+
style={popover.style}
|
|
134
|
+
>
|
|
135
|
+
<Footnote
|
|
136
|
+
onClose={(): void => {
|
|
137
|
+
setPopover({ show: false })
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
140
|
+
{popover.title && <h3>{popover.title}</h3>}
|
|
141
|
+
<div dangerouslySetInnerHTML={{ __html: popover.body }} />
|
|
142
|
+
</Footnote>
|
|
143
|
+
</div>
|
|
144
|
+
) : (
|
|
145
|
+
<Popover
|
|
87
146
|
onClose={(): void => {
|
|
88
147
|
setPopover({ show: false })
|
|
89
148
|
}}
|
|
90
149
|
>
|
|
91
|
-
<h3>{popover.title}</h3>
|
|
150
|
+
{popover.title && <h3>{popover.title}</h3>}
|
|
92
151
|
<div dangerouslySetInnerHTML={{ __html: popover.body }} />
|
|
93
|
-
</
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
setPopover({ show: false })
|
|
99
|
-
}}
|
|
100
|
-
>
|
|
101
|
-
<h3>{popover.title}</h3>
|
|
102
|
-
<div dangerouslySetInnerHTML={{ __html: popover.body }} />
|
|
103
|
-
</Popover>
|
|
104
|
-
)}
|
|
105
|
-
</>
|
|
106
|
-
)}
|
|
152
|
+
</Popover>
|
|
153
|
+
)}
|
|
154
|
+
</>
|
|
155
|
+
)}
|
|
156
|
+
</div>
|
|
107
157
|
</div>
|
|
108
158
|
)
|
|
109
159
|
}
|
|
@@ -44,7 +44,7 @@ export const EmbedBlock: React.FC<EmbedBlockProps> = ({
|
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
const mobileFullwidth =
|
|
47
|
-
fullWidthProviders.indexOf(provider) || block.type === 'dots_on_image'
|
|
47
|
+
fullWidthProviders.indexOf(provider) > -1 || block.type === 'dots_on_image'
|
|
48
48
|
|
|
49
49
|
const renderCC = (context?: string | string[]): JSX.Element => (
|
|
50
50
|
<MediaCaption
|