@magento/pagebuilder 7.1.0-beta.1 → 7.2.0-beta.1

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 (48) hide show
  1. package/lib/ContentTypes/Banner/__tests__/__snapshots__/banner.shimmer.spec.js.snap +0 -1
  2. package/lib/ContentTypes/Banner/__tests__/__snapshots__/banner.spec.js.snap +0 -1
  3. package/lib/ContentTypes/Banner/banner.js +23 -4
  4. package/lib/ContentTypes/Banner/banner.shimmer.js +13 -2
  5. package/lib/ContentTypes/Banner/configAggregator.js +4 -2
  6. package/lib/ContentTypes/Column/column.js +13 -2
  7. package/lib/ContentTypes/Column/configAggregator.js +3 -1
  8. package/lib/ContentTypes/DynamicBlock/__tests__/__snapshots__/dynamicBlock.ce.spec.js.snap +3 -0
  9. package/lib/ContentTypes/DynamicBlock/__tests__/__snapshots__/dynamicBlock.ee.spec.js.snap +93 -0
  10. package/lib/ContentTypes/DynamicBlock/__tests__/__snapshots__/dynamicBlock.shimmer.spec.js.snap +39 -0
  11. package/lib/ContentTypes/DynamicBlock/__tests__/configAggregator.spec.js +49 -0
  12. package/lib/ContentTypes/DynamicBlock/__tests__/dynamicBlock.ce.spec.js +17 -0
  13. package/lib/ContentTypes/DynamicBlock/__tests__/dynamicBlock.ee.spec.js +70 -0
  14. package/lib/ContentTypes/DynamicBlock/__tests__/dynamicBlock.shimmer.spec.js +20 -0
  15. package/lib/ContentTypes/DynamicBlock/configAggregator.js +25 -0
  16. package/lib/ContentTypes/DynamicBlock/dynamicBlock.ce.js +5 -0
  17. package/lib/ContentTypes/DynamicBlock/dynamicBlock.ee.js +134 -0
  18. package/lib/ContentTypes/DynamicBlock/dynamicBlock.module.css +8 -0
  19. package/lib/ContentTypes/DynamicBlock/dynamicBlock.shimmer.js +134 -0
  20. package/lib/ContentTypes/DynamicBlock/dynamicBlock.shimmer.module.css +26 -0
  21. package/lib/ContentTypes/DynamicBlock/index.js +2 -0
  22. package/lib/ContentTypes/Image/__tests__/__snapshots__/image.shimmer.spec.js.snap +139 -0
  23. package/lib/ContentTypes/Image/__tests__/configAggregator.spec.js +28 -10
  24. package/lib/ContentTypes/Image/__tests__/image.shimmer.spec.js +122 -0
  25. package/lib/ContentTypes/Image/__tests__/image.spec.js +5 -5
  26. package/lib/ContentTypes/Image/configAggregator.js +51 -18
  27. package/lib/ContentTypes/Image/image.js +25 -9
  28. package/lib/ContentTypes/Image/image.module.css +2 -0
  29. package/lib/ContentTypes/Image/image.shimmer.js +191 -0
  30. package/lib/ContentTypes/Image/image.shimmer.module.css +5 -0
  31. package/lib/ContentTypes/Image/index.js +1 -0
  32. package/lib/ContentTypes/Row/__tests__/configAggregator.spec.js +18 -0
  33. package/lib/ContentTypes/Row/__tests__/row.spec.js +2 -1
  34. package/lib/ContentTypes/Row/configAggregator.js +13 -3
  35. package/lib/ContentTypes/Row/row.js +26 -3
  36. package/lib/ContentTypes/Slider/configAggregator.js +3 -2
  37. package/lib/ContentTypes/Slider/slider.js +21 -2
  38. package/lib/ContentTypes/Slider/slider.shimmer.js +13 -2
  39. package/lib/ContentTypes/TabItem/configAggregator.js +4 -2
  40. package/lib/ContentTypes/TabItem/tabItem.js +13 -2
  41. package/lib/ContentTypes/Tabs/configAggregator.js +4 -2
  42. package/lib/ContentTypes/Tabs/tabs.js +19 -2
  43. package/lib/__tests__/parseStorageHtml.spec.js +35 -0
  44. package/lib/__tests__/utils.spec.js +21 -1
  45. package/lib/config.js +10 -2
  46. package/lib/parseStorageHtml.js +32 -0
  47. package/lib/utils.js +46 -0
  48. package/package.json +8 -8
