@secretstache/wordpress-gutenberg 0.3.10 → 0.3.11

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.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "",
5
5
  "author": "Secret Stache",
6
6
  "license": "GPL-2.0-or-later",
@@ -132,55 +132,60 @@ export const getDataQueryAttributes = (
132
132
  ...(hasNumberOfPosts ? numberOfPostsAttribute : {}),
133
133
  };
134
134
  };
135
-
136
135
  /**
137
- * Returns the base background attribute object with configurable default background color and media type.
136
+ * Generates a set of attributes for background settings in a block, including options
137
+ * for background color, media, and overlays based on the provided configurations.
138
+ *
139
+ * @param {Object} [options={}] - The options for generating background attributes.
140
+ * @param {Object} [options.defaultBackgroundColor={ value: '', slug: '' }] - The default background color attribute.
141
+ * @param {boolean} [options.hasBackgroundMedia=false] - Flag to determine if background media attributes should be included.
142
+ * @param {string} [options.defaultBackgroundMediaType=''] - The default type of background media if media attributes are included.
143
+ * @param {boolean} [options.hasOverlay=false] - Flag to determine if overlay attributes should be included.
144
+ * @param {Object} [options.defaultOverlayColor={ value: '', slug: '' }] - The default overlay color attribute if overlay attributes are included.
138
145
  *
139
- * @param {Object} options - The options for configuring the background attributes.
140
- * @param {string} [options.defaultBackgroundMediaType=''] - The default background media type.
141
- * @param {Object} options.defaultBackgroundColor - The background color configuration.
142
- * @param {string} options.defaultBackgroundColor.value - The hex value of the background color.
143
- * @param {string} options.defaultBackgroundColor.slug - The slug of the background color.
144
- * @param {boolean} [options.hasIncludeBackgroundMediaAttribute=false] - Whether to include the background media attribute.
145
- * @param {boolean} [options.hasIncludeOverlayAttribute=false] - Whether to include the overlay attribute.
146
- * @returns {Object} The base background attribute object.
146
+ * @returns {Object} An object containing the attributes for the block's background configuration.
147
147
  */
148
148
  export const getBaseBackgroundAttributes = ({
149
- defaultBackgroundMediaType = '',
150
149
  defaultBackgroundColor = { value: '', slug: '' },
151
- hasIncludeBackgroundMediaAttribute = false,
152
- hasIncludeOverlayAttribute = false,
150
+
151
+ hasBackgroundMedia = false,
152
+ defaultBackgroundMediaType = '',
153
+
154
+ hasOverlay = false,
155
+ defaultOverlayColor = { value: '', slug: '' },
153
156
  } = {}) => {
154
- // TODO: add the overlay color attribute
155
- const isIncludeOverlayAttribute = {
156
- isIncludeOverlay: {
157
+ const backgroundMediaAttribute = {
158
+ isIncludeBackgroundMedia: {
157
159
  type: 'boolean',
158
160
  default: false,
159
- }
161
+ },
162
+ backgroundMediaType: {
163
+ type: 'string',
164
+ default: defaultBackgroundMediaType,
165
+ },
166
+ ...mediaAttribute,
160
167
  };
161
168
 
162
- const isIncludeBackgroundMediaAttribute = {
163
- isIncludeBackgroundMedia: {
169
+ const overlayAttribute = {
170
+ isIncludeOverlay: {
164
171
  type: 'boolean',
165
172
  default: false,
166
- }
173
+ },
174
+ overlayColor: {
175
+ type: 'object',
176
+ default: defaultOverlayColor,
177
+ },
167
178
  };
168
179
 
169
180
  return {
170
- ...(hasIncludeBackgroundMediaAttribute ? isIncludeBackgroundMediaAttribute : {}),
171
-
172
- backgroundMediaType: {
173
- type: 'string',
174
- default: defaultBackgroundMediaType,
175
- },
176
181
  backgroundColor: {
177
182
  type: 'object',
178
183
  default: defaultBackgroundColor,
179
184
  },
180
185
 
181
- ...mediaAttribute,
186
+ ...(hasBackgroundMedia ? backgroundMediaAttribute : {}),
182
187
 
183
- ...(hasIncludeOverlayAttribute ? isIncludeOverlayAttribute : {}),
188
+ ...(hasOverlay ? overlayAttribute : {}),
184
189
  };
185
190
  };
186
191