@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.
Files changed (143) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/components/ContentGroup/ContentGroupTabs.js +10 -8
  3. package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  4. package/lib/components/Video/providers/Default.js +13 -7
  5. package/lib/components/Video/providers/Default.js.map +1 -1
  6. package/lib/components/Video/providers/get-provider.js +5 -0
  7. package/lib/components/Video/providers/get-provider.js.map +1 -1
  8. package/lib/hooks/helpers/getVariant.js.map +1 -1
  9. package/lib/utils/variant-handler.js +2 -1
  10. package/lib/utils/variant-handler.js.map +1 -1
  11. package/lib/variants/HeroImage/index.js +29 -0
  12. package/lib/variants/HeroImage/index.js.map +1 -0
  13. package/lib/variants/Infographic/Infographic.js +27 -0
  14. package/lib/variants/Infographic/Infographic.js.map +1 -0
  15. package/lib/variants/Infographic/index.js +41 -0
  16. package/lib/variants/Infographic/index.js.map +1 -0
  17. package/lib/variants/Infographic/useInfographic.js +43 -0
  18. package/lib/variants/Infographic/useInfographic.js.map +1 -0
  19. package/lib/variants/LongformGallery/LongformGallery.js +53 -0
  20. package/lib/variants/LongformGallery/LongformGallery.js.map +1 -0
  21. package/lib/variants/LongformGallery/LongformGalleryImage.js +71 -0
  22. package/lib/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
  23. package/lib/variants/LongformGallery/constants.js +19 -0
  24. package/lib/variants/LongformGallery/constants.js.map +1 -0
  25. package/lib/variants/LongformGallery/helpers/index.js +29 -0
  26. package/lib/variants/LongformGallery/helpers/index.js.map +1 -0
  27. package/lib/variants/LongformGallery/helpers/parseImageData.js +42 -0
  28. package/lib/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
  29. package/lib/variants/LongformGallery/helpers/separateImages.js +36 -0
  30. package/lib/variants/LongformGallery/helpers/separateImages.js.map +1 -0
  31. package/lib/variants/LongformGallery/helpers/shouldSkip.js +13 -0
  32. package/lib/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
  33. package/lib/variants/LongformGallery/index.js +43 -0
  34. package/lib/variants/LongformGallery/index.js.map +1 -0
  35. package/lib/variants/LongformGallery/useLongformGallery.js +58 -0
  36. package/lib/variants/LongformGallery/useLongformGallery.js.map +1 -0
  37. package/lib/variants/LongformRow/index.js +29 -0
  38. package/lib/variants/LongformRow/index.js.map +1 -0
  39. package/lib/variants/ParallaxImageTextRight/index.js +30 -0
  40. package/lib/variants/ParallaxImageTextRight/index.js.map +1 -0
  41. package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
  42. package/lib/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
  43. package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
  44. package/lib/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
  45. package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
  46. package/lib/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
  47. package/lib/variants/ThumbnailCarousel/index.js +15 -3
  48. package/lib/variants/ThumbnailCarousel/index.js.map +1 -1
  49. package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -9
  50. package/lib/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
  51. package/lib/variants/index.js +10 -0
  52. package/lib/variants/index.js.map +1 -1
  53. package/lib-es/components/ContentGroup/ContentGroupTabs.js +10 -8
  54. package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  55. package/lib-es/components/Video/providers/Default.js +14 -7
  56. package/lib-es/components/Video/providers/Default.js.map +1 -1
  57. package/lib-es/components/Video/providers/get-provider.js +2 -1
  58. package/lib-es/components/Video/providers/get-provider.js.map +1 -1
  59. package/lib-es/hooks/helpers/getVariant.js.map +1 -1
  60. package/lib-es/utils/variant-handler.js +2 -1
  61. package/lib-es/utils/variant-handler.js.map +1 -1
  62. package/lib-es/variants/HeroImage/index.js +10 -0
  63. package/lib-es/variants/HeroImage/index.js.map +1 -0
  64. package/lib-es/variants/Infographic/Infographic.js +20 -0
  65. package/lib-es/variants/Infographic/Infographic.js.map +1 -0
  66. package/lib-es/variants/Infographic/index.js +10 -0
  67. package/lib-es/variants/Infographic/index.js.map +1 -0
  68. package/lib-es/variants/Infographic/useInfographic.js +23 -0
  69. package/lib-es/variants/Infographic/useInfographic.js.map +1 -0
  70. package/lib-es/variants/LongformGallery/LongformGallery.js +40 -0
  71. package/lib-es/variants/LongformGallery/LongformGallery.js.map +1 -0
  72. package/lib-es/variants/LongformGallery/LongformGalleryImage.js +59 -0
  73. package/lib-es/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
  74. package/lib-es/variants/LongformGallery/constants.js +18 -0
  75. package/lib-es/variants/LongformGallery/constants.js.map +1 -0
  76. package/lib-es/variants/LongformGallery/helpers/index.js +5 -0
  77. package/lib-es/variants/LongformGallery/helpers/index.js.map +1 -0
  78. package/lib-es/variants/LongformGallery/helpers/parseImageData.js +26 -0
  79. package/lib-es/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
  80. package/lib-es/variants/LongformGallery/helpers/separateImages.js +25 -0
  81. package/lib-es/variants/LongformGallery/helpers/separateImages.js.map +1 -0
  82. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js +3 -0
  83. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
  84. package/lib-es/variants/LongformGallery/index.js +12 -0
  85. package/lib-es/variants/LongformGallery/index.js.map +1 -0
  86. package/lib-es/variants/LongformGallery/useLongformGallery.js +47 -0
  87. package/lib-es/variants/LongformGallery/useLongformGallery.js.map +1 -0
  88. package/lib-es/variants/LongformRow/index.js +10 -0
  89. package/lib-es/variants/LongformRow/index.js.map +1 -0
  90. package/lib-es/variants/ParallaxImageTextRight/index.js +11 -0
  91. package/lib-es/variants/ParallaxImageTextRight/index.js.map +1 -0
  92. package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js +8 -10
  93. package/lib-es/variants/ThumbnailCarousel/ThumbnailCarousel.js.map +1 -1
  94. package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +1 -5
  95. package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js.map +1 -1
  96. package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +10 -23
  97. package/lib-es/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js.map +1 -1
  98. package/lib-es/variants/ThumbnailCarousel/index.js +2 -2
  99. package/lib-es/variants/ThumbnailCarousel/index.js.map +1 -1
  100. package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
  101. package/lib-es/variants/ThumbnailCarousel/useThumbnailCarousel.js.map +1 -1
  102. package/lib-es/variants/index.js +10 -0
  103. package/lib-es/variants/index.js.map +1 -1
  104. package/package.json +2 -2
  105. package/src/components/ContentGroup/ContentGroupTabs.js +11 -8
  106. package/src/components/Video/providers/Default.js +12 -6
  107. package/src/components/Video/providers/get-provider.js +2 -1
  108. package/src/hooks/helpers/getVariant.js +1 -0
  109. package/src/utils/variant-handler.js +2 -1
  110. package/src/variants/HeroImage/index.js +8 -0
  111. package/src/variants/Infographic/Infographic.js +14 -0
  112. package/src/variants/Infographic/index.js +12 -0
  113. package/src/variants/Infographic/useInfographic.js +18 -0
  114. package/src/variants/LongformGallery/LongformGallery.js +47 -0
  115. package/src/variants/LongformGallery/LongformGalleryImage.js +65 -0
  116. package/src/variants/LongformGallery/constants.js +21 -0
  117. package/src/variants/LongformGallery/helpers/index.js +5 -0
  118. package/src/variants/LongformGallery/helpers/parseImageData.js +25 -0
  119. package/src/variants/LongformGallery/helpers/separateImages.js +38 -0
  120. package/src/variants/LongformGallery/helpers/shouldSkip.js +3 -0
  121. package/src/variants/LongformGallery/index.js +13 -0
  122. package/src/variants/LongformGallery/useLongformGallery.js +41 -0
  123. package/src/variants/LongformRow/index.js +8 -0
  124. package/src/variants/ParallaxImageTextRight/index.js +9 -0
  125. package/src/variants/ThumbnailCarousel/ThumbnailCarousel.js +6 -10
  126. package/src/variants/ThumbnailCarousel/ThumbnailImage/ThumbnailImage.js +4 -18
  127. package/src/variants/ThumbnailCarousel/ThumbnailImage/useThumbnailImage.js +11 -25
  128. package/src/variants/ThumbnailCarousel/index.js +4 -2
  129. package/src/variants/ThumbnailCarousel/useThumbnailCarousel.js +13 -8
  130. package/src/variants/index.js +10 -0
  131. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +2 -0
  132. package/tests/unit/src/components/Video/providers/__snapshots__/Default.test.js.snap +111 -108
  133. package/tests/unit/src/utils/variant-handler.test.js +9 -4
  134. package/tests/unit/src/variants/LongFormGallery/LongformGallery.test.js +42 -0
  135. package/tests/unit/src/variants/LongFormGallery/LongformGalleryImage.test.js +44 -0
  136. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGallery.test.js.snap +99 -0
  137. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap +51 -0
  138. package/tests/unit/src/variants/LongFormGallery/constants.js +37 -0
  139. package/tests/unit/src/variants/LongFormGallery/helpers/parseImageData.test.js +53 -0
  140. package/tests/unit/src/variants/LongFormGallery/helpers/separateImages.test.js +52 -0
  141. package/tests/unit/src/variants/LongFormGallery/helpers/shouldSkip.test.js +23 -0
  142. package/tests/unit/src/variants/LongFormGallery/useLongformGallery.test.js +36 -0
  143. 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
