@blaze-cms/react-page-builder 0.141.0-core-styles.21 → 0.141.0-core-styles.23
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/CHANGELOG.md +22 -0
- package/lib/components/ContentGroup/ContentGroupTabs.js +10 -8
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib/components/Video/providers/Default.js +13 -7
- package/lib/components/Video/providers/Default.js.map +1 -1
- package/lib/components/Video/providers/get-provider.js +5 -0
- package/lib/components/Video/providers/get-provider.js.map +1 -1
- package/lib/hooks/helpers/getVariant.js.map +1 -1
- package/lib/utils/variant-handler.js +2 -1
- package/lib/utils/variant-handler.js.map +1 -1
- package/lib/variants/HeroImage/index.js +29 -0
- package/lib/variants/HeroImage/index.js.map +1 -0
- package/lib/variants/Infographic/Infographic.js +27 -0
- package/lib/variants/Infographic/Infographic.js.map +1 -0
- package/lib/variants/Infographic/index.js +41 -0
- package/lib/variants/Infographic/index.js.map +1 -0
- package/lib/variants/Infographic/useInfographic.js +43 -0
- package/lib/variants/Infographic/useInfographic.js.map +1 -0
- package/lib/variants/LongformGallery/LongformGallery.js +53 -0
- package/lib/variants/LongformGallery/LongformGallery.js.map +1 -0
- package/lib/variants/LongformGallery/LongformGalleryImage.js +71 -0
- package/lib/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
- package/lib/variants/LongformGallery/constants.js +19 -0
- package/lib/variants/LongformGallery/constants.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/index.js +29 -0
- package/lib/variants/LongformGallery/helpers/index.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/parseImageData.js +42 -0
- package/lib/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/separateImages.js +36 -0
- package/lib/variants/LongformGallery/helpers/separateImages.js.map +1 -0
- package/lib/variants/LongformGallery/helpers/shouldSkip.js +13 -0
- package/lib/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
- package/lib/variants/LongformGallery/index.js +43 -0
- package/lib/variants/LongformGallery/index.js.map +1 -0
- package/lib/variants/LongformGallery/useLongformGallery.js +58 -0
- package/lib/variants/LongformGallery/useLongformGallery.js.map +1 -0
- package/lib/variants/LongformRow/index.js +29 -0
- package/lib/variants/LongformRow/index.js.map +1 -0
- package/lib/variants/ParallaxImageTextRight/index.js +30 -0
- package/lib/variants/ParallaxImageTextRight/index.js.map +1 -0
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
- package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/index.js +15 -3
- package/lib/variants/ThumbnailCarousel/index.js.map +1 -1
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -9
- package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/lib/variants/index.js +10 -0
- package/lib/variants/index.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupTabs.js +10 -8
- package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib-es/components/Video/providers/Default.js +14 -7
- package/lib-es/components/Video/providers/Default.js.map +1 -1
- package/lib-es/components/Video/providers/get-provider.js +2 -1
- package/lib-es/components/Video/providers/get-provider.js.map +1 -1
- package/lib-es/hooks/helpers/getVariant.js.map +1 -1
- package/lib-es/utils/variant-handler.js +2 -1
- package/lib-es/utils/variant-handler.js.map +1 -1
- package/lib-es/variants/HeroImage/index.js +10 -0
- package/lib-es/variants/HeroImage/index.js.map +1 -0
- package/lib-es/variants/Infographic/Infographic.js +20 -0
- package/lib-es/variants/Infographic/Infographic.js.map +1 -0
- package/lib-es/variants/Infographic/index.js +10 -0
- package/lib-es/variants/Infographic/index.js.map +1 -0
- package/lib-es/variants/Infographic/useInfographic.js +23 -0
- package/lib-es/variants/Infographic/useInfographic.js.map +1 -0
- package/lib-es/variants/LongformGallery/LongformGallery.js +40 -0
- package/lib-es/variants/LongformGallery/LongformGallery.js.map +1 -0
- package/lib-es/variants/LongformGallery/LongformGalleryImage.js +59 -0
- package/lib-es/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
- package/lib-es/variants/LongformGallery/constants.js +18 -0
- package/lib-es/variants/LongformGallery/constants.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/index.js +5 -0
- package/lib-es/variants/LongformGallery/helpers/index.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/parseImageData.js +26 -0
- package/lib-es/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/separateImages.js +25 -0
- package/lib-es/variants/LongformGallery/helpers/separateImages.js.map +1 -0
- package/lib-es/variants/LongformGallery/helpers/shouldSkip.js +3 -0
- package/lib-es/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
- package/lib-es/variants/LongformGallery/index.js +12 -0
- package/lib-es/variants/LongformGallery/index.js.map +1 -0
- package/lib-es/variants/LongformGallery/useLongformGallery.js +47 -0
- package/lib-es/variants/LongformGallery/useLongformGallery.js.map +1 -0
- package/lib-es/variants/LongformRow/index.js +10 -0
- package/lib-es/variants/LongformRow/index.js.map +1 -0
- package/lib-es/variants/ParallaxImageTextRight/index.js +11 -0
- package/lib-es/variants/ParallaxImageTextRight/index.js.map +1 -0
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
- package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
- package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/index.js +2 -2
- package/lib-es/variants/ThumbnailCarousel/index.js.map +1 -1
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
- package/lib-es/variants/index.js +10 -0
- package/lib-es/variants/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/ContentGroup/ContentGroupTabs.js +11 -8
- package/src/components/Video/providers/Default.js +12 -6
- package/src/components/Video/providers/get-provider.js +2 -1
- package/src/hooks/helpers/getVariant.js +1 -0
- package/src/utils/variant-handler.js +2 -1
- package/src/variants/HeroImage/index.js +8 -0
- package/src/variants/Infographic/Infographic.js +14 -0
- package/src/variants/Infographic/index.js +12 -0
- package/src/variants/Infographic/useInfographic.js +18 -0
- package/src/variants/LongformGallery/LongformGallery.js +47 -0
- package/src/variants/LongformGallery/LongformGalleryImage.js +65 -0
- package/src/variants/LongformGallery/constants.js +21 -0
- package/src/variants/LongformGallery/helpers/index.js +5 -0
- package/src/variants/LongformGallery/helpers/parseImageData.js +25 -0
- package/src/variants/LongformGallery/helpers/separateImages.js +38 -0
- package/src/variants/LongformGallery/helpers/shouldSkip.js +3 -0
- package/src/variants/LongformGallery/index.js +13 -0
- package/src/variants/LongformGallery/useLongformGallery.js +41 -0
- package/src/variants/LongformRow/index.js +8 -0
- package/src/variants/ParallaxImageTextRight/index.js +9 -0
- package/src/variants/ThumbnailCarousel/ThumbnailCarousel.js +6 -10
- package/src/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +4 -18
- package/src/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +11 -25
- package/src/variants/ThumbnailCarousel/index.js +4 -2
- package/src/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
- package/src/variants/index.js +10 -0
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +2 -0
- package/tests/unit/src/components/Video/providers/__snapshots__/Default.test.js.snap +111 -108
- package/tests/unit/src/utils/variant-handler.test.js +9 -4
- package/tests/unit/src/variants/LongFormGallery/LongformGallery.test.js +42 -0
- package/tests/unit/src/variants/LongFormGallery/LongformGalleryImage.test.js +44 -0
- package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGallery.test.js.snap +99 -0
- package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap +51 -0
- package/tests/unit/src/variants/LongFormGallery/constants.js +37 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/parseImageData.test.js +53 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/separateImages.test.js +52 -0
- package/tests/unit/src/variants/LongFormGallery/helpers/shouldSkip.test.js +23 -0
- package/tests/unit/src/variants/LongFormGallery/useLongformGallery.test.js +36 -0
- package/tests/unit/src/variants/ThumbnailCarousel/__snapshots__/ThumbnailCarousel.test.js.snap +10 -15
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Player } from 'video-react';
|
|
4
|
+
import { VIDEO_WRAPPER_CLASS_NAME } from '../../../constants';
|
|
5
|
+
|
|
4
6
|
// import 'video-react/styles/scss/video-react.scss';
|
|
5
7
|
|
|
6
|
-
const Default = ({ modifier, url, autoplay }) => (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
8
|
+
const Default = ({ modifier, url, autoplay, loop }) => (
|
|
9
|
+
<div className={VIDEO_WRAPPER_CLASS_NAME}>
|
|
10
|
+
<Player className={modifier} preload="none" autoPlay={autoplay} loop={loop} muted={autoplay}>
|
|
11
|
+
<source src={url} />
|
|
12
|
+
</Player>
|
|
13
|
+
</div>
|
|
10
14
|
);
|
|
11
15
|
|
|
12
16
|
Default.propTypes = {
|
|
13
17
|
url: PropTypes.string.isRequired,
|
|
14
18
|
modifier: PropTypes.string,
|
|
15
|
-
autoplay: PropTypes.bool
|
|
19
|
+
autoplay: PropTypes.bool,
|
|
20
|
+
loop: PropTypes.bool
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
Default.defaultProps = {
|
|
19
24
|
modifier: null,
|
|
20
|
-
autoplay: false
|
|
25
|
+
autoplay: false,
|
|
26
|
+
loop: false
|
|
21
27
|
};
|
|
22
28
|
|
|
23
29
|
export default Default;
|
|
@@ -8,7 +8,8 @@ const SUPPORTED_PROVIDERS = {
|
|
|
8
8
|
import(/* webpackChunkName: "blazePbVideoJWPlayer" */ './JWPlayer/JWPlayerProvider')
|
|
9
9
|
),
|
|
10
10
|
vimeo: dynamic(() => import(/* webpackChunkName: "blazePbVideoVimeo" */ './Vimeo/VimeoProvider')),
|
|
11
|
-
default: dynamic(() => import(/* webpackChunkName: "blazePbVideoDefault" */ './Default'))
|
|
11
|
+
default: dynamic(() => import(/* webpackChunkName: "blazePbVideoDefault" */ './Default')),
|
|
12
|
+
html: dynamic(() => import(/* webpackChunkName: "blazePbVideoDefault" */ './Default'))
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
function getProvider(provider) {
|
|
@@ -3,6 +3,7 @@ import { variantHandler } from '../../utils';
|
|
|
3
3
|
export default function getVariant(settings) {
|
|
4
4
|
const { variant } = settings;
|
|
5
5
|
if (!variant) return [null, {}];
|
|
6
|
+
|
|
6
7
|
const { VariantComponent, getSettings } = variantHandler.get(variant) || {};
|
|
7
8
|
const variantSettings =
|
|
8
9
|
!!getSettings && typeof getSettings === 'function' ? getSettings(settings) : settings;
|
|
@@ -18,7 +18,8 @@ function variantMapHandler() {
|
|
|
18
18
|
|
|
19
19
|
function validate(key, variant) {
|
|
20
20
|
if (!key || !variant) throw new BlazeError('Variant requires key and component');
|
|
21
|
-
|
|
21
|
+
// eslint-disable-next-line no-console
|
|
22
|
+
if (variants.has(key) && key !== 'array') console.warn(`Variant already exists: ${key}`); // todo: restore error // throw new BlazeError(`Variant already exists: ${key}`);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
return {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import useInfographic from './useInfographic';
|
|
3
|
+
|
|
4
|
+
const Infographic = props => {
|
|
5
|
+
const { contentRef, id, className, tabId, children } = useInfographic(props);
|
|
6
|
+
|
|
7
|
+
return (
|
|
8
|
+
<div ref={contentRef} id={id} className={className} role="tabpanel" aria-labelledby={tabId}>
|
|
9
|
+
{children}
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default Infographic;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import dynamic from 'next/dynamic';
|
|
2
|
+
|
|
3
|
+
const Infographic = {
|
|
4
|
+
getSettings: componentSettings => ({
|
|
5
|
+
...componentSettings
|
|
6
|
+
}),
|
|
7
|
+
VariantComponent: dynamic(() =>
|
|
8
|
+
import(/* webpackChunkName: "blazePbVariantInfographic" */ './Infographic')
|
|
9
|
+
)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default Infographic;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
2
|
+
|
|
3
|
+
const useInfographic = ({ className: _className, ...props }) => {
|
|
4
|
+
const [isIntersecting, contentRef] = useInView({
|
|
5
|
+
once: true,
|
|
6
|
+
offset: '200px'
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const className = `${_className} infographic${isIntersecting ? ' infographic__active' : ''}`;
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
...props,
|
|
13
|
+
className,
|
|
14
|
+
contentRef
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default useInfographic;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withTitle } from '../../HOC';
|
|
3
|
+
import useLongformGallery from './useLongformGallery';
|
|
4
|
+
import LongformGalleryImage from './LongformGalleryImage';
|
|
5
|
+
|
|
6
|
+
const LongformGallery = props => {
|
|
7
|
+
const {
|
|
8
|
+
loading,
|
|
9
|
+
error,
|
|
10
|
+
groupedImages,
|
|
11
|
+
shouldDisplayCaption,
|
|
12
|
+
caption,
|
|
13
|
+
handleImageOnClick
|
|
14
|
+
} = useLongformGallery(props);
|
|
15
|
+
|
|
16
|
+
if (loading || error || !groupedImages.length) return null;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div className="longform-gallery" data-testid="longform-gallery">
|
|
20
|
+
{groupedImages.map((imageGroup, i) => (
|
|
21
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
22
|
+
<div key={i} data-testid="grouped-images" className="longform-gallery__images">
|
|
23
|
+
{imageGroup.map(secondaryImage => (
|
|
24
|
+
<LongformGalleryImage
|
|
25
|
+
key={secondaryImage.id}
|
|
26
|
+
{...secondaryImage}
|
|
27
|
+
numberOfImages={imageGroup.length}
|
|
28
|
+
className={
|
|
29
|
+
imageGroup.length > 2
|
|
30
|
+
? 'longform-gallery__images__image secondary-image'
|
|
31
|
+
: 'longform-gallery__images__image main-image'
|
|
32
|
+
}
|
|
33
|
+
handleImageOnClick={handleImageOnClick}
|
|
34
|
+
/>
|
|
35
|
+
))}
|
|
36
|
+
</div>
|
|
37
|
+
))}
|
|
38
|
+
{shouldDisplayCaption && (
|
|
39
|
+
<div className="carousel__details" data-testid="carousel-details">
|
|
40
|
+
<div className="caption">{caption}</div>
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default withTitle(LongformGallery);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Head from 'next/head';
|
|
4
|
+
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
5
|
+
import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
|
|
6
|
+
import { IN_VIEW_CONFIG } from './constants';
|
|
7
|
+
|
|
8
|
+
const LongformGalleryImage = ({
|
|
9
|
+
id,
|
|
10
|
+
url,
|
|
11
|
+
caption,
|
|
12
|
+
altText,
|
|
13
|
+
priority,
|
|
14
|
+
className,
|
|
15
|
+
numberOfImages,
|
|
16
|
+
handleImageOnClick,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);
|
|
20
|
+
const shouldRender = priority || isIntersecting;
|
|
21
|
+
const HeadComponent = priority ? Head : null;
|
|
22
|
+
const sizeKey = `carousel:longform:${numberOfImages}`;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div ref={outerRef} className={`${className}`}>
|
|
26
|
+
<div
|
|
27
|
+
role="button"
|
|
28
|
+
className="longform-gallery__images__image__container"
|
|
29
|
+
data-testid="longform-gallery__images__image__container"
|
|
30
|
+
onClick={() => handleImageOnClick(id)}>
|
|
31
|
+
{shouldRender && (
|
|
32
|
+
<ResponsiveImage
|
|
33
|
+
sizeKey={sizeKey}
|
|
34
|
+
role="button"
|
|
35
|
+
src={url}
|
|
36
|
+
alt={altText}
|
|
37
|
+
priority={priority}
|
|
38
|
+
HeadComponent={HeadComponent}
|
|
39
|
+
{...props}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
{!!caption && (
|
|
44
|
+
<div
|
|
45
|
+
className="longform-gallery__images__image__details"
|
|
46
|
+
data-testid="longform-gallery__images__image__details">
|
|
47
|
+
<div className="longform-gallery__images__image__details__caption">{caption}</div>
|
|
48
|
+
</div>
|
|
49
|
+
)}
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
LongformGalleryImage.propTypes = {
|
|
55
|
+
id: PropTypes.string.isRequired,
|
|
56
|
+
url: PropTypes.string.isRequired,
|
|
57
|
+
caption: PropTypes.string.isRequired,
|
|
58
|
+
numberOfImages: PropTypes.number.isRequired,
|
|
59
|
+
altText: PropTypes.string.isRequired,
|
|
60
|
+
priority: PropTypes.bool.isRequired,
|
|
61
|
+
className: PropTypes.string.isRequired,
|
|
62
|
+
handleImageOnClick: PropTypes.func.isRequired
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default LongformGalleryImage;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
|
|
3
|
+
const GET_IMAGES_QUERY = gql`
|
|
4
|
+
query getImages($where: JSON!) {
|
|
5
|
+
getImages: getFiles(where: $where) {
|
|
6
|
+
id
|
|
7
|
+
url
|
|
8
|
+
data
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const PROPS_TO_CHECK = ['altText', 'caption', 'hrefUrl', 'credits'];
|
|
14
|
+
|
|
15
|
+
const IN_VIEW_CONFIG = {
|
|
16
|
+
once: true,
|
|
17
|
+
offset: '200px',
|
|
18
|
+
bottomOffset: '-200px'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { GET_IMAGES_QUERY, IN_VIEW_CONFIG, PROPS_TO_CHECK };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import parseHTML from 'html-react-parser';
|
|
2
|
+
import { PROPS_TO_CHECK } from '../constants';
|
|
3
|
+
|
|
4
|
+
const parseImageData = (image, index, priorityLimit, shouldDisplayCaption) => {
|
|
5
|
+
const { data = {} } = image;
|
|
6
|
+
const parsedData = {};
|
|
7
|
+
|
|
8
|
+
PROPS_TO_CHECK.forEach(dataKey => {
|
|
9
|
+
const value = data && data[dataKey];
|
|
10
|
+
if (dataKey === 'caption') {
|
|
11
|
+
parsedData[dataKey] = shouldDisplayCaption && !!value ? parseHTML(value) : '';
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
parsedData[dataKey] = value || '';
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
...parsedData,
|
|
19
|
+
id: image.id,
|
|
20
|
+
url: image.url,
|
|
21
|
+
priority: index < priorityLimit
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default parseImageData;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import parseImageData from './parseImageData';
|
|
2
|
+
|
|
3
|
+
const buildImageGroups = (images, priorityLimit, shouldDisplayCaption) => {
|
|
4
|
+
const imageGroups = [];
|
|
5
|
+
let imageGroupIndex = 0;
|
|
6
|
+
const isDivisible = images.length % 3 === 0;
|
|
7
|
+
|
|
8
|
+
images.forEach((image, index) => {
|
|
9
|
+
if (!imageGroups[imageGroupIndex])
|
|
10
|
+
imageGroups[imageGroupIndex] = [
|
|
11
|
+
parseImageData(image, index, priorityLimit, shouldDisplayCaption)
|
|
12
|
+
];
|
|
13
|
+
else
|
|
14
|
+
imageGroups[imageGroupIndex].push(
|
|
15
|
+
parseImageData(image, index, priorityLimit, shouldDisplayCaption)
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (isDivisible) {
|
|
19
|
+
if (imageGroups[imageGroupIndex].length >= 3) imageGroupIndex += 1;
|
|
20
|
+
} else {
|
|
21
|
+
if (imageGroupIndex === 0 && imageGroups[imageGroupIndex].length >= 2) {
|
|
22
|
+
imageGroupIndex += 1;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (imageGroups[imageGroupIndex].length >= 3) imageGroupIndex += 1;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return imageGroups;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const separateImages = (images, priorityLimit, shouldDisplayCaption) => {
|
|
33
|
+
if (!images || !images.length) return [];
|
|
34
|
+
|
|
35
|
+
return buildImageGroups(images, priorityLimit, shouldDisplayCaption);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default separateImages;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import dynamic from 'next/dynamic';
|
|
2
|
+
|
|
3
|
+
const LongformGallery = {
|
|
4
|
+
VariantComponent: dynamic(() =>
|
|
5
|
+
import(/* webpackChunkName: "blazePbVariantLongformGallery" */ './LongformGallery')
|
|
6
|
+
),
|
|
7
|
+
getSettings: componentSettings => ({
|
|
8
|
+
...componentSettings,
|
|
9
|
+
modifier: 'longformGallery'
|
|
10
|
+
})
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default LongformGallery;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useQuery } from '@apollo/client';
|
|
2
|
+
import { GET_IMAGES_QUERY } from './constants';
|
|
3
|
+
import { separateImages, shouldSkip } from './helpers';
|
|
4
|
+
|
|
5
|
+
const useLongformGallery = ({
|
|
6
|
+
imageIds = [],
|
|
7
|
+
priorityLimit = 0,
|
|
8
|
+
caption = '',
|
|
9
|
+
shouldDisplayCaption = false,
|
|
10
|
+
enableLightbox = false,
|
|
11
|
+
toggleModal = () => {},
|
|
12
|
+
handleSelectedImage = () => {}
|
|
13
|
+
}) => {
|
|
14
|
+
const skip = shouldSkip(imageIds);
|
|
15
|
+
|
|
16
|
+
const { data, loading, error } = useQuery(GET_IMAGES_QUERY, {
|
|
17
|
+
variables: { where: { id: { _in: imageIds } } },
|
|
18
|
+
skip
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const { getImages } = data || {};
|
|
22
|
+
|
|
23
|
+
const groupedImages = separateImages(getImages, priorityLimit, shouldDisplayCaption);
|
|
24
|
+
|
|
25
|
+
const handleImageOnClick = clickedImageId => {
|
|
26
|
+
if (!enableLightbox) return;
|
|
27
|
+
toggleModal();
|
|
28
|
+
handleSelectedImage(clickedImageId);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
loading,
|
|
33
|
+
error,
|
|
34
|
+
shouldDisplayCaption,
|
|
35
|
+
caption,
|
|
36
|
+
groupedImages,
|
|
37
|
+
handleImageOnClick
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default useLongformGallery;
|
|
@@ -8,8 +8,8 @@ const ThumbnailCarousel = props => {
|
|
|
8
8
|
imageIds,
|
|
9
9
|
selectedImageId,
|
|
10
10
|
priorityLimit,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
scrollToImage,
|
|
12
|
+
mainImageButtonClick
|
|
13
13
|
} = useThumbnailCarousel(props);
|
|
14
14
|
|
|
15
15
|
return (
|
|
@@ -22,12 +22,7 @@ const ThumbnailCarousel = props => {
|
|
|
22
22
|
onClick={() => mainImageButtonClick()}>
|
|
23
23
|
<div className="arrow arrow--left" />
|
|
24
24
|
</div>
|
|
25
|
-
<
|
|
26
|
-
className="thumbnail-carousel__main_image_container__main-image"
|
|
27
|
-
data-testid="thumbnail-main-image"
|
|
28
|
-
ref={thumbnailsListRef}>
|
|
29
|
-
<ThumbnailImage {...props} priority imageId={selectedImageId} />
|
|
30
|
-
</div>
|
|
25
|
+
<ThumbnailImage {...props} priority imageId={selectedImageId} />
|
|
31
26
|
<div
|
|
32
27
|
id="next-button"
|
|
33
28
|
className="thumbnail-carousel__main_image_container__button next"
|
|
@@ -36,15 +31,16 @@ const ThumbnailCarousel = props => {
|
|
|
36
31
|
<div className="arrow arrow--right" />
|
|
37
32
|
</div>
|
|
38
33
|
</div>
|
|
39
|
-
<div className="thumbnail-carousel__list">
|
|
34
|
+
<div className="thumbnail-carousel__list" ref={thumbnailsListRef}>
|
|
40
35
|
{imageIds.map((imageId, index) => (
|
|
41
36
|
<ThumbnailImage
|
|
42
37
|
{...props}
|
|
43
38
|
key={imageId}
|
|
39
|
+
imageIndex={index}
|
|
44
40
|
priority={index < priorityLimit}
|
|
45
41
|
imageId={imageId}
|
|
46
42
|
selectedImageId={selectedImageId}
|
|
47
|
-
|
|
43
|
+
scrollToImage={scrollToImage}
|
|
48
44
|
/>
|
|
49
45
|
))}
|
|
50
46
|
</div>
|
|
@@ -3,33 +3,19 @@ import LazyImage from '../../../components/LazyImage';
|
|
|
3
3
|
import useThumbnailImage from './useThumbnailImage';
|
|
4
4
|
|
|
5
5
|
const ThumbnailImage = props => {
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
className,
|
|
10
|
-
imageRef,
|
|
11
|
-
imageUrl,
|
|
12
|
-
altText,
|
|
13
|
-
priority,
|
|
14
|
-
handleClick,
|
|
15
|
-
handleEnableLightbox
|
|
16
|
-
} = useThumbnailImage(props);
|
|
6
|
+
const { loading, error, className, imageUrl, altText, priority, handleClick } = useThumbnailImage(
|
|
7
|
+
props
|
|
8
|
+
);
|
|
17
9
|
|
|
18
10
|
if (error) return error.message;
|
|
19
11
|
if (loading) return null;
|
|
20
12
|
|
|
21
13
|
return (
|
|
22
|
-
<div
|
|
23
|
-
ref={imageRef}
|
|
24
|
-
className={className}
|
|
25
|
-
onClick={handleClick}
|
|
26
|
-
role="button"
|
|
27
|
-
data-testid="thumbnail-image">
|
|
14
|
+
<div className={className} onClick={handleClick} role="button" data-testid="thumbnail-image">
|
|
28
15
|
<LazyImage
|
|
29
16
|
src={imageUrl}
|
|
30
17
|
alt={altText}
|
|
31
18
|
sizeKey="carousel"
|
|
32
|
-
onClick={handleEnableLightbox}
|
|
33
19
|
role="button"
|
|
34
20
|
priority={priority}
|
|
35
21
|
/>
|
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
1
|
import PropTypes from 'prop-types';
|
|
3
2
|
import { useGetImages } from '../../../hooks';
|
|
4
3
|
import { getImageData } from '../../../utils';
|
|
5
4
|
|
|
6
5
|
const useThumbnailImage = ({
|
|
7
6
|
imageId,
|
|
7
|
+
imageIndex,
|
|
8
8
|
enableLightbox,
|
|
9
9
|
toggleModal,
|
|
10
10
|
handleSelectedImage,
|
|
11
11
|
priority,
|
|
12
12
|
selectedImageId,
|
|
13
|
-
|
|
13
|
+
scrollToImage
|
|
14
14
|
}) => {
|
|
15
|
-
const imageRef = useRef(null);
|
|
16
|
-
const isSelected = selectedImageId === imageId;
|
|
17
15
|
const { data = {}, loading, error } = useGetImages(imageId);
|
|
18
16
|
|
|
19
|
-
useEffect(
|
|
20
|
-
() => {
|
|
21
|
-
if (imageRef.current && isSelected) {
|
|
22
|
-
imageRef.current.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
[isSelected]
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const handleEnableLightbox = () => {
|
|
29
|
-
if (!enableLightbox) return;
|
|
30
|
-
toggleModal();
|
|
31
|
-
handleSelectedImage(imageId);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
17
|
const handleClick = () => {
|
|
35
|
-
|
|
18
|
+
if (scrollToImage) scrollToImage(imageIndex);
|
|
19
|
+
else if (enableLightbox) {
|
|
20
|
+
toggleModal();
|
|
21
|
+
handleSelectedImage(imageId);
|
|
22
|
+
}
|
|
36
23
|
};
|
|
37
24
|
|
|
38
25
|
const { url: imageUrl = '', data: imageData = {} } = data.getFile || {
|
|
@@ -49,12 +36,11 @@ const useThumbnailImage = ({
|
|
|
49
36
|
loading,
|
|
50
37
|
error,
|
|
51
38
|
className,
|
|
52
|
-
|
|
39
|
+
imageId,
|
|
53
40
|
imageUrl,
|
|
54
41
|
altText,
|
|
55
42
|
priority,
|
|
56
|
-
handleClick
|
|
57
|
-
handleEnableLightbox
|
|
43
|
+
handleClick
|
|
58
44
|
};
|
|
59
45
|
};
|
|
60
46
|
|
|
@@ -65,11 +51,11 @@ useThumbnailImage.propTypes = {
|
|
|
65
51
|
toggleModal: PropTypes.func.isRequired,
|
|
66
52
|
handleSelectedImage: PropTypes.func.isRequired,
|
|
67
53
|
priority: PropTypes.bool.isRequired,
|
|
68
|
-
|
|
54
|
+
scrollToImage: PropTypes.func
|
|
69
55
|
};
|
|
70
56
|
|
|
71
57
|
useThumbnailImage.defaultProps = {
|
|
72
|
-
|
|
58
|
+
scrollToImage: null
|
|
73
59
|
};
|
|
74
60
|
|
|
75
61
|
export default useThumbnailImage;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dynamic from 'next/dynamic';
|
|
2
2
|
|
|
3
3
|
const ThumbnailCarousel = {
|
|
4
4
|
getSettings: componentSettings => ({
|
|
5
5
|
...componentSettings
|
|
6
6
|
}),
|
|
7
|
-
VariantComponent:
|
|
7
|
+
VariantComponent: dynamic(() =>
|
|
8
|
+
import(/* webpackChunkName: "blazePbVariantThumbnailCarousel" */ './ThumbnailCarousel')
|
|
9
|
+
)
|
|
8
10
|
};
|
|
9
11
|
|
|
10
12
|
export default ThumbnailCarousel;
|
|
@@ -6,20 +6,25 @@ const useThumbnailCarousel = ({ imageIds, priorityLimit, ...props }) => {
|
|
|
6
6
|
const selectedImageId = imageIds[selectedImageIndex];
|
|
7
7
|
|
|
8
8
|
const mainImageButtonClick = next => {
|
|
9
|
+
let newIndex;
|
|
9
10
|
if (next) {
|
|
10
11
|
const isLast = imageIds.length - 1 === selectedImageIndex;
|
|
11
|
-
|
|
12
|
-
setSelectedImageIndex(newIndex);
|
|
12
|
+
newIndex = isLast ? 0 : selectedImageIndex + 1;
|
|
13
13
|
} else {
|
|
14
14
|
const isFirst = selectedImageIndex === 0;
|
|
15
|
-
|
|
16
|
-
setSelectedImageIndex(newIndex);
|
|
15
|
+
newIndex = isFirst ? imageIds.length - 1 : selectedImageIndex - 1;
|
|
17
16
|
}
|
|
17
|
+
scrollToImage(newIndex);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const scrollToImage = newIndex => {
|
|
21
|
+
if (thumbnailsListRef.current && selectedImageIndex !== newIndex) {
|
|
22
|
+
thumbnailsListRef.current.scrollTo({
|
|
23
|
+
left: 150 * newIndex,
|
|
24
|
+
behavior: 'smooth'
|
|
25
|
+
});
|
|
26
|
+
setSelectedImageIndex(newIndex);
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
29
|
|
|
25
30
|
return {
|
|
@@ -29,7 +34,7 @@ const useThumbnailCarousel = ({ imageIds, priorityLimit, ...props }) => {
|
|
|
29
34
|
selectedImageIndex,
|
|
30
35
|
thumbnailsListRef,
|
|
31
36
|
priorityLimit,
|
|
32
|
-
|
|
37
|
+
scrollToImage,
|
|
33
38
|
mainImageButtonClick
|
|
34
39
|
};
|
|
35
40
|
};
|
package/src/variants/index.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
import heroImage from './HeroImage';
|
|
2
|
+
import infographic from './Infographic';
|
|
3
|
+
import longformGallery from './LongformGallery';
|
|
4
|
+
import longformRow from './LongformRow';
|
|
5
|
+
import parallaxImageTextRight from './ParallaxImageTextRight';
|
|
1
6
|
import thumbnailCarousel from './ThumbnailCarousel';
|
|
2
7
|
|
|
3
8
|
export default {
|
|
9
|
+
heroImage,
|
|
10
|
+
infographic,
|
|
11
|
+
longformGallery,
|
|
12
|
+
longformRow,
|
|
13
|
+
parallaxImageTextRight,
|
|
4
14
|
thumbnailCarousel
|
|
5
15
|
};
|
|
@@ -36,6 +36,7 @@ exports[`ContentGroupTabs component should match snapshot and render sidepanel c
|
|
|
36
36
|
class="content-group-sidepanel__content-section"
|
|
37
37
|
id="section-one"
|
|
38
38
|
role="tabpanel"
|
|
39
|
+
tabid="tab-section-one"
|
|
39
40
|
>
|
|
40
41
|
<div>
|
|
41
42
|
section one
|
|
@@ -81,6 +82,7 @@ exports[`ContentGroupTabs component should match snapshot and render tabs conten
|
|
|
81
82
|
class="content-group-tabs__content-section"
|
|
82
83
|
id="section-one"
|
|
83
84
|
role="tabpanel"
|
|
85
|
+
tabid="tab-section-one"
|
|
84
86
|
>
|
|
85
87
|
<div>
|
|
86
88
|
section one
|