@secretstache/wordpress-gutenberg 0.6.3 → 0.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secretstache/wordpress-gutenberg",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "",
5
5
  "author": "Secret Stache",
6
6
  "license": "GPL-2.0-or-later",
@@ -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
- desktopPrefix = 'md:',
198
- mobilePrefix = '',
198
+ {
199
+ desktopPrefix = 'md:',
200
+ mobilePrefix = '',
201
+ valuePrefix = '',
202
+ } = {}
199
203
  ) => {
200
- return classNames({
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
- [`${desktopPrefix}pt-${spacing?.desktop?.padding?.top}`]: spacing?.desktop?.padding?.top !== -1,
205
- [`${desktopPrefix}pb-${spacing?.desktop?.padding?.bottom}`]: spacing?.desktop?.padding?.bottom !== -1,
206
+ const buildClass = (prefix, property, valuePrefix, value) => {
207
+ if (value === SKIP) return null;
206
208
 
207
- [`${mobilePrefix}mt-${spacing?.mobile?.margin?.top}`]: spacing?.mobile?.margin?.top !== -1,
208
- [`${mobilePrefix}mb-${spacing?.mobile?.margin?.bottom}`]: spacing?.mobile?.margin?.bottom !== -1,
209
+ return `${prefix}${property}-${valuePrefix}${value}`;
210
+ };
209
211
 
210
- [`${mobilePrefix}pt-${spacing?.mobile?.padding?.top}`]: spacing?.mobile?.padding?.top !== -1,
211
- [`${mobilePrefix}pb-${spacing?.mobile?.padding?.bottom}`]: spacing?.mobile?.padding?.bottom !== -1,
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
  /**