@meduza/ui-kit-2 1.4.2 → 1.4.4
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 +29 -39
- 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 +29 -39
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit-game.css +20 -25
- package/dist/ui-kit.css +20 -25
- package/package.json +4 -1
- package/src/RelatedBlock/RelatedBlock.module.css +1 -1
- package/src/RelatedCarousel/RelatedCarousel.module.css +10 -19
- package/src/RelatedCarousel/RelatedCarousel.test.tsx +7 -3
- package/src/RelatedCarousel/index.tsx +33 -50
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +1 -1
- package/src/RichTitle/RichTitle.module.css +5 -4
package/dist/ui-kit-game.css
CHANGED
|
@@ -3242,14 +3242,18 @@
|
|
|
3242
3242
|
}
|
|
3243
3243
|
|
|
3244
3244
|
.RichTitle-module_isInMediaBlock__2h6rl:not(.RichTitle-module_featured__ULNQn) span {
|
|
3245
|
-
display: block;
|
|
3246
|
-
|
|
3247
|
-
margin-top: 4px;
|
|
3248
|
-
|
|
3249
3245
|
font-size: 18px;
|
|
3250
3246
|
line-height: 132%;
|
|
3251
3247
|
}
|
|
3252
3248
|
|
|
3249
|
+
@media only screen and (max-width: 40.5625em) {
|
|
3250
|
+
|
|
3251
|
+
.RichTitle-module_isInMediaBlock__2h6rl:not(.RichTitle-module_featured__ULNQn) span {
|
|
3252
|
+
display: block;
|
|
3253
|
+
margin-top: 4px;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3253
3257
|
.RichTitle-module_isInBookRelated__LcCPV {
|
|
3254
3258
|
margin: 6px 0 20px;
|
|
3255
3259
|
}
|
|
@@ -4086,7 +4090,7 @@ a mark {
|
|
|
4086
4090
|
|
|
4087
4091
|
border-radius: 8px;
|
|
4088
4092
|
background-color: #f5f5f5;
|
|
4089
|
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0
|
|
4093
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 2px 0 0 #b88b58;
|
|
4090
4094
|
}
|
|
4091
4095
|
|
|
4092
4096
|
@media only screen and (min-width: 40.625em) {
|
|
@@ -6033,7 +6037,7 @@ ul.VersesBlock-module_root__CrgSZ:first-child {
|
|
|
6033
6037
|
|
|
6034
6038
|
background-color: #f7f7f7;
|
|
6035
6039
|
|
|
6036
|
-
border-top: 2px solid #
|
|
6040
|
+
border-top: 2px solid #b88b58;
|
|
6037
6041
|
|
|
6038
6042
|
outline-width: 0;
|
|
6039
6043
|
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.1);
|
|
@@ -6728,39 +6732,30 @@ ul.VersesBlock-module_root__CrgSZ:first-child {
|
|
|
6728
6732
|
position: relative;
|
|
6729
6733
|
}
|
|
6730
6734
|
|
|
6731
|
-
.RelatedCarousel-
|
|
6732
|
-
display: flex;
|
|
6733
|
-
gap: 20px;
|
|
6734
|
-
|
|
6735
|
+
.RelatedCarousel-module_viewport__HCzJi {
|
|
6735
6736
|
margin: 0 -20px;
|
|
6736
6737
|
padding: 0 20px;
|
|
6737
6738
|
|
|
6738
|
-
overflow
|
|
6739
|
-
|
|
6740
|
-
list-style: none;
|
|
6741
|
-
overscroll-behavior-x: contain;
|
|
6739
|
+
overflow: hidden;
|
|
6740
|
+
}
|
|
6742
6741
|
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
-webkit-overflow-scrolling: touch;
|
|
6742
|
+
.RelatedCarousel-module_track__UVQ2n {
|
|
6743
|
+
--slideGap: 20px;
|
|
6746
6744
|
|
|
6747
|
-
|
|
6748
|
-
}
|
|
6745
|
+
display: flex;
|
|
6749
6746
|
|
|
6750
|
-
|
|
6751
|
-
display: none;
|
|
6747
|
+
touch-action: pan-y pinch-zoom;
|
|
6752
6748
|
}
|
|
6753
6749
|
|
|
6754
6750
|
.RelatedCarousel-module_slide__MI9tF {
|
|
6755
6751
|
position: relative;
|
|
6756
6752
|
|
|
6757
|
-
|
|
6753
|
+
box-sizing: border-box;
|
|
6754
|
+
flex: 0 0 calc(85% + var(--slideGap));
|
|
6758
6755
|
min-width: 0;
|
|
6756
|
+
padding-right: var(--slideGap);
|
|
6759
6757
|
|
|
6760
6758
|
overflow: hidden;
|
|
6761
|
-
|
|
6762
|
-
scroll-snap-align: start;
|
|
6763
|
-
scroll-snap-stop: always;
|
|
6764
6759
|
}
|
|
6765
6760
|
|
|
6766
6761
|
.RelatedCarousel-module_dots__mOSIC {
|
package/dist/ui-kit.css
CHANGED
|
@@ -3242,14 +3242,18 @@
|
|
|
3242
3242
|
}
|
|
3243
3243
|
|
|
3244
3244
|
.RichTitle-module_isInMediaBlock__2h6rl:not(.RichTitle-module_featured__ULNQn) span {
|
|
3245
|
-
display: block;
|
|
3246
|
-
|
|
3247
|
-
margin-top: 4px;
|
|
3248
|
-
|
|
3249
3245
|
font-size: 18px;
|
|
3250
3246
|
line-height: 132%;
|
|
3251
3247
|
}
|
|
3252
3248
|
|
|
3249
|
+
@media only screen and (max-width: 63.9375em) {
|
|
3250
|
+
|
|
3251
|
+
.RichTitle-module_isInMediaBlock__2h6rl:not(.RichTitle-module_featured__ULNQn) span {
|
|
3252
|
+
display: block;
|
|
3253
|
+
margin-top: 4px;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
|
|
3253
3257
|
.RichTitle-module_isInBookRelated__LcCPV {
|
|
3254
3258
|
margin: 6px 0 20px;
|
|
3255
3259
|
}
|
|
@@ -4086,7 +4090,7 @@ a mark {
|
|
|
4086
4090
|
|
|
4087
4091
|
border-radius: 8px;
|
|
4088
4092
|
background-color: #f5f5f5;
|
|
4089
|
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0
|
|
4093
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), inset 0 2px 0 0 #b88b58;
|
|
4090
4094
|
}
|
|
4091
4095
|
|
|
4092
4096
|
@media only screen and (min-width: 48em) {
|
|
@@ -6033,7 +6037,7 @@ ul.VersesBlock-module_root__CrgSZ:first-child {
|
|
|
6033
6037
|
|
|
6034
6038
|
background-color: #f7f7f7;
|
|
6035
6039
|
|
|
6036
|
-
border-top: 2px solid #
|
|
6040
|
+
border-top: 2px solid #b88b58;
|
|
6037
6041
|
|
|
6038
6042
|
outline-width: 0;
|
|
6039
6043
|
box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.1);
|
|
@@ -6728,39 +6732,30 @@ ul.VersesBlock-module_root__CrgSZ:first-child {
|
|
|
6728
6732
|
position: relative;
|
|
6729
6733
|
}
|
|
6730
6734
|
|
|
6731
|
-
.RelatedCarousel-
|
|
6732
|
-
display: flex;
|
|
6733
|
-
gap: 20px;
|
|
6734
|
-
|
|
6735
|
+
.RelatedCarousel-module_viewport__HCzJi {
|
|
6735
6736
|
margin: 0 -20px;
|
|
6736
6737
|
padding: 0 20px;
|
|
6737
6738
|
|
|
6738
|
-
overflow
|
|
6739
|
-
|
|
6740
|
-
list-style: none;
|
|
6741
|
-
overscroll-behavior-x: contain;
|
|
6739
|
+
overflow: hidden;
|
|
6740
|
+
}
|
|
6742
6741
|
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
-webkit-overflow-scrolling: touch;
|
|
6742
|
+
.RelatedCarousel-module_track__UVQ2n {
|
|
6743
|
+
--slideGap: 20px;
|
|
6746
6744
|
|
|
6747
|
-
|
|
6748
|
-
}
|
|
6745
|
+
display: flex;
|
|
6749
6746
|
|
|
6750
|
-
|
|
6751
|
-
display: none;
|
|
6747
|
+
touch-action: pan-y pinch-zoom;
|
|
6752
6748
|
}
|
|
6753
6749
|
|
|
6754
6750
|
.RelatedCarousel-module_slide__MI9tF {
|
|
6755
6751
|
position: relative;
|
|
6756
6752
|
|
|
6757
|
-
|
|
6753
|
+
box-sizing: border-box;
|
|
6754
|
+
flex: 0 0 calc(85% + var(--slideGap));
|
|
6758
6755
|
min-width: 0;
|
|
6756
|
+
padding-right: var(--slideGap);
|
|
6759
6757
|
|
|
6760
6758
|
overflow: hidden;
|
|
6761
|
-
|
|
6762
|
-
scroll-snap-align: start;
|
|
6763
|
-
scroll-snap-stop: always;
|
|
6764
6759
|
}
|
|
6765
6760
|
|
|
6766
6761
|
.RelatedCarousel-module_dots__mOSIC {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.4",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"description": "UIKit for Meduza",
|
|
5
5
|
"repository": "https://github.com/meduza-corp/ui-kit-2.git",
|
|
@@ -125,5 +125,8 @@
|
|
|
125
125
|
"typescript": "^5.1.6",
|
|
126
126
|
"typescript-plugin-css-modules": "^5.0.1",
|
|
127
127
|
"utils": "^0.3.1"
|
|
128
|
+
},
|
|
129
|
+
"dependencies": {
|
|
130
|
+
"embla-carousel-react": "^8.6.0"
|
|
128
131
|
}
|
|
129
132
|
}
|
|
@@ -2,39 +2,30 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
.
|
|
6
|
-
display: flex;
|
|
7
|
-
gap: 20px;
|
|
8
|
-
|
|
5
|
+
.viewport {
|
|
9
6
|
margin: 0 -20px;
|
|
10
7
|
padding: 0 20px;
|
|
11
8
|
|
|
12
|
-
overflow
|
|
13
|
-
|
|
14
|
-
list-style: none;
|
|
15
|
-
overscroll-behavior-x: contain;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
}
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-webkit-overflow-scrolling: touch;
|
|
12
|
+
.track {
|
|
13
|
+
--slideGap: 20px;
|
|
20
14
|
|
|
21
|
-
|
|
22
|
-
}
|
|
15
|
+
display: flex;
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
display: none;
|
|
17
|
+
touch-action: pan-y pinch-zoom;
|
|
26
18
|
}
|
|
27
19
|
|
|
28
20
|
.slide {
|
|
29
21
|
position: relative;
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
flex: 0 0 calc(85% + var(--slideGap));
|
|
32
25
|
min-width: 0;
|
|
26
|
+
padding-right: var(--slideGap);
|
|
33
27
|
|
|
34
28
|
overflow: hidden;
|
|
35
|
-
|
|
36
|
-
scroll-snap-align: start;
|
|
37
|
-
scroll-snap-stop: always;
|
|
38
29
|
}
|
|
39
30
|
|
|
40
31
|
.dots {
|
|
@@ -19,9 +19,13 @@ describe('Related Carousel', () => {
|
|
|
19
19
|
expect(getByTestId('related-carousel')).toHaveClass(styles.root)
|
|
20
20
|
})
|
|
21
21
|
|
|
22
|
-
it('should render a dot per
|
|
23
|
-
const {
|
|
22
|
+
it('should render a slide and a dot per child', () => {
|
|
23
|
+
const { getByTestId, getByText } = renderComponent()
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
const carousel = getByTestId('related-carousel')
|
|
26
|
+
|
|
27
|
+
expect(getByText('Первая')).toBeInTheDocument()
|
|
28
|
+
expect(carousel.querySelectorAll(`.${styles.slide}`)).toHaveLength(2)
|
|
29
|
+
expect(carousel.querySelectorAll(`.${styles.dot}`)).toHaveLength(2)
|
|
26
30
|
})
|
|
27
31
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react'
|
|
2
|
+
import useEmblaCarousel from 'embla-carousel-react'
|
|
2
3
|
|
|
3
4
|
import { RelatedCarouselProps } from './RelatedCarousel.types'
|
|
4
5
|
import makeClassName from '../utils/makeClassName'
|
|
@@ -60,67 +61,47 @@ const getDotScale = (
|
|
|
60
61
|
return 'full'
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
const getSlideStep = (track: HTMLElement | null): number => {
|
|
64
|
-
if (!track) {
|
|
65
|
-
return 0
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const [first, second] = Array.from(track.children) as HTMLElement[]
|
|
69
|
-
|
|
70
|
-
if (!first) {
|
|
71
|
-
return 0
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return second ? second.offsetLeft - first.offsetLeft : first.offsetWidth
|
|
75
|
-
}
|
|
76
|
-
|
|
77
64
|
export const RelatedCarousel: React.FC<RelatedCarouselProps> = ({
|
|
78
65
|
children,
|
|
79
66
|
ariaLabel
|
|
80
67
|
}) => {
|
|
81
|
-
const
|
|
82
|
-
|
|
68
|
+
const [viewportRef, embla] = useEmblaCarousel({
|
|
69
|
+
loop: true,
|
|
70
|
+
align: 'start',
|
|
71
|
+
containScroll: false
|
|
72
|
+
})
|
|
73
|
+
|
|
83
74
|
const [activeIndex, setActiveIndex] = useState(0)
|
|
84
75
|
const [dotsStart, setDotsStart] = useState(0)
|
|
85
76
|
|
|
86
77
|
const slides = React.Children.toArray(children)
|
|
87
|
-
const lastIndex = slides.length - 1
|
|
88
78
|
const total = slides.length
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
if (!track) {
|
|
94
|
-
return undefined
|
|
80
|
+
const handleSelect = useCallback(() => {
|
|
81
|
+
if (!embla) {
|
|
82
|
+
return
|
|
95
83
|
}
|
|
96
84
|
|
|
97
|
-
const
|
|
98
|
-
cancelAnimationFrame(frameRef.current)
|
|
99
|
-
|
|
100
|
-
frameRef.current = requestAnimationFrame(() => {
|
|
101
|
-
const step = getSlideStep(track)
|
|
102
|
-
|
|
103
|
-
if (!step) {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
85
|
+
const index = embla.selectedScrollSnap()
|
|
106
86
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
)
|
|
87
|
+
setActiveIndex(index)
|
|
88
|
+
setDotsStart((start) => getDotsStart(index, start, total))
|
|
89
|
+
}, [embla, total])
|
|
111
90
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!embla) {
|
|
93
|
+
return undefined
|
|
115
94
|
}
|
|
116
95
|
|
|
117
|
-
|
|
96
|
+
handleSelect()
|
|
97
|
+
embla.on('select', handleSelect)
|
|
98
|
+
embla.on('reInit', handleSelect)
|
|
118
99
|
|
|
119
100
|
return () => {
|
|
120
|
-
|
|
121
|
-
|
|
101
|
+
embla.off('select', handleSelect)
|
|
102
|
+
embla.off('reInit', handleSelect)
|
|
122
103
|
}
|
|
123
|
-
}, [
|
|
104
|
+
}, [embla, handleSelect])
|
|
124
105
|
|
|
125
106
|
const dotsStyle: DotsStyle = {
|
|
126
107
|
'--dotsVisible': Math.min(total, VISIBLE_DOTS),
|
|
@@ -134,13 +115,15 @@ export const RelatedCarousel: React.FC<RelatedCarouselProps> = ({
|
|
|
134
115
|
role="group"
|
|
135
116
|
aria-label={ariaLabel}
|
|
136
117
|
>
|
|
137
|
-
<
|
|
138
|
-
{
|
|
139
|
-
|
|
140
|
-
{slide}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
118
|
+
<div className={styles.viewport} ref={viewportRef}>
|
|
119
|
+
<div className={styles.track}>
|
|
120
|
+
{slides.map((slide, index) => (
|
|
121
|
+
<div className={styles.slide} key={index}>
|
|
122
|
+
{slide}
|
|
123
|
+
</div>
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
144
127
|
<div aria-hidden="true" className={styles.dots} style={dotsStyle}>
|
|
145
128
|
<div className={styles.dotsTrack}>
|
|
146
129
|
{slides.map((_slide, index) => {
|
|
@@ -110,12 +110,13 @@
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
.isInMediaBlock:not(.featured) span {
|
|
113
|
-
display: block;
|
|
114
|
-
|
|
115
|
-
margin-top: 4px;
|
|
116
|
-
|
|
117
113
|
font-size: 18px;
|
|
118
114
|
line-height: 132%;
|
|
115
|
+
|
|
116
|
+
@media $landscapeTabletMax {
|
|
117
|
+
display: block;
|
|
118
|
+
margin-top: 4px;
|
|
119
|
+
}
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
.isInBookRelated {
|