@@ -25,7 +25,6 @@ exports[`renders a BannerShimmer component with minHeight 1`] = `
25
25
  "borderColor": undefined,
26
26
  "borderRadius": undefined,
27
27
  "borderWidth": undefined,
28
- "minHeight": "400px",
29
28
  "textAlign": undefined,
30
29
  }
31
30
  }
@@ -503,7 +503,6 @@ exports[`renders an empty Banner component 1`] = `
503
503
  "borderColor": undefined,
504
504
  "borderRadius": undefined,
505
505
  "borderWidth": undefined,
506
- "minHeight": undefined,
507
506
  "textAlign": undefined,
508
507
  }
509
508
  }
@@ -1,12 +1,13 @@
1
1
  import React, { useState, useEffect, useRef, useCallback } from 'react';
2
2
  import defaultClasses from './banner.module.css';
3
3
  import { useStyle } from '@magento/venia-ui/lib/classify';
4
- import { arrayOf, bool, oneOf, shape, string, func } from 'prop-types';
4
+ import { arrayOf, bool, oneOf, shape, string, func, object } from 'prop-types';
5
5
  import Button from '@magento/venia-ui/lib/components/Button/button';
6
6
  import resolveLinkProps from '../../resolveLinkProps';
7
7
  import { Link, useHistory } from 'react-router-dom';
8
8
  import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
9
9
  import useIntersectionObserver from '@magento/peregrine/lib/hooks/useIntersectionObserver';
10
+ import { useMediaQuery } from '@magento/peregrine/lib/hooks/useMediaQuery';
10
11
  import handleHtmlContentClick from '../../handleHtmlContentClick';
11
12
 
12
13
  const { matchMedia } = globalThis;
