Skip to content

Commit 2ab2d9d

Browse files
authored
Merge pull request #328 from cloudinary/fix/parser-for-block
Fix gallery block inconsistencies & Refactor
2 parents 455fa36 + d3f50d5 commit 2ab2d9d

16 files changed

+218
-136
lines changed

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"rules": {
1717
"no-alert": "off",
1818
"no-console": "off",
19+
"no-unused-vars": "off",
1920
"no-nested-ternary": "off",
2021
"jsx-a11y/click-events-have-key-events": "off",
2122
"react-hooks/rules-of-hooks": "error",

css/gallery-block-rtl.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/gallery-block.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/src/gallery.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
}
2626
}
2727

28+
.loading-spinner-container {
29+
position: absolute;
30+
width: 100%;
31+
height: 100%;
32+
background-color: rgba(255,255,255,0.8);
33+
top: 0;
34+
left: 0;
35+
display: flex;
36+
align-items: center;
37+
justify-content: center;
38+
}
39+
2840
/* stylelint-disable selector-class-pattern */
2941
.components-placeholder__fieldset {
3042
justify-content: start;

js/gallery-block.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '9810fbbcfcc1692159bd922028b216cf');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '0cab79e094af694490067db4b65978cb');

js/gallery-block.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/gallery-block.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/gallery.asset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => '016b1065367c780bb1710e094ffcb228');
1+
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-components', 'wp-components/build-style/style.css', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill'), 'version' => 'cce044f0d02652ce16aaaa158bbd7196');

js/gallery.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/src/components/settings-gallery.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
1-
/*global CLD_THEME_COLORS */
1+
/*global CLD_THEME_COLORS, cloudinaryGalleryConfig */
22

33
import React from 'react';
4+
import Dot from 'dot-object';
45
import { render, useEffect, useState } from '@wordpress/element';
5-
import attributes from '../gallery-block/attributes';
66
import GalleryControls from '../gallery-block/controls';
7-
import { setupAttributesForRendering } from '../gallery-block/utils';
87

9-
delete attributes.cloudName;
10-
delete attributes.mediaAssets;
8+
import {
9+
setupAttributesForRendering,
10+
toBlockAttributes,
11+
} from '../gallery-block/utils';
12+
13+
const { cloudName, mediaAssets, ...attributes } = toBlockAttributes(
14+
new Dot( '_' ).dot( cloudinaryGalleryConfig )
15+
);
1116

1217
const parsedAttrs = {};
1318
Object.keys( attributes ).forEach( ( attr ) => {
1419
parsedAttrs[ attr ] = attributes[ attr ]?.default;
1520
} );
1621

17-
function galleryWidgetConfig( config ) {
18-
return {
19-
cloudName: 'demo',
20-
...config,
21-
mediaAssets: [
22-
{
23-
tag: 'shoes_product_gallery_demo',
24-
mediaType: 'image',
25-
},
26-
],
27-
container: '.gallery-preview',
28-
};
29-
}
22+
const galleryWidgetConfig = ( config ) => ( {
23+
cloudName: 'demo',
24+
...config,
25+
mediaAssets: [
26+
{
27+
tag: 'shoes_product_gallery_demo',
28+
mediaType: 'image',
29+
},
30+
],
31+
container: '.gallery-preview',
32+
} );
3033

3134
const StatefulGalleryControls = () => {
3235
const [ statefulAttrs, setStatefulAttrs ] = useState( parsedAttrs );

0 commit comments

Comments
 (0)