@alfalab/core-components-gallery 5.7.4 → 5.8.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.
- package/Component.js +47 -12
- package/components/buttons/index.css +35 -0
- package/{buttons-ec113bb4.d.ts → components/buttons/index.d.ts} +6 -1
- package/components/buttons/index.js +72 -0
- package/components/header/Component.js +33 -12
- package/components/header/index.css +5 -19
- package/components/header-info-block/Component.js +1 -1
- package/components/header-info-block/index.css +5 -5
- package/components/header-mobile/Component.d.ts +4 -0
- package/components/header-mobile/Component.js +39 -0
- package/components/header-mobile/index.css +50 -0
- package/components/header-mobile/index.d.ts +1 -0
- package/components/header-mobile/index.js +9 -0
- package/components/image-preview/Component.js +67 -24
- package/components/image-preview/index.css +35 -28
- package/components/image-preview/paths.d.ts +2 -0
- package/components/image-preview/paths.js +2 -0
- package/components/image-viewer/component.js +30 -10
- package/components/image-viewer/index.css +37 -25
- package/components/image-viewer/slide.js +3 -1
- package/components/image-viewer/video/index.css +48 -0
- package/components/image-viewer/video/index.d.ts +10 -0
- package/components/image-viewer/video/index.js +130 -0
- package/components/index.d.ts +2 -0
- package/components/index.js +4 -0
- package/components/info-bar/Component.d.ts +4 -0
- package/components/info-bar/Component.js +47 -0
- package/components/info-bar/index.css +37 -0
- package/components/info-bar/index.d.ts +1 -0
- package/components/info-bar/index.js +9 -0
- package/components/navigation-bar/Component.js +3 -2
- package/components/navigation-bar/index.css +8 -6
- package/context.d.ts +7 -0
- package/context.js +7 -0
- package/cssm/Component.js +46 -11
- package/cssm/components/{header/buttons.d.ts → buttons/index.d.ts} +6 -1
- package/cssm/components/buttons/index.js +71 -0
- package/cssm/components/buttons/index.module.css +34 -0
- package/cssm/components/header/Component.js +28 -10
- package/cssm/components/header/index.module.css +3 -17
- package/cssm/components/header-mobile/Component.d.ts +4 -0
- package/cssm/components/header-mobile/Component.js +38 -0
- package/cssm/components/header-mobile/index.d.ts +1 -0
- package/cssm/components/header-mobile/index.js +9 -0
- package/cssm/components/header-mobile/index.module.css +49 -0
- package/cssm/components/image-preview/Component.js +66 -27
- package/cssm/components/image-preview/index.module.css +25 -18
- package/cssm/components/image-preview/paths.d.ts +2 -0
- package/cssm/components/image-preview/paths.js +2 -0
- package/cssm/components/image-viewer/component.js +29 -9
- package/cssm/components/image-viewer/index.module.css +21 -9
- package/cssm/components/image-viewer/slide.js +12 -2
- package/cssm/components/image-viewer/video/index.d.ts +10 -0
- package/cssm/components/image-viewer/video/index.js +129 -0
- package/cssm/components/image-viewer/video/index.module.css +47 -0
- package/cssm/components/index.d.ts +2 -0
- package/cssm/components/index.js +4 -0
- package/cssm/components/info-bar/Component.d.ts +4 -0
- package/cssm/components/info-bar/Component.js +46 -0
- package/cssm/components/info-bar/index.d.ts +1 -0
- package/cssm/components/info-bar/index.js +9 -0
- package/cssm/components/info-bar/index.module.css +36 -0
- package/cssm/components/navigation-bar/Component.js +2 -1
- package/cssm/components/navigation-bar/index.module.css +3 -1
- package/cssm/context.d.ts +7 -0
- package/cssm/context.js +7 -0
- package/cssm/index.d.ts +1 -1
- package/cssm/index.js +1 -8
- package/cssm/index.module.css +14 -2
- package/cssm/types.d.ts +7 -0
- package/cssm/utils/constants.d.ts +14 -1
- package/cssm/utils/constants.js +19 -0
- package/cssm/utils/index.js +7 -0
- package/cssm/utils/utils.d.ts +2 -1
- package/cssm/utils/utils.js +5 -3
- package/esm/Component.js +46 -12
- package/esm/components/buttons/index.css +35 -0
- package/esm/{buttons-791da71e.d.ts → components/buttons/index.d.ts} +6 -1
- package/esm/components/buttons/index.js +55 -0
- package/esm/components/header/Component.js +30 -9
- package/esm/components/header/index.css +5 -19
- package/esm/components/header-info-block/Component.js +1 -1
- package/esm/components/header-info-block/index.css +5 -5
- package/esm/components/header-mobile/Component.d.ts +4 -0
- package/esm/components/header-mobile/Component.js +30 -0
- package/esm/components/header-mobile/index.css +50 -0
- package/esm/components/header-mobile/index.d.ts +1 -0
- package/esm/components/header-mobile/index.js +1 -0
- package/esm/components/image-preview/Component.js +69 -26
- package/esm/components/image-preview/index.css +35 -28
- package/esm/components/image-preview/paths.d.ts +2 -0
- package/esm/components/image-preview/paths.js +2 -0
- package/esm/components/image-viewer/component.js +31 -11
- package/esm/components/image-viewer/index.css +37 -25
- package/esm/components/image-viewer/slide.js +3 -1
- package/esm/components/image-viewer/video/index.css +48 -0
- package/esm/components/image-viewer/video/index.d.ts +10 -0
- package/esm/components/image-viewer/video/index.js +119 -0
- package/esm/components/index.d.ts +2 -0
- package/esm/components/index.js +2 -0
- package/esm/components/info-bar/Component.d.ts +4 -0
- package/esm/components/info-bar/Component.js +39 -0
- package/esm/components/info-bar/index.css +37 -0
- package/esm/components/info-bar/index.d.ts +1 -0
- package/esm/components/info-bar/index.js +1 -0
- package/esm/components/navigation-bar/Component.js +3 -2
- package/esm/components/navigation-bar/index.css +8 -6
- package/esm/context.d.ts +7 -0
- package/esm/context.js +7 -0
- package/esm/index.css +17 -5
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -3
- package/esm/{slide-7d5a41d1.js → slide-c469a906.js} +15 -5
- package/esm/types.d.ts +7 -0
- package/esm/utils/constants.d.ts +14 -1
- package/esm/utils/constants.js +14 -1
- package/esm/utils/index.js +2 -2
- package/esm/utils/utils.d.ts +2 -1
- package/esm/utils/utils.js +5 -4
- package/index.css +17 -5
- package/index.d.ts +1 -1
- package/index.js +1 -8
- package/modern/Component.js +39 -7
- package/modern/components/buttons/index.css +35 -0
- package/modern/{buttons-1859cb8e.d.ts → components/buttons/index.d.ts} +6 -1
- package/modern/components/buttons/index.js +33 -0
- package/modern/components/header/Component.js +27 -9
- package/modern/components/header/index.css +5 -19
- package/modern/components/header-info-block/Component.js +1 -1
- package/modern/components/header-info-block/index.css +5 -5
- package/modern/components/header-mobile/Component.d.ts +4 -0
- package/modern/components/header-mobile/Component.js +28 -0
- package/modern/components/header-mobile/index.css +50 -0
- package/modern/components/header-mobile/index.d.ts +1 -0
- package/modern/components/header-mobile/index.js +1 -0
- package/modern/components/image-preview/Component.js +65 -23
- package/modern/components/image-preview/index.css +35 -28
- package/modern/components/image-preview/paths.d.ts +2 -0
- package/modern/components/image-preview/paths.js +2 -0
- package/modern/components/image-viewer/component.js +31 -11
- package/modern/components/image-viewer/index.css +37 -25
- package/modern/components/image-viewer/slide.js +3 -1
- package/modern/components/image-viewer/video/index.css +48 -0
- package/modern/components/image-viewer/video/index.d.ts +10 -0
- package/modern/components/image-viewer/video/index.js +117 -0
- package/modern/components/index.d.ts +2 -0
- package/modern/components/index.js +2 -0
- package/modern/components/info-bar/Component.d.ts +4 -0
- package/modern/components/info-bar/Component.js +38 -0
- package/modern/components/info-bar/index.css +37 -0
- package/modern/components/info-bar/index.d.ts +1 -0
- package/modern/components/info-bar/index.js +1 -0
- package/modern/components/navigation-bar/Component.js +3 -2
- package/modern/components/navigation-bar/index.css +8 -6
- package/modern/context.d.ts +7 -0
- package/modern/context.js +7 -0
- package/modern/index.css +17 -5
- package/modern/index.d.ts +1 -1
- package/modern/index.js +1 -3
- package/modern/{slide-c47386c3.js → slide-83826e9d.js} +15 -5
- package/modern/types.d.ts +7 -0
- package/modern/utils/constants.d.ts +14 -1
- package/modern/utils/constants.js +14 -1
- package/modern/utils/index.js +2 -2
- package/modern/utils/utils.d.ts +2 -1
- package/modern/utils/utils.js +5 -4
- package/moderncssm/Component.js +38 -6
- package/moderncssm/components/buttons/index.d.ts +16 -0
- package/moderncssm/components/buttons/index.js +31 -0
- package/moderncssm/components/buttons/index.module.css +20 -0
- package/moderncssm/components/header/Component.js +24 -9
- package/moderncssm/components/header/index.module.css +0 -19
- package/moderncssm/components/header-mobile/Component.d.ts +4 -0
- package/moderncssm/components/header-mobile/Component.js +26 -0
- package/moderncssm/components/header-mobile/index.d.ts +1 -0
- package/moderncssm/components/header-mobile/index.js +1 -0
- package/moderncssm/components/header-mobile/index.module.css +35 -0
- package/moderncssm/components/image-preview/Component.js +64 -26
- package/moderncssm/components/image-preview/index.module.css +30 -13
- package/moderncssm/components/image-preview/paths.d.ts +2 -0
- package/moderncssm/components/image-preview/paths.js +2 -0
- package/moderncssm/components/image-viewer/component.js +30 -10
- package/moderncssm/components/image-viewer/index.module.css +29 -6
- package/moderncssm/components/image-viewer/slide.js +14 -4
- package/moderncssm/components/image-viewer/video/index.d.ts +10 -0
- package/moderncssm/components/image-viewer/video/index.js +115 -0
- package/moderncssm/components/image-viewer/video/index.module.css +36 -0
- package/moderncssm/components/index.d.ts +2 -0
- package/moderncssm/components/index.js +2 -0
- package/moderncssm/components/info-bar/Component.d.ts +4 -0
- package/moderncssm/components/info-bar/Component.js +36 -0
- package/moderncssm/components/info-bar/index.d.ts +1 -0
- package/moderncssm/components/info-bar/index.js +1 -0
- package/moderncssm/components/info-bar/index.module.css +23 -0
- package/moderncssm/components/navigation-bar/Component.js +2 -1
- package/moderncssm/components/navigation-bar/index.module.css +4 -0
- package/moderncssm/context.d.ts +7 -0
- package/moderncssm/context.js +7 -0
- package/moderncssm/index.d.ts +1 -1
- package/moderncssm/index.js +1 -3
- package/moderncssm/index.module.css +18 -2
- package/moderncssm/types.d.ts +7 -0
- package/moderncssm/utils/constants.d.ts +14 -1
- package/moderncssm/utils/constants.js +14 -1
- package/moderncssm/utils/index.js +2 -2
- package/moderncssm/utils/utils.d.ts +2 -1
- package/moderncssm/utils/utils.js +5 -4
- package/package.json +2 -1
- package/{slide-12155967.js → slide-07755478.js} +13 -3
- package/src/Component.tsx +48 -6
- package/src/components/buttons/index.module.css +21 -0
- package/src/components/{header/buttons.tsx → buttons/index.tsx} +77 -0
- package/src/components/header/Component.tsx +33 -10
- package/src/components/header/index.module.css +0 -20
- package/src/components/header-mobile/Component.tsx +57 -0
- package/src/components/header-mobile/index.module.css +35 -0
- package/src/components/header-mobile/index.ts +1 -0
- package/src/components/image-preview/Component.tsx +131 -28
- package/src/components/image-preview/index.module.css +28 -9
- package/src/components/image-preview/paths.ts +3 -0
- package/src/components/image-viewer/component.tsx +32 -11
- package/src/components/image-viewer/index.module.css +26 -3
- package/src/components/image-viewer/slide.tsx +30 -4
- package/src/components/image-viewer/video/index.module.css +36 -0
- package/src/components/image-viewer/video/index.tsx +159 -0
- package/src/components/index.ts +2 -0
- package/src/components/info-bar/Component.tsx +68 -0
- package/src/components/info-bar/index.module.css +23 -0
- package/src/components/info-bar/index.ts +1 -0
- package/src/components/navigation-bar/Component.tsx +2 -1
- package/src/components/navigation-bar/index.module.css +4 -0
- package/src/context.ts +14 -0
- package/src/index.module.css +18 -2
- package/src/index.ts +1 -1
- package/src/types.ts +15 -5
- package/src/utils/constants.ts +17 -0
- package/src/utils/utils.ts +5 -3
- package/types.d.ts +7 -0
- package/utils/constants.d.ts +14 -1
- package/utils/constants.js +19 -0
- package/utils/index.js +7 -0
- package/utils/utils.d.ts +2 -1
- package/utils/utils.js +5 -3
- package/buttons-ec113bb4.js +0 -37
- package/components/header/buttons.d.ts +0 -0
- package/components/header/buttons.js +0 -20
- package/cssm/components/header/buttons.js +0 -37
- package/esm/buttons-791da71e.js +0 -27
- package/esm/components/header/buttons.d.ts +0 -0
- package/esm/components/header/buttons.js +0 -9
- package/modern/buttons-1859cb8e.js +0 -20
- package/modern/components/header/buttons.d.ts +0 -0
- package/modern/components/header/buttons.js +0 -8
- package/moderncssm/components/header/buttons.d.ts +0 -11
- package/moderncssm/components/header/buttons.js +0 -18
- /package/esm/{slide-7d5a41d1.d.ts → slide-c469a906.d.ts} +0 -0
- /package/modern/{slide-c47386c3.d.ts → slide-83826e9d.d.ts} +0 -0
- /package/{slide-12155967.d.ts → slide-07755478.d.ts} +0 -0
|
@@ -3,18 +3,23 @@
|
|
|
3
3
|
.component {
|
|
4
4
|
display: flex;
|
|
5
5
|
padding: var(--gap-4);
|
|
6
|
-
|
|
7
|
-
border-radius: var(--border-radius-12);
|
|
6
|
+
z-index: 3;
|
|
8
7
|
overflow: hidden;
|
|
9
8
|
transition: border 0.15s ease-in-out;
|
|
10
9
|
outline: none;
|
|
10
|
+
|
|
11
|
+
& .image {
|
|
12
|
+
opacity: 0.3;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.mobile {
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
11
18
|
}
|
|
12
19
|
|
|
13
20
|
.active {
|
|
14
|
-
border-color: var(--color-static-overlay-white-xhigh);
|
|
15
|
-
|
|
16
21
|
& > .image {
|
|
17
|
-
opacity:
|
|
22
|
+
opacity: 1;
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
|
|
@@ -22,9 +27,15 @@
|
|
|
22
27
|
width: 56px;
|
|
23
28
|
height: 56px;
|
|
24
29
|
flex-shrink: 0;
|
|
25
|
-
border-radius: var(--border-radius-
|
|
30
|
+
border-radius: var(--border-radius-12);
|
|
26
31
|
cursor: pointer;
|
|
27
32
|
user-select: none;
|
|
33
|
+
|
|
34
|
+
&.mobile {
|
|
35
|
+
width: 36px;
|
|
36
|
+
height: 46px;
|
|
37
|
+
border-radius: var(--border-radius-8);
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
40
|
|
|
30
41
|
.image {
|
|
@@ -32,7 +43,6 @@
|
|
|
32
43
|
|
|
33
44
|
& > img {
|
|
34
45
|
display: block;
|
|
35
|
-
background-color: var(--color-light-base-bg-primary);
|
|
36
46
|
width: 100%;
|
|
37
47
|
height: 100%;
|
|
38
48
|
border-radius: inherit;
|
|
@@ -59,9 +69,10 @@
|
|
|
59
69
|
justify-content: center;
|
|
60
70
|
align-items: center;
|
|
61
71
|
background-color: var(--color-static-neutral-300-inverted);
|
|
72
|
+
opacity: 0.3;
|
|
62
73
|
|
|
63
|
-
|
|
64
|
-
opacity:
|
|
74
|
+
&.active {
|
|
75
|
+
opacity: 1;
|
|
65
76
|
}
|
|
66
77
|
}
|
|
67
78
|
|
|
@@ -73,3 +84,11 @@
|
|
|
73
84
|
.focused {
|
|
74
85
|
@mixin focus-outline;
|
|
75
86
|
}
|
|
87
|
+
|
|
88
|
+
.canvasPreview {
|
|
89
|
+
border-radius: var(--border-radius-12);
|
|
90
|
+
|
|
91
|
+
&.mobile {
|
|
92
|
+
border-radius: var(--border-radius-8);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -2,4 +2,7 @@ export const NoImagePaths = {
|
|
|
2
2
|
baseImage:
|
|
3
3
|
'M 30.5 6.5 L 4 6.5 C 2.894531 6.5 2 7.394531 2 8.5 L 2 31.5 C 2 32.605469 2.894531 33.5 4 33.5 L 36 33.5 C 37.105469 33.5 38 32.605469 38 31.5 L 38 14 L 32.367188 14 C 31.335938 14 30.5 13.164062 30.5 12.132812 Z M 11.917969 15.667969 C 12.285156 15.296875 12.882812 15.296875 13.25 15.667969 L 14.25 16.667969 L 15.25 15.667969 C 15.617188 15.296875 16.214844 15.296875 16.582031 15.667969 C 16.953125 16.035156 16.953125 16.632812 16.582031 17 L 15.582031 18 L 16.582031 19 C 16.953125 19.367188 16.953125 19.964844 16.582031 20.332031 C 16.214844 20.703125 15.617188 20.703125 15.25 20.332031 L 14.25 19.332031 L 13.25 20.332031 C 12.882812 20.703125 12.285156 20.703125 11.917969 20.332031 C 11.546875 19.964844 11.546875 19.367188 11.917969 19 L 12.917969 18 L 11.917969 17 C 11.546875 16.632812 11.546875 16.035156 11.917969 15.667969 Z M 24.75 15.667969 C 24.382812 15.296875 23.785156 15.296875 23.414062 15.667969 C 23.046875 16.035156 23.046875 16.632812 23.414062 17 L 24.414062 18 L 23.414062 19 C 23.046875 19.367188 23.046875 19.964844 23.414062 20.332031 C 23.785156 20.703125 24.378906 20.703125 24.75 20.332031 L 25.75 19.332031 L 26.75 20.332031 C 27.117188 20.703125 27.714844 20.703125 28.082031 20.332031 C 28.449219 19.964844 28.449219 19.367188 28.082031 19 L 27.082031 18 L 28.082031 17 C 28.449219 16.632812 28.449219 16.035156 28.082031 15.667969 C 27.714844 15.296875 27.117188 15.296875 26.75 15.667969 L 25.75 16.667969 Z M 14.40625 27.914062 L 14.402344 27.914062 C 13.898438 28.136719 13.308594 27.910156 13.085938 27.40625 C 12.863281 26.902344 13.089844 26.308594 13.59375 26.085938 L 14 27 C 13.59375 26.085938 13.59375 26.085938 13.59375 26.085938 L 13.597656 26.085938 L 13.601562 26.082031 L 13.609375 26.078125 L 13.621094 26.074219 L 13.636719 26.066406 C 13.660156 26.058594 13.695312 26.042969 13.734375 26.027344 C 13.816406 25.996094 13.933594 25.949219 14.082031 25.898438 C 14.378906 25.796875 14.808594 25.660156 15.359375 25.527344 C 16.457031 25.261719 18.035156 25 20 25 C 21.964844 25 23.542969 25.261719 24.640625 25.527344 C 25.191406 25.660156 25.621094 25.796875 25.917969 25.898438 C 25.96875 25.917969 26.015625 25.933594 26.058594 25.949219 C 26.144531 25.980469 26.210938 26.007812 26.265625 26.027344 C 26.285156 26.035156 26.304688 26.042969 26.320312 26.050781 C 26.335938 26.054688 26.351562 26.0625 26.363281 26.066406 L 26.382812 26.078125 L 26.390625 26.078125 L 26.398438 26.082031 L 26.402344 26.085938 L 26.40625 26.085938 C 26.40625 26.085938 26.40625 26.085938 26.402344 26.089844 L 26.398438 26.105469 L 26.40625 26.085938 C 26.910156 26.308594 27.136719 26.902344 26.914062 27.40625 C 26.691406 27.910156 26.101562 28.136719 25.597656 27.914062 L 20.449219 27.914062 L 25.59375 27.914062 L 25.585938 27.910156 C 25.574219 27.90625 25.554688 27.898438 25.527344 27.886719 C 25.472656 27.863281 25.382812 27.832031 25.261719 27.789062 C 25.019531 27.703125 24.652344 27.589844 24.171875 27.472656 C 23.207031 27.238281 21.785156 27 20 27 C 18.214844 27 16.792969 27.238281 15.828125 27.472656 C 15.347656 27.589844 14.980469 27.703125 14.738281 27.789062 C 14.617188 27.832031 14.527344 27.863281 14.472656 27.886719 C 14.445312 27.898438 14.425781 27.90625 14.414062 27.910156 L 14.40625 27.914062 L 20.449219 27.914062 Z M 14.40625 27.914062',
|
|
4
4
|
triangleImage: 'M 38 12 L 32.5 12 L 32.5 6.5 Z M 38 12',
|
|
5
|
+
mobileImage:
|
|
6
|
+
'M19 0H1.33333C0.596954 0 0 0.596944 0 1.33333V16.6667C0 17.4031 0.596954 18 1.33333 18H22.6667C23.403 18 24 17.4031 24 16.6667V4.99995H20.2444C19.5571 4.99995 19 4.44279 19 3.7555V0ZM6.61123 6.11112C6.85668 5.86566 7.25465 5.86566 7.5001 6.11112L8.1667 6.77773L8.83331 6.1111C9.07878 5.86564 9.47675 5.86564 9.7222 6.1111C9.96766 6.35657 9.96766 6.75454 9.7222 7L9.05558 7.66661L9.72231 8.33333C9.96777 8.57878 9.96777 8.97675 9.72231 9.22221C9.47686 9.46767 9.07889 9.46767 8.83344 9.22221L8.16671 8.55548L7.49999 9.22221C7.25454 9.46765 6.85657 9.46765 6.6111 9.22221C6.36565 8.97675 6.36565 8.57878 6.6111 8.33331L7.27782 7.66659L6.61123 7C6.36576 6.75454 6.36576 6.35657 6.61123 6.11112ZM15.1661 6.11112C14.9207 5.86566 14.5227 5.86566 14.2772 6.11112C14.0318 6.35659 14.0318 6.75456 14.2772 7L14.9438 7.66661L14.2771 8.33333C14.0317 8.57878 14.0317 8.97675 14.2771 9.22221C14.5226 9.46767 14.9206 9.46767 15.166 9.22221L15.8327 8.55548L16.4995 9.22221C16.7449 9.46767 17.1429 9.46767 17.3883 9.22221C17.6338 8.97677 17.6338 8.5788 17.3883 8.33333L16.7216 7.66661L17.3882 7C17.6337 6.75454 17.6337 6.35657 17.3882 6.11112C17.1428 5.86566 16.7448 5.86566 16.4993 6.11112L15.8327 6.77773L15.1661 6.11112ZM8.26956 14.2764L8.26919 14.2766C7.93322 14.4248 7.54007 14.2733 7.39079 13.9374C7.24125 13.601 7.39278 13.207 7.72924 13.0575L8 13.6667C7.72924 13.0575 7.72962 13.0573 7.72962 13.0573L7.73005 13.0571L7.73099 13.0567L7.7333 13.0557L7.73957 13.0529L7.74749 13.0495L7.75875 13.0448C7.77446 13.0381 7.796 13.0293 7.82326 13.0184C7.87777 12.9968 7.95515 12.9674 8.05442 12.9328C8.25294 12.8638 8.53925 12.7742 8.90544 12.6854C9.63773 12.5079 10.6907 12.3333 12 12.3333C13.3093 12.3333 14.3623 12.5079 15.0946 12.6854C15.4608 12.7742 15.7471 12.8638 15.9456 12.9328C15.9796 12.9447 16.011 12.9559 16.0398 12.9664C16.0952 12.9866 16.1409 13.0042 16.1767 13.0184C16.1901 13.0238 16.2022 13.0286 16.2128 13.033C16.2238 13.0375 16.2333 13.0414 16.2413 13.0448L16.2559 13.051L16.2604 13.0529L16.2667 13.0557L16.269 13.0567L16.27 13.0571L16.2704 13.0573C16.2704 13.0573 16.2704 13.0573 16.2692 13.0602L16.2646 13.0707L16.2708 13.0575C16.6072 13.207 16.7587 13.601 16.6092 13.9374C16.4599 14.2733 16.0671 14.4249 15.731 14.2767L15.7304 14.2764L12.2987 14.2764L15.73 14.2762L15.7238 14.2736C15.7163 14.2704 15.7032 14.265 15.6846 14.2576C15.6473 14.2428 15.588 14.2201 15.5075 14.1922C15.3467 14.1362 15.1017 14.0591 14.7804 13.9812C14.1377 13.8254 13.1907 13.6667 12 13.6667C10.8093 13.6667 9.86227 13.8254 9.21956 13.9812C8.89825 14.0591 8.65331 14.1362 8.49245 14.1922C8.41204 14.2201 8.3527 14.2428 8.31541 14.2576C8.29677 14.265 8.28365 14.2704 8.27616 14.2736L8.27041 14.276L12.2987 14.2764L8.26956 14.2764Z',
|
|
7
|
+
mobileTriangle: 'M23.9999 3.66661H20.3333V0L23.9999 3.66661Z',
|
|
5
8
|
};
|
|
@@ -19,7 +19,7 @@ import { ChevronBackHeavyMIcon } from '@alfalab/icons-glyph/ChevronBackHeavyMIco
|
|
|
19
19
|
import { ChevronForwardHeavyMIcon } from '@alfalab/icons-glyph/ChevronForwardHeavyMIcon';
|
|
20
20
|
|
|
21
21
|
import { GalleryContext } from '../../context';
|
|
22
|
-
import { getImageAlt, getImageKey, TestIds } from '../../utils';
|
|
22
|
+
import { getImageAlt, getImageKey, isVideo, TestIds } from '../../utils';
|
|
23
23
|
|
|
24
24
|
import { Slide } from './slide';
|
|
25
25
|
|
|
@@ -37,15 +37,18 @@ export const ImageViewer: FC = () => {
|
|
|
37
37
|
currentSlideIndex,
|
|
38
38
|
initialSlide,
|
|
39
39
|
onClose,
|
|
40
|
-
getCurrentImage,
|
|
41
40
|
setImageMeta,
|
|
42
41
|
setCurrentSlideIndex,
|
|
43
42
|
getSwiper,
|
|
44
43
|
setSwiper,
|
|
45
44
|
slidePrev,
|
|
46
45
|
slideNext,
|
|
46
|
+
getCurrentImage,
|
|
47
|
+
view,
|
|
47
48
|
} = useContext(GalleryContext);
|
|
48
49
|
|
|
50
|
+
const isMobile = view === 'mobile';
|
|
51
|
+
|
|
49
52
|
const leftArrowRef = useRef<HTMLDivElement>(null);
|
|
50
53
|
const rightArrowRef = useRef<HTMLDivElement>(null);
|
|
51
54
|
|
|
@@ -53,6 +56,7 @@ export const ImageViewer: FC = () => {
|
|
|
53
56
|
const [rightArrowFocused] = useFocus(rightArrowRef, 'keyboard');
|
|
54
57
|
|
|
55
58
|
const swiper = getSwiper();
|
|
59
|
+
const currentImage = getCurrentImage();
|
|
56
60
|
|
|
57
61
|
const handleSlideChange = useCallback(() => {
|
|
58
62
|
setCurrentSlideIndex?.(swiper?.activeIndex ?? initialSlide);
|
|
@@ -102,11 +106,11 @@ export const ImageViewer: FC = () => {
|
|
|
102
106
|
|
|
103
107
|
const isImg = eventTarget.tagName === 'IMG';
|
|
104
108
|
|
|
105
|
-
if (!isImg && !isPlaceholder && !isArrow) {
|
|
109
|
+
if (!isImg && !isPlaceholder && !isArrow && !isMobile) {
|
|
106
110
|
onClose();
|
|
107
111
|
}
|
|
108
112
|
},
|
|
109
|
-
[onClose],
|
|
113
|
+
[isMobile, onClose],
|
|
110
114
|
);
|
|
111
115
|
|
|
112
116
|
useEffect(() => {
|
|
@@ -120,32 +124,49 @@ export const ImageViewer: FC = () => {
|
|
|
120
124
|
fadeEffect: {
|
|
121
125
|
crossFade: true,
|
|
122
126
|
},
|
|
123
|
-
className: cn(styles.swiper, {
|
|
127
|
+
className: cn(styles.swiper, {
|
|
128
|
+
[styles.hidden]: fullScreen && !isVideo(currentImage?.src),
|
|
129
|
+
[styles.fullScreenVideo]: fullScreen && !singleSlide && isVideo(currentImage?.src),
|
|
130
|
+
[styles.mobile]: isMobile,
|
|
131
|
+
[styles.mobileVideo]: isMobile && isVideo(currentImage?.src),
|
|
132
|
+
}),
|
|
124
133
|
controller: { control: swiper },
|
|
125
134
|
a11y: {
|
|
126
135
|
slideRole: 'img',
|
|
127
136
|
},
|
|
128
137
|
initialSlide,
|
|
129
138
|
simulateTouch: false,
|
|
139
|
+
zoom: { maxRatio: 4 },
|
|
130
140
|
onSwiper: setSwiper,
|
|
131
141
|
onSlideChange: handleSlideChange,
|
|
132
142
|
}),
|
|
133
|
-
[
|
|
143
|
+
[
|
|
144
|
+
fullScreen,
|
|
145
|
+
currentImage?.src,
|
|
146
|
+
singleSlide,
|
|
147
|
+
isMobile,
|
|
148
|
+
swiper,
|
|
149
|
+
initialSlide,
|
|
150
|
+
setSwiper,
|
|
151
|
+
handleSlideChange,
|
|
152
|
+
],
|
|
134
153
|
);
|
|
135
154
|
|
|
136
|
-
const showControls = !singleSlide && !fullScreen && !!images.length;
|
|
155
|
+
const showControls = !singleSlide && !fullScreen && !isMobile && !!images.length;
|
|
137
156
|
|
|
138
157
|
const swiperWidth = swiper?.width || 1;
|
|
139
158
|
const swiperHeight = swiper?.height || swiper?.width || 1;
|
|
140
159
|
|
|
141
160
|
const swiperAspectRatio = swiperWidth / swiperHeight;
|
|
142
161
|
|
|
143
|
-
const currentImage = getCurrentImage();
|
|
144
|
-
|
|
145
162
|
return (
|
|
146
163
|
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */
|
|
147
164
|
<div
|
|
148
|
-
className={cn(styles.component, {
|
|
165
|
+
className={cn(styles.component, {
|
|
166
|
+
[styles.singleSlide]: singleSlide,
|
|
167
|
+
[styles.mobile]: isMobile,
|
|
168
|
+
[styles.mobileVideo]: isMobile && isVideo(currentImage?.src),
|
|
169
|
+
})}
|
|
149
170
|
onClick={handleWrapperClick}
|
|
150
171
|
>
|
|
151
172
|
{showControls && (
|
|
@@ -165,7 +186,7 @@ export const ImageViewer: FC = () => {
|
|
|
165
186
|
</div>
|
|
166
187
|
)}
|
|
167
188
|
|
|
168
|
-
{fullScreen && (
|
|
189
|
+
{fullScreen && !isVideo(currentImage?.src) && (
|
|
169
190
|
<img
|
|
170
191
|
src={currentImage?.src}
|
|
171
192
|
alt={currentImage ? getImageAlt(currentImage, currentSlideIndex) : ''}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-grow: 1;
|
|
6
6
|
justify-content: center;
|
|
7
|
-
align-items: center;
|
|
8
7
|
background-color: var(--color-static-neutral-0-inverted);
|
|
9
8
|
}
|
|
10
9
|
|
|
@@ -17,11 +16,28 @@
|
|
|
17
16
|
max-height: calc(100vh - 168px);
|
|
18
17
|
padding: var(--gap-32) var(--gap-16);
|
|
19
18
|
box-sizing: border-box;
|
|
19
|
+
|
|
20
|
+
&.mobile {
|
|
21
|
+
max-height: calc(100vh - 210px);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.mobileVideo {
|
|
25
|
+
max-height: 100vh;
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
.singleSlide .swiper {
|
|
23
30
|
max-height: calc(100vh - 80px);
|
|
24
31
|
padding: var(--gap-32);
|
|
32
|
+
|
|
33
|
+
&.mobile {
|
|
34
|
+
max-height: calc(100vh - 174px);
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.mobileVideo {
|
|
39
|
+
max-height: 100vh;
|
|
40
|
+
}
|
|
25
41
|
}
|
|
26
42
|
|
|
27
43
|
.hidden {
|
|
@@ -46,8 +62,11 @@
|
|
|
46
62
|
width: 0;
|
|
47
63
|
height: 0;
|
|
48
64
|
user-select: none;
|
|
49
|
-
background-color: var(--color-light-base-bg-primary);
|
|
50
65
|
border-radius: var(--border-radius-8);
|
|
66
|
+
|
|
67
|
+
&.mobile {
|
|
68
|
+
border-radius: var(--border-radius-0);
|
|
69
|
+
}
|
|
51
70
|
}
|
|
52
71
|
|
|
53
72
|
.smallImage {
|
|
@@ -55,7 +74,6 @@
|
|
|
55
74
|
width: auto;
|
|
56
75
|
height: auto;
|
|
57
76
|
user-select: none;
|
|
58
|
-
background-color: var(--color-light-base-bg-primary);
|
|
59
77
|
}
|
|
60
78
|
|
|
61
79
|
.verticalImageFit {
|
|
@@ -124,3 +142,8 @@
|
|
|
124
142
|
height: auto;
|
|
125
143
|
background-color: var(--color-light-base-bg-primary);
|
|
126
144
|
}
|
|
145
|
+
|
|
146
|
+
.fullScreenVideo {
|
|
147
|
+
width: calc(100% - 192px);
|
|
148
|
+
max-height: calc(100vh - 82px);
|
|
149
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import React, { FC, ReactNode, SyntheticEvent } from 'react';
|
|
1
|
+
import React, { FC, ReactNode, SyntheticEvent, useContext } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { Typography } from '@alfalab/core-components-typography';
|
|
5
5
|
|
|
6
|
+
import { GalleryContext } from '../../context';
|
|
6
7
|
import { GalleryImage, ImageMeta } from '../../types';
|
|
7
|
-
import { getImageAlt, isSmallImage, TestIds } from '../../utils';
|
|
8
|
+
import { getImageAlt, isSmallImage, isVideo, TestIds } from '../../utils';
|
|
8
9
|
|
|
9
10
|
import { NoImagePaths } from './paths';
|
|
11
|
+
import { Video } from './video';
|
|
10
12
|
|
|
11
13
|
import styles from './index.module.css';
|
|
12
14
|
|
|
@@ -16,9 +18,16 @@ type SlideInnerProps = {
|
|
|
16
18
|
withPlaceholder: boolean;
|
|
17
19
|
loading: boolean;
|
|
18
20
|
children: ReactNode;
|
|
21
|
+
isVideoView?: boolean;
|
|
19
22
|
};
|
|
20
23
|
|
|
21
|
-
const SlideInner: FC<SlideInnerProps> = ({
|
|
24
|
+
const SlideInner: FC<SlideInnerProps> = ({
|
|
25
|
+
children,
|
|
26
|
+
broken,
|
|
27
|
+
loading,
|
|
28
|
+
withPlaceholder,
|
|
29
|
+
isVideoView,
|
|
30
|
+
}) => {
|
|
22
31
|
const content = broken ? (
|
|
23
32
|
<div className={styles.brokenImgWrapper}>
|
|
24
33
|
<div className={styles.brokenImgIcon}>
|
|
@@ -41,7 +50,7 @@ const SlideInner: FC<SlideInnerProps> = ({ children, broken, loading, withPlaceh
|
|
|
41
50
|
</div>
|
|
42
51
|
|
|
43
52
|
<Typography.Text view='primary-small' color='static-secondary-light'>
|
|
44
|
-
Не удалось загрузить изображение
|
|
53
|
+
Не удалось загрузить {isVideoView ? 'видео' : 'изображение'}
|
|
45
54
|
</Typography.Text>
|
|
46
55
|
</div>
|
|
47
56
|
) : (
|
|
@@ -80,11 +89,27 @@ export const Slide: FC<SlideProps> = ({
|
|
|
80
89
|
handleLoad,
|
|
81
90
|
handleLoadError,
|
|
82
91
|
}) => {
|
|
92
|
+
const { view } = useContext(GalleryContext);
|
|
93
|
+
|
|
83
94
|
const broken = Boolean(meta?.broken);
|
|
84
95
|
const small = isSmallImage(meta);
|
|
85
96
|
const verticalImageFit = !small && swiperAspectRatio > imageAspectRatio;
|
|
86
97
|
const horizontalImageFit = !small && swiperAspectRatio <= imageAspectRatio;
|
|
87
98
|
|
|
99
|
+
if (isVideo(image.src)) {
|
|
100
|
+
return (
|
|
101
|
+
<SlideInner
|
|
102
|
+
isVideoView={true}
|
|
103
|
+
active={isActive}
|
|
104
|
+
broken={broken}
|
|
105
|
+
withPlaceholder={broken}
|
|
106
|
+
loading={!meta}
|
|
107
|
+
>
|
|
108
|
+
<Video url={image.src} index={index} isActive={isActive} />
|
|
109
|
+
</SlideInner>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
88
113
|
return (
|
|
89
114
|
<SlideInner
|
|
90
115
|
active={isActive}
|
|
@@ -98,6 +123,7 @@ export const Slide: FC<SlideProps> = ({
|
|
|
98
123
|
className={cn({
|
|
99
124
|
[styles.smallImage]: small,
|
|
100
125
|
[styles.image]: !small && meta,
|
|
126
|
+
[styles.mobile]: view === 'mobile',
|
|
101
127
|
[styles.verticalImageFit]: verticalImageFit,
|
|
102
128
|
[styles.horizontalImageFit]: horizontalImageFit,
|
|
103
129
|
})}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
|
+
|
|
3
|
+
.videoWrapper {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
height: 100%;
|
|
7
|
+
width: 100%;
|
|
8
|
+
position: relative;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.video {
|
|
12
|
+
max-width: 100%;
|
|
13
|
+
max-height: 100%;
|
|
14
|
+
border-radius: var(--border-radius-24);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.mobile {
|
|
18
|
+
border-radius: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.videoButton {
|
|
22
|
+
position: absolute;
|
|
23
|
+
top: 50%;
|
|
24
|
+
left: 50%;
|
|
25
|
+
transform: translate(-50%, -50%);
|
|
26
|
+
z-index: 1;
|
|
27
|
+
color: green;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.icon {
|
|
31
|
+
color: var(--color-static-neutral-0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.iconShape {
|
|
35
|
+
fill: var(--color-static-neutral-translucent-700);
|
|
36
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { MouseEvent, ReactEventHandler, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import Hls from 'hls.js';
|
|
4
|
+
|
|
5
|
+
import { Circle } from '@alfalab/core-components/icon-view/circle';
|
|
6
|
+
import PlayCompactMIcon from '@alfalab/icons-glyph/PlayCompactMIcon';
|
|
7
|
+
|
|
8
|
+
import { GalleryContext } from '../../../context';
|
|
9
|
+
import { GALLERY_EVENTS } from '../../../utils/constants';
|
|
10
|
+
|
|
11
|
+
import styles from './index.module.css';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
url: string;
|
|
15
|
+
index: number;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Video = ({ url, index, className, isActive }: Props) => {
|
|
21
|
+
const playerRef = useRef<HTMLVideoElement>(null);
|
|
22
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
23
|
+
|
|
24
|
+
const { setImageMeta, mutedVideo, view, playingVideo, setPlayingVideo, setHideNavigation } =
|
|
25
|
+
useContext(GalleryContext);
|
|
26
|
+
|
|
27
|
+
const isMobile = view === 'mobile';
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setImageMeta({ player: playerRef }, index);
|
|
31
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
32
|
+
}, [index]);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const hls = new Hls();
|
|
36
|
+
|
|
37
|
+
if (Hls.isSupported()) {
|
|
38
|
+
hls.on(Hls.Events.ERROR, (_, data) => {
|
|
39
|
+
if (data.fatal) {
|
|
40
|
+
switch (data.type) {
|
|
41
|
+
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
42
|
+
hls.recoverMediaError();
|
|
43
|
+
break;
|
|
44
|
+
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
45
|
+
setImageMeta({ player: { current: null }, broken: true }, index);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
hls.destroy();
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
hls.loadSource(url);
|
|
55
|
+
if (playerRef.current) {
|
|
56
|
+
hls.attachMedia(playerRef.current);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return () => {
|
|
61
|
+
if (hls) {
|
|
62
|
+
hls.destroy();
|
|
63
|
+
}
|
|
64
|
+
if (timer.current) {
|
|
65
|
+
clearTimeout(timer.current);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/* eslint-disable-next-line react-hooks/exhaustive-deps */
|
|
69
|
+
}, [url, index]);
|
|
70
|
+
|
|
71
|
+
const handleWrapperClick = (e: MouseEvent) => {
|
|
72
|
+
e.stopPropagation();
|
|
73
|
+
|
|
74
|
+
if (isMobile) {
|
|
75
|
+
setHideNavigation(false);
|
|
76
|
+
|
|
77
|
+
if (playingVideo) {
|
|
78
|
+
if (timer.current) {
|
|
79
|
+
clearTimeout(timer.current);
|
|
80
|
+
}
|
|
81
|
+
timer.current = setTimeout(() => {
|
|
82
|
+
setHideNavigation(true);
|
|
83
|
+
}, 3000);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setPlayingVideo(!playingVideo);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (playerRef.current && isActive) {
|
|
94
|
+
if (playingVideo) {
|
|
95
|
+
playerRef.current.play();
|
|
96
|
+
} else {
|
|
97
|
+
playerRef.current.pause();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (playerRef.current && !isActive) {
|
|
101
|
+
playerRef.current.pause();
|
|
102
|
+
playerRef.current.currentTime = 0;
|
|
103
|
+
}
|
|
104
|
+
}, [isActive, playingVideo]);
|
|
105
|
+
|
|
106
|
+
const onPlay: ReactEventHandler<HTMLVideoElement> = (e) => {
|
|
107
|
+
const customEvent = new CustomEvent(GALLERY_EVENTS.ON_PLAY, {
|
|
108
|
+
detail: { player: e.target },
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
dispatchEvent(customEvent);
|
|
112
|
+
|
|
113
|
+
if (timer.current) {
|
|
114
|
+
clearTimeout(timer.current);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
timer.current = setTimeout(() => {
|
|
118
|
+
setHideNavigation(true);
|
|
119
|
+
}, 3000);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const onPause: ReactEventHandler<HTMLVideoElement> = (e) => {
|
|
123
|
+
const customEvent = new CustomEvent(GALLERY_EVENTS.ON_PAUSE, {
|
|
124
|
+
detail: { player: e.target },
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
dispatchEvent(customEvent);
|
|
128
|
+
if (timer.current) {
|
|
129
|
+
clearTimeout(timer.current);
|
|
130
|
+
timer.current = undefined;
|
|
131
|
+
}
|
|
132
|
+
setHideNavigation(false);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
137
|
+
<div onClick={handleWrapperClick} className={styles.videoWrapper}>
|
|
138
|
+
<video
|
|
139
|
+
onPlay={onPlay}
|
|
140
|
+
onPause={onPause}
|
|
141
|
+
ref={playerRef}
|
|
142
|
+
playsInline={true}
|
|
143
|
+
muted={mutedVideo}
|
|
144
|
+
loop={true}
|
|
145
|
+
src={Hls.isSupported() ? undefined : url}
|
|
146
|
+
className={cn(styles.video, { [styles.mobile]: view === 'mobile' }, className)}
|
|
147
|
+
>
|
|
148
|
+
<track kind='captions' />
|
|
149
|
+
</video>
|
|
150
|
+
{view === 'desktop' && !playingVideo && (
|
|
151
|
+
<div className={styles.videoButton}>
|
|
152
|
+
<Circle size={64} shapeClassName={styles.iconShape}>
|
|
153
|
+
<PlayCompactMIcon className={styles.icon} />
|
|
154
|
+
</Circle>
|
|
155
|
+
</div>
|
|
156
|
+
)}
|
|
157
|
+
</div>
|
|
158
|
+
);
|
|
159
|
+
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { useCallback, useContext } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Typography } from '@alfalab/core-components-typography';
|
|
4
|
+
|
|
5
|
+
import { GalleryContext } from '../../context';
|
|
6
|
+
import { GALLERY_EVENTS, isVideo } from '../../utils';
|
|
7
|
+
import * as Buttons from '../buttons';
|
|
8
|
+
|
|
9
|
+
import styles from './index.module.css';
|
|
10
|
+
|
|
11
|
+
export const InfoBar = () => {
|
|
12
|
+
const {
|
|
13
|
+
getCurrentImage,
|
|
14
|
+
mutedVideo,
|
|
15
|
+
setMutedVideo,
|
|
16
|
+
playingVideo,
|
|
17
|
+
setPlayingVideo,
|
|
18
|
+
getCurrentImageMeta,
|
|
19
|
+
} = useContext(GalleryContext);
|
|
20
|
+
|
|
21
|
+
const image = getCurrentImage();
|
|
22
|
+
const meta = getCurrentImageMeta();
|
|
23
|
+
|
|
24
|
+
const handleMuteVideo = useCallback(() => {
|
|
25
|
+
if (mutedVideo) {
|
|
26
|
+
const customEvent = new CustomEvent(GALLERY_EVENTS.ON_UNMUTE, {
|
|
27
|
+
detail: { player: meta?.player?.current },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
dispatchEvent(customEvent);
|
|
31
|
+
} else {
|
|
32
|
+
const customEvent = new CustomEvent(GALLERY_EVENTS.ON_MUTE, {
|
|
33
|
+
detail: { player: meta?.player?.current },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
dispatchEvent(customEvent);
|
|
37
|
+
}
|
|
38
|
+
setMutedVideo(!mutedVideo);
|
|
39
|
+
}, [meta?.player, mutedVideo, setMutedVideo]);
|
|
40
|
+
|
|
41
|
+
const handlePlayVideo = useCallback(() => {
|
|
42
|
+
setPlayingVideo(!playingVideo);
|
|
43
|
+
}, [playingVideo, setPlayingVideo]);
|
|
44
|
+
|
|
45
|
+
return isVideo(image?.src) ? (
|
|
46
|
+
<section className={styles.videoButtons}>
|
|
47
|
+
{playingVideo ? (
|
|
48
|
+
<Buttons.Pause onClick={handlePlayVideo} className={styles.center} />
|
|
49
|
+
) : (
|
|
50
|
+
<Buttons.Play onClick={handlePlayVideo} className={styles.center} />
|
|
51
|
+
)}
|
|
52
|
+
{mutedVideo ? (
|
|
53
|
+
<Buttons.UnmuteVideo onClick={handleMuteVideo} className={styles.right} />
|
|
54
|
+
) : (
|
|
55
|
+
<Buttons.MuteVideo onClick={handleMuteVideo} className={styles.right} />
|
|
56
|
+
)}
|
|
57
|
+
</section>
|
|
58
|
+
) : (
|
|
59
|
+
<Typography.Text
|
|
60
|
+
className={styles.description}
|
|
61
|
+
tag='div'
|
|
62
|
+
view='component'
|
|
63
|
+
color='primary-inverted'
|
|
64
|
+
>
|
|
65
|
+
{image?.name}
|
|
66
|
+
</Typography.Text>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
|
+
|
|
3
|
+
.description {
|
|
4
|
+
text-align: center;
|
|
5
|
+
margin-bottom: var(--gap-8);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.videoButtons {
|
|
9
|
+
padding: 0 var(--gap-8);
|
|
10
|
+
position: relative;
|
|
11
|
+
height: 48px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.center {
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 50%;
|
|
17
|
+
transform: translateX(-50%);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.right {
|
|
21
|
+
position: absolute;
|
|
22
|
+
right: 0;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { InfoBar } from './Component';
|
|
@@ -11,7 +11,7 @@ const MIN_SCROLL_STEP = 24;
|
|
|
11
11
|
export const NavigationBar: FC = () => {
|
|
12
12
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
13
13
|
|
|
14
|
-
const { images, currentSlideIndex, setCurrentSlideIndex, getSwiper } =
|
|
14
|
+
const { images, currentSlideIndex, setCurrentSlideIndex, getSwiper, setPlayingVideo } =
|
|
15
15
|
useContext(GalleryContext);
|
|
16
16
|
|
|
17
17
|
const swiper = getSwiper();
|
|
@@ -20,6 +20,7 @@ export const NavigationBar: FC = () => {
|
|
|
20
20
|
setCurrentSlideIndex?.(index);
|
|
21
21
|
|
|
22
22
|
if (swiper) {
|
|
23
|
+
setPlayingVideo(true);
|
|
23
24
|
swiper.slideTo(index);
|
|
24
25
|
}
|
|
25
26
|
};
|