@@ -60,6 +61,7 @@ const Banner = props => {
60
61
  marginRight,
61
62
  marginBottom,
62
63
  marginLeft,
64
+ mediaQueries,
63
65
  paddingTop,
64
66
  paddingRight,
65
67
  paddingBottom,
@@ -75,6 +77,8 @@ const Banner = props => {
75
77
  getParallax = () => {}
76
78
  } = props;
77
79
 
80
+ const { styles: mediaQueryStyles } = useMediaQuery({ mediaQueries });
81
+
78
82
  let image = desktopImage;
79
83
  if (mobileImage && matchMedia && matchMedia('(max-width: 768px)').matches) {
80
84
  image = mobileImage;
@@ -207,7 +211,6 @@ const Banner = props => {
207
211
  }, [backgroundElement, image, intersectionObserver, setBgImage]);
208
212
 
209
213
  if (appearance === 'poster') {
210
- wrapperStyles.minHeight = minHeight;
211
214
  overlayStyles.minHeight = minHeight;
212
215
  overlayStyles.paddingTop = paddingTop;
213
216
  overlayStyles.paddingRight = paddingRight;
@@ -281,11 +284,20 @@ const Banner = props => {
281
284
  let BannerFragment = (
282
285
  <div
283
286
  className={classes.wrapper}
284
- style={wrapperStyles}
287
+ style={{
288
+ ...wrapperStyles,
289
+ ...(appearance !== 'poster' && mediaQueryStyles)
290
+ }}
285
291
  ref={backgroundElement}
286
292
  >
287
293
  {videoOverlay}
288
- <div className={overlayClass} style={overlayStyles}>
294
+ <div
295
+ className={overlayClass}
296
+ style={{
297
+ ...overlayStyles,
298
+ ...(appearance === 'poster' && mediaQueryStyles)
299
+ }}
300
+ >
289
301
  <div
290
302
  className={classes.content}
291
303
  style={contentStyles}
@@ -379,6 +391,7 @@ const Banner = props => {
379
391
  * @property {String} marginRight CSS margin right property
380
392
  * @property {String} marginBottom CSS margin bottom property
381
393
  * @property {String} marginLeft CSS margin left property
394
+ * @property {Array} mediaQueries List of media query rules to be applied to the component
382
395
  * @property {String} paddingTop CSS padding top property
383
396
  * @property {String} paddingRight CSS padding right property
384
397
  * @property {String} paddingBottom CSS padding bottom property
@@ -445,6 +458,12 @@ Banner.propTypes = {
445
458
  marginRight: string,
446
459
  marginBottom: string,
447
460
  marginLeft: string,
461
+ mediaQueries: arrayOf(
462
+ shape({
463
+ media: string,
464
+ style: object
465
+ })
466
+ ),
448
467
  paddingTop: string,
449
468
  paddingRight: string,
450
469
  paddingBottom: string,
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { arrayOf, shape, string } from 'prop-types';
2
+ import { arrayOf, shape, string, object } from 'prop-types';
3
3
  import defaultClasses from './banner.shimmer.module.css';
4
4
  import { useStyle } from '@magento/venia-ui/lib/classify';
5
5
  import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
6
+ import { useMediaQuery } from '@magento/peregrine/lib/hooks/useMediaQuery';
6
7
 
7
8
  /**
8
9
  * Page Builder Banner Shimmer component.
@@ -24,6 +25,7 @@ const BannerShimmer = props => {
24
25
  marginRight,
25
26
  marginBottom,
26
27
  marginLeft,
28
+ mediaQueries,
27
29
  paddingTop,
28
30
  paddingRight,
29
31
  paddingBottom,
@@ -31,6 +33,8 @@ const BannerShimmer = props => {
31
33
  cssClasses = []
32
34
  } = props;
33
35
 
36
+ const { styles: mediaQueryStyles } = useMediaQuery({ mediaQueries });
37
+
34
38
  const rootStyles = {
35
39
  marginTop,
36
40
  marginRight,
@@ -39,7 +43,7 @@ const BannerShimmer = props => {
39
43
  };
40
44
 
41
45
  const wrapperStyles = {
42
- minHeight,
46
+ minHeight: mediaQueryStyles?.minHeight || minHeight,
43
47
  border,
44
48
  borderWidth,
45
49
  paddingTop,
@@ -89,6 +93,7 @@ const BannerShimmer = props => {
89
93
  * @property {String} marginRight CSS margin right property
90
94
  * @property {String} marginBottom CSS margin bottom property
91
95
  * @property {String} marginLeft CSS margin left property
96
+ * @property {Array} mediaQueries List of media query rules to be applied to the component
92
97
  * @property {String} paddingTop CSS padding top property
93
98
  * @property {String} paddingRight CSS padding right property
94
99
  * @property {String} paddingBottom CSS padding bottom property
@@ -111,6 +116,12 @@ BannerShimmer.propTypes = {
111
116
  marginRight: string,
112
117
  marginBottom: string,
113
118
  marginLeft: string,
119
+ mediaQueries: arrayOf(
120
+ shape({
121
+ media: string,
122
+ style: object
123
+ })
124
+ ),
114
125
  paddingTop: string,
115
126
  paddingRight: string,
116
127
  paddingBottom: string,
@@ -5,7 +5,8 @@ import {
5
5
  getPadding,
6
6
  getTextAlign,
7
7
  getCssClasses,
8
- getIsHidden
8
+ getIsHidden,
9
+ getMediaQueries
9
10
  } from '../../utils';
10
11
 
11
12
  /**
@@ -84,6 +85,7 @@ export default (node, props) => {
84
85
  ...getCssClasses(node),
85
86
  ...getMargin(node),
86
87
  ...getPadding(minHeightPaddingElement),
87
- ...getIsHidden(node)
88
+ ...getIsHidden(node),
89
+ ...getMediaQueries(minHeightPaddingElement)
88
90
  };
89
91
  };
@@ -1,8 +1,9 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
2
  import defaultClasses from './column.module.css';
3
3
  import { useStyle } from '@magento/venia-ui/lib/classify';
4
- import { arrayOf, oneOf, shape, string } from 'prop-types';
4
+ import { arrayOf, oneOf, shape, string, object } from 'prop-types';
5
5
  import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
6
+ import { useMediaQuery } from '@magento/peregrine/lib/hooks/useMediaQuery';
6
7
 
7
8
  const { matchMedia } = globalThis;
8
9
 
@@ -40,6 +41,7 @@ const Column = props => {
40
41
  marginLeft,
41
42
  marginRight,
42
43
  marginTop,
44
+ mediaQueries,
43
45
  minHeight,
44
46
  mobileImage,
45
47
  paddingBottom,
@@ -51,6 +53,8 @@ const Column = props => {
51
53
  width
52
54
  } = props;
53
55
 
56
+ const { styles: mediaQueryStyles } = useMediaQuery({ mediaQueries });
57
+
54
58
  let image = desktopImage;
55
59
  if (mobileImage && matchMedia && matchMedia('(max-width: 768px)').matches) {
56
60
  image = mobileImage;
@@ -151,7 +155,7 @@ const Column = props => {
151
155
 
152
156
  return (
153
157
  <div
154
- style={dynamicStyles}
158
+ style={{ ...dynamicStyles, ...mediaQueryStyles }}
155
159
  ref={columnElement}
156
160
  className={[classes.root, ...cssClasses].join(' ')}
157
161
  >
@@ -184,6 +188,7 @@ const Column = props => {
184
188
  * @property {String} marginRight CSS margin right property
185
189
  * @property {String} marginTop CSS margin top property
186
190
  * @property {String} maxWidth Maximum width of the video
191
+ * @property {Array} mediaQueries List of media query rules to be applied to the component
187
192
  * @property {String} minHeight - CSS min-height property
188
193
  * @property {String} mobileImage Background image url to be used for mobile screen width
189
194
  * @property {String} paddingBottom CSS padding bottom property
@@ -219,6 +224,12 @@ Column.propTypes = {
219
224
  marginLeft: string,
220
225
  marginRight: string,
221
226
  marginTop: string,
227
+ mediaQueries: arrayOf(
228
+ shape({
229
+ media: string,
230
+ style: object
231
+ })
232
+ ),
222
233
  minHeight: string,
223
234
  mobileImage: string,
224
235
  paddingBottom: string,
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  getAdvanced,
3
3
  getBackgroundImages,
4
- getVerticalAlignment
4
+ getVerticalAlignment,
5
+ getMediaQueries
5
6
  } from '../../utils';
6
7
 
7
8
  export default node => {
@@ -10,6 +11,7 @@ export default node => {
10
11
  display: node.style.display,
11
12
  width: node.style.width,
12
13
  backgroundColor: node.style.backgroundColor,
14
+ ...getMediaQueries(node),
13
15
  ...getAdvanced(node),
14
16
  ...getBackgroundImages(node),
15
17
  ...getVerticalAlignment(node)
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`#PageBuilder DynamicBlock CE renders 1`] = `null`;
@@ -0,0 +1,93 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`#PageBuilder DynamicBlock EE does not render a Dynamic Block component when no uids are provided 1`] = `null`;
4
+
5
+ exports[`#PageBuilder DynamicBlock EE renders a Dynamic Block component inlined 1`] = `
6
+ <span
7
+ aria-busy="false"
8
+ aria-live="polite"
9
+ className=""
10
+ style={
11
+ Object {
12
+ "border": "solid",
13
+ "borderColor": "red",
14
+ "borderRadius": "15px",
15
+ "borderWidth": "10px",
16
+ "marginBottom": "10px",
17
+ "marginLeft": "10px",
18
+ "marginRight": "10px",
19
+ "marginTop": "10px",
20
+ "minHeight": "40px",
21
+ "paddingBottom": "10px",
22
+ "paddingLeft": "10px",
23
+ "paddingRight": "10px",
24
+ "paddingTop": "10px",
25
+ "textAlign": "right",
26
+ }
27
+ }
28
+ >
29
+ <mock-CmsDynamicBlockGroup
30
+ uids="uids"
31
+ />
32
+ </span>
33
+ `;
34
+
35
+ exports[`#PageBuilder DynamicBlock EE renders a Dynamic Block component with custom classes 1`] = `
36
+ <div
37
+ aria-busy="false"
38
+ aria-live="polite"
39
+ className=" test-class"
40
+ style={
41
+ Object {
42
+ "border": "solid",
43
+ "borderColor": "red",
44
+ "borderRadius": "15px",
45
+ "borderWidth": "10px",
46
+ "marginBottom": "10px",
47
+ "marginLeft": "10px",
48
+ "marginRight": "10px",
49
+ "marginTop": "10px",
50
+ "minHeight": "40px",
51
+ "paddingBottom": "10px",
52
+ "paddingLeft": "10px",
53
+ "paddingRight": "10px",
54
+ "paddingTop": "10px",
55
+ "textAlign": "right",
56
+ }
57
+ }
58
+ >
59
+ <mock-CmsDynamicBlockGroup
60
+ uids="uids"
61
+ />
62
+ </div>
63
+ `;
64
+
65
+ exports[`#PageBuilder DynamicBlock EE renders a Dynamic Block component without custom classes 1`] = `
66
+ <div
67
+ aria-busy="false"
68
+ aria-live="polite"
69
+ className=""
70
+ style={
71
+ Object {
72
+ "border": "solid",
73
+ "borderColor": "red",
74
+ "borderRadius": "15px",
75
+ "borderWidth": "10px",
76
+ "marginBottom": "10px",
77
+ "marginLeft": "10px",
78
+ "marginRight": "10px",
79
+ "marginTop": "10px",
80
+ "minHeight": "40px",
81
+ "paddingBottom": "10px",
82
+ "paddingLeft": "10px",
83
+ "paddingRight": "10px",
84
+ "paddingTop": "10px",
85
+ "textAlign": "right",
86
+ }
87
+ }
88
+ >
89
+ <mock-CmsDynamicBlockGroup
90
+ uids="uids"
91
+ />
92
+ </div>
93
+ `;
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders a DynamicBlockShimmer component with minHeight 1`] = `
4
+ <div
5
+ aria-busy="true"
6
+ aria-live="polite"
7
+ style={
8
+ Object {
9
+ "marginBottom": undefined,
10
+ "marginLeft": undefined,
11
+ "marginRight": undefined,
12
+ "marginTop": undefined,
13
+ "minHeight": "40px",
14
+ }
15
+ }
16
+ >
17
+ <div
18
+ className=" "
19
+ style={Object {}}
20
+ >
21
+ <div
22
+ style={
23
+ Object {
24
+ "border": undefined,
25
+ "borderWidth": undefined,
26
+ "paddingBottom": undefined,
27
+ "paddingLeft": undefined,
28
+ "paddingRight": undefined,
29
+ "paddingTop": undefined,
30
+ }
31
+ }
32
+ >
33
+ <div>
34
+ <div />
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ `;
@@ -0,0 +1,49 @@
1
+ import configAggregator from '../configAggregator';
2
+
3
+ test('dynamic block config aggregator does not render if widget block is not present', () => {
4
+ const node = document.createElement('div');
5
+ node.innerHTML = `<div data-content-type="dynamic_block" data-appearance="default" data-element="main"></div>`;
6
+
7
+ const aggregatedConfig = configAggregator(node.childNodes[0]);
8
+
9
+ expect(aggregatedConfig).toEqual({});
10
+ });
11
+
12
+ test('dynamic block config aggregator does not render if no uids is found', () => {
13
+ const node = document.createElement('div');
14
+ node.innerHTML = `<div data-content-type="dynamic_block" data-appearance="default" data-element="main"><div class="widget block block-banners" data-banner-id="1" data-types="" data-display-mode="fixed" data-ids="1" data-rotate="" data-store-id="1" data-banner-name="Block 1" data-banner-status="Enabled"></div></div>`;
15
+
16
+ const aggregatedConfig = configAggregator(node.childNodes[0]);
17
+
18
+ expect(aggregatedConfig).toEqual({});
19
+ });
20
+
21
+ test('dynamic block config aggregator retrieves data and display block', () => {
22
+ const node = document.createElement('div');
23
+ node.innerHTML = `<div data-content-type="dynamic_block" data-appearance="default" data-element="main"><div class="widget block block-banners" data-banner-id="1" data-types="" data-display-mode="fixed" data-ids="1" data-rotate="" data-store-id="1" data-banner-name="Block 1" data-banner-status="Enabled" data-uids="uids"></div></div>`;
24
+
25
+ const aggregatedConfig = configAggregator(node.childNodes[0]);
26
+
27
+ expect(aggregatedConfig).toEqual(
28
+ expect.objectContaining({
29
+ displayInline: false,
30
+ displayMode: 'fixed',
31
+ uids: 'uids'
32
+ })
33
+ );
34
+ });
35
+
36
+ test('dynamic block config aggregator retrieves data and display inline', () => {
37
+ const node = document.createElement('div');
38
+ node.innerHTML = `<div data-content-type="dynamic_block" data-appearance="default" data-element="main"><div class="widget block block-banners-inline" data-banner-id="2" data-types="" data-display-mode="fixed" data-ids="2" data-rotate="" data-store-id="2" data-banner-name="Block 2" data-banner-status="Enabled" data-uids="uids"></div></div>`;
39
+
40
+ const aggregatedConfig = configAggregator(node.childNodes[0]);
41
+
42
+ expect(aggregatedConfig).toEqual(
43
+ expect.objectContaining({
44
+ displayInline: true,
45
+ displayMode: 'fixed',
46
+ uids: 'uids'
47
+ })
48
+ );
49
+ });
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+
5
+ import DynamicBlock from '../dynamicBlock.ce';
6
+
7
+ const Component = () => {
8
+ return <DynamicBlock />;
9
+ };
10
+
11
+ describe('#PageBuilder DynamicBlock CE', () => {
12
+ it('renders', () => {
13
+ const tree = createTestInstance(<Component />);
14
+
15
+ expect(tree.toJSON()).toMatchSnapshot();
16
+ });
17
+ });
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+ import { DISPLAY_MODE_FIXED_TYPE } from '@magento/venia-ui/lib/components/CmsDynamicBlock';
5
+
6
+ import DynamicBlock from '../dynamicBlock.ee';
7
+
8
+ jest.mock('@magento/venia-ui/lib/components/CmsDynamicBlock', () => props => (
9
+ <mock-CmsDynamicBlockGroup {...props} />
10
+ ));
11
+
12
+ const defaultProps = {
13
+ displayInline: false,
14
+ displayMode: DISPLAY_MODE_FIXED_TYPE,
15
+ uids: 'uids',
16
+ textAlign: 'right',
17
+ border: 'solid',
18
+ borderColor: 'red',
19
+ borderWidth: '10px',
20
+ borderRadius: '15px',
21
+ marginTop: '10px',
22
+ marginRight: '10px',
23
+ marginBottom: '10px',
24
+ marginLeft: '10px',
25
+ minHeight: '40px',
26
+ paddingTop: '10px',
27
+ paddingRight: '10px',
28
+ paddingBottom: '10px',
29
+ paddingLeft: '10px'
30
+ };
31
+
32
+ describe('#PageBuilder DynamicBlock EE', () => {
33
+ it('renders a Dynamic Block component without custom classes', () => {
34
+ const component = createTestInstance(
35
+ <DynamicBlock {...defaultProps} />
36
+ );
37
+
38
+ expect(component.toJSON()).toMatchSnapshot();
39
+ });
40
+
41
+ it('renders a Dynamic Block component with custom classes', () => {
42
+ const blockProps = {
43
+ ...defaultProps,
44
+ cssClasses: ['test-class']
45
+ };
46
+ const component = createTestInstance(<DynamicBlock {...blockProps} />);
47
+
48
+ expect(component.toJSON()).toMatchSnapshot();
49
+ });
50
+
51
+ it('renders a Dynamic Block component inlined', () => {
52
+ const blockProps = {
53
+ ...defaultProps,
54
+ displayInline: true
55
+ };
56
+ const component = createTestInstance(<DynamicBlock {...blockProps} />);
57
+
58
+ expect(component.toJSON()).toMatchSnapshot();
59
+ });
60
+
61
+ it('does not render a Dynamic Block component when no uids are provided', () => {
62
+ const blockProps = {
63
+ ...defaultProps,
64
+ uids: undefined
65
+ };
66
+ const component = createTestInstance(<DynamicBlock {...blockProps} />);
67
+
68
+ expect(component.toJSON()).toMatchSnapshot();
69
+ });
70
+ });
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ import { createTestInstance } from '@magento/peregrine';
4
+
5
+ import DynamicBlockShimmer from '../dynamicBlock.shimmer';
6
+
7
+ test('dynamicBlockShimmer should not render if minHeight not specified', () => {
8
+ const component = createTestInstance(<DynamicBlockShimmer />);
9
+
10
+ expect(component.toJSON()).toBe(null);
11
+ });
12
+
13
+ test('renders a DynamicBlockShimmer component with minHeight', () => {
14
+ const props = {
15
+ minHeight: '40px'
16
+ };
17
+ const component = createTestInstance(<DynamicBlockShimmer {...props} />);
18
+
19
+ expect(component.toJSON()).toMatchSnapshot();
20
+ });
@@ -0,0 +1,25 @@
1
+ import { getAdvanced } from '../../utils';
2
+
3
+ export default node => {
4
+ const widgetBlock = node.childNodes[0];
5
+
6
+ if (
7
+ !widgetBlock ||
8
+ (widgetBlock && !widgetBlock.getAttribute('data-uids'))
9
+ ) {
10
+ return {};
11
+ }
12
+
13
+ // dynamicBlock shimmer uses minHeight from closest row
14
+ const row = widgetBlock.closest('[data-content-type="row"]')?.firstChild;
15
+
16
+ return {
17
+ minHeight: row && row.style.minHeight ? row.style.minHeight : null,
18
+ displayInline: widgetBlock
19
+ .getAttribute('class')
20
+ .includes('block-banners-inline'),
21
+ displayMode: widgetBlock.getAttribute('data-display-mode'),
22
+ uids: widgetBlock.getAttribute('data-uids'),
23
+ ...getAdvanced(node)
24
+ };
25
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Dynamic Block is an EE-only feature for now.
3
+ * Here in CE, don't render the component at all.
4
+ */
5
+ export default () => null;