- <Player className={modifier} preload="none" autoPlay={autoplay} muted={autoplay}>
8
- <source src={url} type="video/mp4" />
9
- </Player>
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
- if (variants.has(key) && key !== 'array') throw new BlazeError(`Variant already exists`);
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,8 @@
1
+ const HeroImage = {
2
+ getSettings: componentSettings => ({
3
+ ...componentSettings,
4
+ modifier: 'hero-image'
5
+ })
6
+ };
7
+
8
+ export default HeroImage;
@@ -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,5 @@
1
+ import parseImageData from './parseImageData';
2
+ import separateImages from './separateImages';
3
+ import shouldSkip from './shouldSkip';
4
+
5
+ export { parseImageData, separateImages, shouldSkip };
@@ -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,3 @@
1
+ const shouldSkip = ids => !ids || (Array.isArray(ids) && !ids.length);
2
+
3
+ export default shouldSkip;
@@ -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;
@@ -0,0 +1,8 @@
1
+ const LongformRow = {
2
+ getSettings: componentSettings => ({
3
+ ...componentSettings,
4
+ modifier: 'longform-row'
5
+ })
6
+ };
7
+
8
+ export default LongformRow;
@@ -0,0 +1,9 @@
1
+ const ParallaxImageTextRight = {
2
+ getSettings: componentSettings => ({
3
+ ...componentSettings,
4
+ parallax: true,
5
+ modifier: 'image-children-right'
6
+ })
7
+ };
8
+
9
+ export default ParallaxImageTextRight;
@@ -8,8 +8,8 @@ const ThumbnailCarousel = props => {
8
8
  imageIds,
9
9
  selectedImageId,
10
10
  priorityLimit,
11
- mainImageButtonClick,
12
- thumbnailImageClick
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
- <div
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
- handleOnClick={thumbnailImageClick}
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
- loading,
8
- error,
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
- handleOnClick
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
- handleOnClick(imageId);
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
- imageRef,
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
- handleOnClick: PropTypes.func
54
+ scrollToImage: PropTypes.func
69
55
  };
