@treely/strapi-slices 5.3.2 → 5.4.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/dist/components/FullScreenImage/FullScreenImage.d.ts +3 -2
- package/dist/components/portfolio/ProjectInfo/messages.de.d.ts +1 -0
- package/dist/components/portfolio/ProjectInfo/messages.en.d.ts +1 -0
- package/dist/rootMessages.de.d.ts +1 -0
- package/dist/rootMessages.en.d.ts +1 -0
- package/dist/strapi-slices.cjs.development.js +33 -25
- package/dist/strapi-slices.cjs.development.js.map +1 -1
- package/dist/strapi-slices.cjs.production.min.js +1 -1
- package/dist/strapi-slices.cjs.production.min.js.map +1 -1
- package/dist/strapi-slices.esm.js +34 -26
- package/dist/strapi-slices.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FullScreenImage/FullScreenImage.tsx +29 -19
- package/src/components/portfolio/ProjectInfo/messages.de.ts +3 -0
- package/src/components/portfolio/ProjectInfo/messages.en.ts +3 -0
- package/src/slices/FullWidthImageSlider/FullWidthImageSlider.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
2
2
|
import { BoemlyModal, Flex, IconButton } from 'boemly';
|
|
3
3
|
import { useKey, useLockBodyScroll } from 'react-use';
|
|
4
4
|
import StrapiImage from '../../models/strapi/StrapiImage';
|
|
@@ -9,52 +9,62 @@ export interface FullScreenImageProps {
|
|
|
9
9
|
images: StrapiImage[];
|
|
10
10
|
isOpen: boolean;
|
|
11
11
|
onClose: () => void;
|
|
12
|
-
|
|
12
|
+
currentIndex?: number;
|
|
13
|
+
setCurrentIndex?: (callback: (c: number) => number) => void;
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export const FullScreenImage = ({
|
|
16
17
|
images,
|
|
17
18
|
isOpen,
|
|
18
19
|
onClose,
|
|
19
|
-
|
|
20
|
+
currentIndex = 0,
|
|
21
|
+
setCurrentIndex,
|
|
20
22
|
}: FullScreenImageProps) => {
|
|
21
|
-
const [imageIndex, setImageIndex] = useState(0);
|
|
22
23
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
23
24
|
|
|
24
25
|
useLockBodyScroll(isOpen);
|
|
25
26
|
|
|
26
|
-
const canMoveRight =
|
|
27
|
-
|
|
27
|
+
const canMoveRight = useMemo(
|
|
28
|
+
() => currentIndex < images.length - 1,
|
|
29
|
+
[currentIndex, images.length]
|
|
30
|
+
);
|
|
31
|
+
const canMoveLeft = useMemo(() => currentIndex !== 0, [currentIndex]);
|
|
28
32
|
|
|
29
|
-
const onRight = (
|
|
30
|
-
|
|
33
|
+
const onRight = useCallback(
|
|
34
|
+
() => canMoveRight && setCurrentIndex && setCurrentIndex((c) => c + 1),
|
|
35
|
+
[canMoveRight]
|
|
36
|
+
);
|
|
37
|
+
const onLeft = useCallback(
|
|
38
|
+
() => canMoveLeft && setCurrentIndex && setCurrentIndex((c) => c - 1),
|
|
39
|
+
[canMoveLeft]
|
|
40
|
+
);
|
|
31
41
|
|
|
32
42
|
useKey('ArrowRight', onRight, {}, [onRight]);
|
|
33
43
|
useKey('ArrowLeft', onLeft, {}, [onLeft]);
|
|
34
44
|
|
|
35
45
|
useEffect(() => {
|
|
36
|
-
if (
|
|
37
|
-
|
|
46
|
+
if (!!isOpen) {
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
containerRef?.current?.scrollTo({
|
|
49
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
50
|
+
behavior: 'instant',
|
|
51
|
+
});
|
|
52
|
+
}, 10);
|
|
38
53
|
}
|
|
39
|
-
}, [
|
|
54
|
+
}, [isOpen]);
|
|
40
55
|
|
|
41
56
|
useEffect(() => {
|
|
42
57
|
if (containerRef.current) {
|
|
43
58
|
containerRef.current.scrollTo({
|
|
44
|
-
left:
|
|
59
|
+
left: currentIndex * containerRef.current.clientWidth,
|
|
45
60
|
behavior: 'smooth',
|
|
46
61
|
});
|
|
47
62
|
}
|
|
48
|
-
}, [
|
|
49
|
-
|
|
50
|
-
const onCloseLocal = () => {
|
|
51
|
-
setImageIndex(0);
|
|
52
|
-
onClose();
|
|
53
|
-
};
|
|
63
|
+
}, [currentIndex, containerRef]);
|
|
54
64
|
|
|
55
65
|
return (
|
|
56
66
|
<BoemlyModal
|
|
57
|
-
onClose={
|
|
67
|
+
onClose={onClose}
|
|
58
68
|
isOpen={isOpen}
|
|
59
69
|
title=""
|
|
60
70
|
trigger=""
|
|
@@ -10,6 +10,8 @@ const messagesDe = {
|
|
|
10
10
|
'Verifizierungsstandard',
|
|
11
11
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14':
|
|
12
12
|
'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
13
|
+
'features.projectInfo.properties.verificationStandard.value.MfKWCH':
|
|
14
|
+
'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
13
15
|
'features.projectInfo.properties.forecastedAmountYear.label':
|
|
14
16
|
'Projektvolumen',
|
|
15
17
|
'features.projectInfo.properties.riskBuffer': 'Anteil Risikopuffer',
|
|
@@ -17,4 +19,5 @@ const messagesDe = {
|
|
|
17
19
|
'features.projectInfo.properties.year':
|
|
18
20
|
'{years} {years, plural, one {Jahr} other {Jahre} }',
|
|
19
21
|
};
|
|
22
|
+
|
|
20
23
|
export default messagesDe;
|
|
@@ -10,6 +10,8 @@ const messagesEn = {
|
|
|
10
10
|
'Verification Standard',
|
|
11
11
|
'features.projectInfo.properties.verificationStandard.value.SilvaconsultFCSISO14':
|
|
12
12
|
'SILVACONSULT® Forest Carbon Standard, ISO 14064-2',
|
|
13
|
+
'features.projectInfo.properties.verificationStandard.value.MfKWCH':
|
|
14
|
+
'Methodik für Klimaschutzprojekte im Wald für die Schweiz',
|
|
13
15
|
'features.projectInfo.properties.forecastedAmountYear.label':
|
|
14
16
|
'Project Volume',
|
|
15
17
|
'features.projectInfo.properties.riskBuffer': 'Risk Buffer Share',
|
|
@@ -17,4 +19,5 @@ const messagesEn = {
|
|
|
17
19
|
'features.projectInfo.properties.year':
|
|
18
20
|
'{years} {years, plural, one {year} other {years} }',
|
|
19
21
|
};
|
|
22
|
+
|
|
20
23
|
export default messagesEn;
|
|
@@ -178,7 +178,8 @@ export const FullWidthImageSlider: React.FC<FullWidthImageSliderProps> = ({
|
|
|
178
178
|
|
|
179
179
|
<FullScreenImage
|
|
180
180
|
images={slice.images.map((image) => image.img)}
|
|
181
|
-
|
|
181
|
+
currentIndex={sliderIndex}
|
|
182
|
+
setCurrentIndex={setSliderIndex}
|
|
182
183
|
isOpen={isOpen}
|
|
183
184
|
onClose={() => setIsOpen(false)}
|
|
184
185
|
/>
|