@secretstache/wordpress-gutenberg 0.3.5 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/styles.css +1 -1
- package/package.json +1 -1
- package/src/hooks/useDataQuery.js +3 -0
- package/src/styles/_responsive-spacing.scss +3 -3
- package/src/utils/attributes.js +26 -12
- package/src/utils/helpers.js +14 -42
package/build/styles.css
CHANGED
@@ -128,7 +128,7 @@
|
|
128
128
|
.block-editor__container .bc-spacing-range-control .components-range-control__root .components-range-control__wrapper .components-range-control__marks .components-range-control__mark-label {
|
129
129
|
left: 8px !important;
|
130
130
|
margin-top: 7px !important; }
|
131
|
-
.block-editor__container .bc-spacing-range-control .components-
|
131
|
+
.block-editor__container .bc-spacing-range-control .components-base-control__help {
|
132
132
|
margin-left: -11px; }
|
133
133
|
|
134
134
|
.block-editor__container .bc-add-new-child-btn {
|
package/package.json
CHANGED
@@ -37,9 +37,12 @@ export const useDataQuery = (props) => {
|
|
37
37
|
const isResolving = select('core/data').isResolving('core', 'getEntityRecords', ['postType', postType, queryArgs]);
|
38
38
|
const isLoading = isResolving || postsToShow === undefined;
|
39
39
|
|
40
|
+
const isEmpty = postsToShow !== null && postsToShow?.length === 0;
|
41
|
+
|
40
42
|
return {
|
41
43
|
postsToShow,
|
42
44
|
isLoading,
|
45
|
+
isEmpty,
|
43
46
|
};
|
44
47
|
}, dependencies);
|
45
48
|
}
|
package/src/utils/attributes.js
CHANGED
@@ -135,21 +135,38 @@ export const getDataQueryAttributes = (
|
|
135
135
|
/**
|
136
136
|
* Returns the base background attribute object with configurable default background color and media type.
|
137
137
|
*
|
138
|
-
* @param {
|
139
|
-
* @param {
|
140
|
-
* @param {
|
141
|
-
* @param {string} defaultBackgroundColor.
|
138
|
+
* @param {Object} options - The options for configuring the background attributes.
|
139
|
+
* @param {string} [options.defaultBackgroundMediaType=''] - The default background media type.
|
140
|
+
* @param {Object} options.defaultBackgroundColor - The background color configuration.
|
141
|
+
* @param {string} options.defaultBackgroundColor.value - The hex value of the background color.
|
142
|
+
* @param {string} options.defaultBackgroundColor.slug - The slug of the background color.
|
143
|
+
* @param {boolean} [options.hasIncludeBackgroundMediaAttribute=false] - Whether to include the background media attribute.
|
144
|
+
* @param {boolean} [options.hasIncludeOverlayAttribute=false] - Whether to include the overlay attribute.
|
142
145
|
* @returns {Object} The base background attribute object.
|
143
146
|
*/
|
144
|
-
export const getBaseBackgroundAttributes = (
|
147
|
+
export const getBaseBackgroundAttributes = ({
|
145
148
|
defaultBackgroundMediaType = '',
|
146
149
|
defaultBackgroundColor = { value: '', slug: '' },
|
147
|
-
|
148
|
-
|
150
|
+
hasIncludeBackgroundMediaAttribute = false,
|
151
|
+
hasIncludeOverlayAttribute = false,
|
152
|
+
} = {}) => {
|
153
|
+
const isIncludeOverlayAttribute = {
|
154
|
+
isIncludeOverlay: {
|
155
|
+
type: 'boolean',
|
156
|
+
default: false,
|
157
|
+
}
|
158
|
+
};
|
159
|
+
|
160
|
+
const isIncludeBackgroundMediaAttribute = {
|
149
161
|
isIncludeBackgroundMedia: {
|
150
162
|
type: 'boolean',
|
151
163
|
default: false,
|
152
|
-
}
|
164
|
+
}
|
165
|
+
};
|
166
|
+
|
167
|
+
return {
|
168
|
+
...(hasIncludeBackgroundMediaAttribute ? isIncludeBackgroundMediaAttribute : {}),
|
169
|
+
|
153
170
|
backgroundMediaType: {
|
154
171
|
type: 'string',
|
155
172
|
default: defaultBackgroundMediaType,
|
@@ -161,10 +178,7 @@ export const getBaseBackgroundAttributes = (
|
|
161
178
|
|
162
179
|
...mediaAttribute,
|
163
180
|
|
164
|
-
|
165
|
-
type: 'boolean',
|
166
|
-
default: false,
|
167
|
-
},
|
181
|
+
...(hasIncludeOverlayAttribute ? isIncludeOverlayAttribute : {}),
|
168
182
|
};
|
169
183
|
};
|
170
184
|
|
package/src/utils/helpers.js
CHANGED
@@ -122,54 +122,26 @@ export const decodeHtmlEntities = (text) => {
|
|
122
122
|
* Generates a string of class names for spacing based on the provided spacing object.
|
123
123
|
*
|
124
124
|
* @param {Object} spacing - The spacing object containing margin and padding values.
|
125
|
-
* @param
|
126
|
-
* @param
|
127
|
-
* @param {string} [desktopPrefixes.marginBottom='mb-'] - Prefix for desktop margin-bottom class.
|
128
|
-
* @param {string} [desktopPrefixes.paddingTop='pt-'] - Prefix for desktop padding-top class.
|
129
|
-
* @param {string} [desktopPrefixes.paddingBottom='pb-'] - Prefix for desktop padding-bottom class.
|
130
|
-
* @param {Object} [mobilePrefixes] - Optional prefixes for mobile spacing classes.
|
131
|
-
* @param {string} [mobilePrefixes.marginTop='sm:mt-'] - Prefix for mobile margin-top class.
|
132
|
-
* @param {string} [mobilePrefixes.marginBottom='sm:mb-'] - Prefix for mobile margin-bottom class.
|
133
|
-
* @param {string} [mobilePrefixes.paddingTop='sm:pt-'] - Prefix for mobile padding-top class.
|
134
|
-
* @param {string} [mobilePrefixes.paddingBottom='sm:pb-'] - Prefix for mobile padding-bottom class.
|
125
|
+
* @param desktopPrefix - Prefix for desktop classes
|
126
|
+
* @param mobilePrefix - Prefix for mobile classes
|
135
127
|
* @returns {string} - A string of class names for the specified spacing.
|
136
128
|
*/
|
137
129
|
export const getSpacingClasses = (
|
138
130
|
spacing,
|
139
|
-
|
140
|
-
|
141
|
-
marginBottom: 'mb-',
|
142
|
-
paddingTop: 'pt-',
|
143
|
-
paddingBottom: 'pb-',
|
144
|
-
},
|
145
|
-
mobilePrefixes = {
|
146
|
-
marginTop: 'sm:mt-',
|
147
|
-
marginBottom: 'sm:mb-',
|
148
|
-
paddingTop: 'sm:pt-',
|
149
|
-
paddingBottom: 'sm:pb-',
|
150
|
-
}
|
131
|
+
desktopPrefix = 'md:',
|
132
|
+
mobilePrefix = '',
|
151
133
|
) => {
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
[`${desktopPrefixes.marginBottom}${spacing.desktop.margin.bottom}`]: spacing.desktop.margin.bottom !== -1,
|
156
|
-
|
157
|
-
[`${desktopPrefixes.paddingTop}${spacing.desktop.padding.top}`]: spacing.desktop.padding.top !== -1,
|
158
|
-
[`${desktopPrefixes.paddingBottom}${spacing.desktop.padding.bottom}`]: spacing.desktop.padding.bottom !== -1,
|
134
|
+
return classNames({
|
135
|
+
[`${desktopPrefix}mt-${spacing?.desktop?.margin?.top}`]: spacing?.desktop?.margin?.top !== -1,
|
136
|
+
[`${desktopPrefix}mb-${spacing?.desktop?.margin?.bottom}`]: spacing?.desktop?.margin?.bottom !== -1,
|
159
137
|
|
160
|
-
|
161
|
-
|
138
|
+
[`${desktopPrefix}pt-${spacing?.desktop?.padding?.top}`]: spacing?.desktop?.padding?.top !== -1,
|
139
|
+
[`${desktopPrefix}pb-${spacing?.desktop?.padding?.bottom}`]: spacing?.desktop?.padding?.bottom !== -1,
|
162
140
|
|
163
|
-
|
164
|
-
|
165
|
-
});
|
166
|
-
} else {
|
167
|
-
return classNames({
|
168
|
-
[`${desktopPrefixes.marginTop}${spacing.margin.top}`]: spacing.margin.top !== -1,
|
169
|
-
[`${desktopPrefixes.marginBottom}${spacing.margin.bottom}`]: spacing.margin.bottom !== -1,
|
141
|
+
[`${mobilePrefix}mt-${spacing?.mobile?.margin?.top}`]: spacing?.mobile?.margin?.top !== -1,
|
142
|
+
[`${mobilePrefix}mb-${spacing?.mobile?.margin?.bottom}`]: spacing?.mobile?.margin?.bottom !== -1,
|
170
143
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
}
|
144
|
+
[`${mobilePrefix}pt-${spacing?.mobile?.padding?.top}`]: spacing?.mobile?.padding?.top !== -1,
|
145
|
+
[`${mobilePrefix}pb-${spacing?.mobile?.padding?.bottom}`]: spacing?.mobile?.padding?.bottom !== -1,
|
146
|
+
});
|
175
147
|
};
|