70
56
 
71
57
  useThumbnailImage.defaultProps = {
72
- handleOnClick: () => {}
58
+ scrollToImage: null
73
59
  };
74
60
 
75
61
  export default useThumbnailImage;
@@ -1,10 +1,12 @@
1
- import ThumbnailCarouselComponent from './ThumbnailCarousel';
1
+ import dynamic from 'next/dynamic';
2
2
 
3
3
  const ThumbnailCarousel = {
4
4
  getSettings: componentSettings => ({
5
5
  ...componentSettings
6
6
  }),
7
- VariantComponent: ThumbnailCarouselComponent
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
- const newIndex = isLast ? 0 : selectedImageIndex + 1;
12
- setSelectedImageIndex(newIndex);
12
+ newIndex = isLast ? 0 : selectedImageIndex + 1;
13
13
  } else {
14
14
  const isFirst = selectedImageIndex === 0;
15
- const newIndex = isFirst ? imageIds.length - 1 : selectedImageIndex - 1;
16
- setSelectedImageIndex(newIndex);
15
+ newIndex = isFirst ? imageIds.length - 1 : selectedImageIndex - 1;
17
16
  }
17
+ scrollToImage(newIndex);
18
18
  };
19
19
 
20
- const thumbnailImageClick = id => {
21
- const newIndex = imageIds.indexOf(id);
22
- if (newIndex !== -1) setSelectedImageIndex(newIndex);
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
- thumbnailImageClick,
37
+ scrollToImage,
33
38
  mainImageButtonClick
34
39
  };
35
40
  };
@@ -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