@secretstache/wordpress-gutenberg 0.6.3 → 0.6.5
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/build/index.js +191 -184
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/helpers.js +22 -12
- package/src/utils/rootBlock/setRootBlockFilter.js +2 -1
package/package.json
CHANGED
package/src/utils/helpers.js
CHANGED
@@ -190,26 +190,36 @@ export const decodeHtmlEntities = (text) => {
|
|
190
190
|
* @param {Object} spacing - The spacing object containing margin and padding values.
|
191
191
|
* @param desktopPrefix - Prefix for desktop classes
|
192
192
|
* @param mobilePrefix - Prefix for mobile classes
|
193
|
+
* @param valuePrefix - Prefix for value
|
193
194
|
* @returns {string} - A string of class names for the specified spacing.
|
194
195
|
*/
|
195
196
|
export const getSpacingClasses = (
|
196
197
|
spacing,
|
197
|
-
|
198
|
-
|
198
|
+
{
|
199
|
+
desktopPrefix = 'md:',
|
200
|
+
mobilePrefix = '',
|
201
|
+
valuePrefix = '',
|
202
|
+
} = {}
|
199
203
|
) => {
|
200
|
-
|
201
|
-
[`${desktopPrefix}mt-${spacing?.desktop?.margin?.top}`]: spacing?.desktop?.margin?.top !== -1,
|
202
|
-
[`${desktopPrefix}mb-${spacing?.desktop?.margin?.bottom}`]: spacing?.desktop?.margin?.bottom !== -1,
|
204
|
+
const SKIP = -1;
|
203
205
|
|
204
|
-
|
205
|
-
|
206
|
+
const buildClass = (prefix, property, valuePrefix, value) => {
|
207
|
+
if (value === SKIP) return null;
|
206
208
|
|
207
|
-
|
208
|
-
|
209
|
+
return `${prefix}${property}-${valuePrefix}${value}`;
|
210
|
+
};
|
209
211
|
|
210
|
-
|
211
|
-
|
212
|
-
|
212
|
+
return classNames(
|
213
|
+
buildClass(desktopPrefix, 'mt', valuePrefix, spacing?.desktop?.margin?.top),
|
214
|
+
buildClass(desktopPrefix, 'mb', valuePrefix, spacing?.desktop?.margin?.bottom),
|
215
|
+
buildClass(desktopPrefix, 'pt', valuePrefix, spacing?.desktop?.padding?.top),
|
216
|
+
buildClass(desktopPrefix, 'pb', valuePrefix, spacing?.desktop?.padding?.bottom),
|
217
|
+
|
218
|
+
buildClass(mobilePrefix, 'mt', valuePrefix, spacing?.mobile?.margin?.top),
|
219
|
+
buildClass(mobilePrefix, 'mb', valuePrefix, spacing?.mobile?.margin?.bottom),
|
220
|
+
buildClass(mobilePrefix, 'pt', valuePrefix, spacing?.mobile?.padding?.top),
|
221
|
+
buildClass(mobilePrefix, 'pb', valuePrefix, spacing?.mobile?.padding?.bottom),
|
222
|
+
);
|
213
223
|
};
|
214
224
|
|
215
225
|
/**
|
@@ -14,8 +14,9 @@ export const setRootBlockFilter = {
|
|
14
14
|
const isRootBlock = name === rootBlockName;
|
15
15
|
const isBaseBlock = name === 'core/block';
|
16
16
|
const hasAncestor = !!settings?.ancestor;
|
17
|
+
const hasParent = !!settings?.parent;
|
17
18
|
|
18
|
-
if (!isRootBlock && !isBaseBlock && !hasAncestor) {
|
19
|
+
if (!isRootBlock && !isBaseBlock && !hasAncestor && !hasParent) {
|
19
20
|
settings.ancestor = [rootBlockName];
|
20
21
|
}
|
21
22
|
|