@meduza/ui-kit-2 1.3.1 → 1.4.1
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/RelatedCarousel/RelatedCarousel.types.d.ts +5 -0
- package/dist/RelatedCarousel/index.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/ui-kit-2.cjs.development.js +348 -276
- 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 +348 -277
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit-game.css +175 -258
- package/dist/ui-kit.css +175 -258
- package/package.json +1 -1
- package/src/Image/Image.module.css +16 -7
- package/src/Lazy/index.tsx +7 -20
- package/src/Meta/Meta.module.css +4 -0
- package/src/RelatedCarousel/RelatedCarousel.module.css +118 -0
- package/src/RelatedCarousel/RelatedCarousel.stories.module.css +53 -0
- package/src/RelatedCarousel/RelatedCarousel.stories.tsx +48 -0
- package/src/RelatedCarousel/RelatedCarousel.test.tsx +27 -0
- package/src/RelatedCarousel/RelatedCarousel.types.ts +6 -0
- package/src/RelatedCarousel/index.tsx +167 -0
- package/src/RelatedCarousel/mock.json +17 -0
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +28 -201
- package/src/RelatedRichBlock/index.tsx +11 -64
- package/src/RichTitle/RichTitle.module.css +8 -12
- package/src/Tag/Tag.module.css +0 -1
- package/src/index.tsx +1 -0
|
@@ -1,59 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
import React, { useEffect } from 'react'
|
|
1
|
+
import React from 'react'
|
|
3
2
|
import { Link } from 'react-router-dom'
|
|
4
3
|
|
|
5
|
-
import { useInView } from 'react-intersection-observer'
|
|
6
4
|
import { RelatedRichBlockProps } from './RelatedRichBlock.types'
|
|
7
5
|
|
|
8
|
-
import postMessage from '../utils/postMessage'
|
|
9
6
|
import { makeClassName, ClassNames } from '../utils/makeClassName'
|
|
10
7
|
import makeStyleContext from '../utils/makeStyleContext'
|
|
11
|
-
import generateGradient from '../utils/generateGradient'
|
|
12
8
|
import { toCapitalize } from '../utils/converCase'
|
|
13
9
|
|
|
14
10
|
import { Tag } from '../Tag'
|
|
15
|
-
import { RenderBlocks } from '../RenderBlocks'
|
|
16
11
|
import { Image } from '../Image'
|
|
17
12
|
|
|
18
13
|
import styles from './RelatedRichBlock.module.css'
|
|
14
|
+
import { RenderBlocks } from '../RenderBlocks'
|
|
19
15
|
|
|
20
16
|
export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
|
|
21
17
|
block: {
|
|
22
18
|
only_on: onlyOn,
|
|
23
19
|
data: {
|
|
24
|
-
blocks,
|
|
25
20
|
url,
|
|
21
|
+
blocks,
|
|
26
22
|
cover: { urls, gradients, tag, layout, ratio }
|
|
27
23
|
}
|
|
28
24
|
},
|
|
29
25
|
styleContext
|
|
30
26
|
}) => {
|
|
31
|
-
const style: React.CSSProperties = {}
|
|
32
|
-
const styleHeader: React.CSSProperties = {}
|
|
33
|
-
|
|
34
27
|
const cardType = `is${toCapitalize(layout)}`
|
|
35
28
|
|
|
36
|
-
const [ref, inView] = useInView({
|
|
37
|
-
threshold: 0,
|
|
38
|
-
triggerOnce: true
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
if (inView) {
|
|
43
|
-
if (
|
|
44
|
-
(onlyOn === 'mobile' && window.innerWidth <= 511) ||
|
|
45
|
-
(onlyOn === 'desktop' && window.innerWidth >= 512) ||
|
|
46
|
-
!onlyOn
|
|
47
|
-
) {
|
|
48
|
-
postMessage('richRelated', url, 'view')
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, [inView])
|
|
52
|
-
|
|
53
|
-
const handleClick = () => {
|
|
54
|
-
postMessage('richRelated', url, 'click')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
29
|
let classNames: ClassNames = [
|
|
58
30
|
[styles.root, true],
|
|
59
31
|
[styles[cardType], !!layout && !!styles[cardType]],
|
|
@@ -69,52 +41,27 @@ export const RelatedRichBlock: React.FC<RelatedRichBlockProps> = ({
|
|
|
69
41
|
context = [...styleContext, 'isInMediaBlock']
|
|
70
42
|
}
|
|
71
43
|
|
|
72
|
-
if (gradients) {
|
|
73
|
-
styleHeader.backgroundImage = generateGradient(
|
|
74
|
-
gradients.bg_rgb,
|
|
75
|
-
'mediaBlockTop'
|
|
76
|
-
)
|
|
77
|
-
|
|
78
|
-
const theme = [gradients.text_rgb === '0,0,0' ? 'dark' : 'light']
|
|
79
|
-
classNames = makeStyleContext(classNames, theme, styles)
|
|
80
|
-
|
|
81
|
-
if (onlyOn === 'desktop') {
|
|
82
|
-
style.backgroundImage = generateGradient(
|
|
83
|
-
gradients.bg_rgb,
|
|
84
|
-
'mediaBlockBottom'
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
44
|
return (
|
|
90
45
|
<Link
|
|
91
46
|
data-testid="related-rich-block"
|
|
92
47
|
className={makeClassName(classNames)}
|
|
93
48
|
to={`/${url}`}
|
|
94
|
-
onClick={(): void => handleClick()}
|
|
95
|
-
ref={ref}
|
|
96
49
|
>
|
|
97
|
-
{layout === 'rich' && (
|
|
98
|
-
<>
|
|
99
|
-
<div className={styles.overlay} style={style} />
|
|
100
|
-
<div className={styles.overlayHeader} style={styleHeader} />
|
|
101
|
-
</>
|
|
102
|
-
)}
|
|
103
|
-
|
|
104
50
|
<div className={styles.tag}>
|
|
105
51
|
<Tag size="small" theme="inherit" styleContext="richRelated">
|
|
106
52
|
{tag}
|
|
107
53
|
</Tag>
|
|
108
54
|
</div>
|
|
109
|
-
|
|
110
|
-
|
|
55
|
+
|
|
56
|
+
<div className={styles.content}>
|
|
57
|
+
<div className={styles.cover}>
|
|
111
58
|
<Image optimized={urls} ratio={ratio} display="narrow" />
|
|
112
59
|
</div>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
60
|
+
<div className={styles.body}>
|
|
61
|
+
{blocks.map((item) => (
|
|
62
|
+
<RenderBlocks key={item.id} block={item} styleContext={context} />
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
118
65
|
</div>
|
|
119
66
|
</Link>
|
|
120
67
|
)
|
|
@@ -100,26 +100,22 @@
|
|
|
100
100
|
text-align: left;
|
|
101
101
|
|
|
102
102
|
@media $landscapeTablet {
|
|
103
|
-
margin-bottom:
|
|
103
|
+
margin-bottom: 16px;
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
.isInMediaBlock:not(.featured) {
|
|
108
|
-
font-size:
|
|
109
|
-
line-height:
|
|
110
|
-
|
|
111
|
-
@media $landscapeTablet {
|
|
112
|
-
font-size: 1.3rem;
|
|
113
|
-
line-height: 1.6rem;
|
|
114
|
-
}
|
|
108
|
+
font-size: 20px;
|
|
109
|
+
line-height: 130%;
|
|
115
110
|
}
|
|
116
111
|
|
|
117
112
|
.isInMediaBlock:not(.featured) span {
|
|
118
|
-
|
|
113
|
+
display: block;
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
margin-top: 4px;
|
|
116
|
+
|
|
117
|
+
font-size: 18px;
|
|
118
|
+
line-height: 132%;
|
|
123
119
|
}
|
|
124
120
|
|
|
125
121
|
.isInBookRelated {
|
package/src/Tag/Tag.module.css
CHANGED
package/src/index.tsx
CHANGED
|
@@ -27,6 +27,7 @@ export * from './ImportantLead'
|
|
|
27
27
|
export * from './ListBlock'
|
|
28
28
|
export * from './ListViewSwitcher'
|
|
29
29
|
export * from './RelatedBlock'
|
|
30
|
+
export * from './RelatedCarousel'
|
|
30
31
|
export * from './RichTitle'
|
|
31
32
|
export * from './SimpleBlock'
|
|
32
33
|
export * from './SimpleTitle'
|