@secretstache/wordpress-gutenberg 0.3.12 → 0.3.14
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
@@ -2,7 +2,7 @@ import { Button, Icon as WPIcon } from '@wordpress/components';
|
|
2
2
|
import { MediaUpload, MediaUploadCheck } from '@wordpress/block-editor';
|
3
3
|
import { page as pageIcon } from '@wordpress/icons';
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const ImageRenderer = ({
|
8
8
|
imageId,
|
@@ -115,12 +115,12 @@ export const MediaControl = ({
|
|
115
115
|
mediaFileName = '',
|
116
116
|
onSelect,
|
117
117
|
onRemove,
|
118
|
-
type =
|
118
|
+
type = MEDIA_TYPE.IMAGE,
|
119
119
|
selectButtonLabel,
|
120
120
|
removeButtonLabel,
|
121
121
|
...other
|
122
122
|
}) => {
|
123
|
-
if (type ===
|
123
|
+
if (type === MEDIA_TYPE.IMAGE) {
|
124
124
|
return (
|
125
125
|
<MediaUploadCheck>
|
126
126
|
<MediaUpload
|
@@ -143,7 +143,7 @@ export const MediaControl = ({
|
|
143
143
|
/>
|
144
144
|
</MediaUploadCheck>
|
145
145
|
);
|
146
|
-
} else if (type ===
|
146
|
+
} else if (type === MEDIA_TYPE.VIDEO) {
|
147
147
|
return (
|
148
148
|
<MediaUploadCheck>
|
149
149
|
<MediaUpload
|
@@ -164,7 +164,7 @@ export const MediaControl = ({
|
|
164
164
|
/>
|
165
165
|
</MediaUploadCheck>
|
166
166
|
);
|
167
|
-
} else if (type ===
|
167
|
+
} else if (type === MEDIA_TYPE.ANIMATION) {
|
168
168
|
return (
|
169
169
|
<MediaUploadCheck>
|
170
170
|
<MediaUpload
|
@@ -2,11 +2,11 @@ import { useMemo } from '@wordpress/element';
|
|
2
2
|
import { SelectControl } from '@wordpress/components';
|
3
3
|
|
4
4
|
import { MediaControl } from './MediaControl.js';
|
5
|
-
import {
|
5
|
+
import { MEDIA_TYPE_LABEL, MEDIA_TYPE } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const MediaTypeControl = (props) => {
|
8
8
|
const {
|
9
|
-
types = [
|
9
|
+
types = [ MEDIA_TYPE.IMAGE, MEDIA_TYPE.VIDEO ],
|
10
10
|
|
11
11
|
selectedType,
|
12
12
|
onTypeChange,
|
@@ -22,9 +22,9 @@ export const MediaTypeControl = (props) => {
|
|
22
22
|
} = props;
|
23
23
|
|
24
24
|
const typesOptions = useMemo(() => types
|
25
|
-
?.filter((type) =>
|
25
|
+
?.filter((type) => MEDIA_TYPE_LABEL[type]) // Ensure it's an allowed type
|
26
26
|
?.map((type) => ({
|
27
|
-
label:
|
27
|
+
label: MEDIA_TYPE_LABEL[type],
|
28
28
|
value: type,
|
29
29
|
}))
|
30
30
|
, [ types ]);
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import { useSelect } from '@wordpress/data';
|
2
|
-
import {
|
2
|
+
import { QUERY_TYPE } from '../utils';
|
3
3
|
|
4
|
-
// TODO: numberOfPosts -1 is not a valid value, the API requires the per_page to be >= 1
|
4
|
+
// TODO: 1. numberOfPosts -1 is not a valid value, the API requires the per_page to be >= 1
|
5
|
+
// TODO: 2. make 'dependencies' the separate second argument
|
6
|
+
// TODO: 3. consider supporting the string value for the getPostType as well as function
|
5
7
|
export const useDataQuery = (props) => {
|
6
8
|
const {
|
7
9
|
getPostType,
|
@@ -25,9 +27,9 @@ export const useDataQuery = (props) => {
|
|
25
27
|
...extraQueryArgs,
|
26
28
|
};
|
27
29
|
|
28
|
-
if (queryType ===
|
30
|
+
if (queryType === QUERY_TYPE.BY_CATEGORY && categoriesTaxonomy && curatedCategoriesIds?.length > 0) {
|
29
31
|
queryArgs[categoriesTaxonomy] = curatedCategoriesIds.join(',');
|
30
|
-
} else if (queryType ===
|
32
|
+
} else if (queryType === QUERY_TYPE.CURATED && curatedPostsIds?.length > 0) {
|
31
33
|
queryArgs['include'] = curatedPostsIds;
|
32
34
|
queryArgs['orderby'] = 'include';
|
33
35
|
}
|
package/src/utils/attributes.js
CHANGED
@@ -144,11 +144,9 @@ export const getBaseBackgroundAttributes = ({
|
|
144
144
|
const backgroundMediaAttribute = {
|
145
145
|
isIncludeBackgroundMedia: {
|
146
146
|
type: 'boolean',
|
147
|
-
default: null,
|
148
147
|
},
|
149
148
|
backgroundMediaType: {
|
150
149
|
type: 'string',
|
151
|
-
default: null,
|
152
150
|
},
|
153
151
|
...getMediaAttribute(mediaAttributeName),
|
154
152
|
};
|
@@ -156,18 +154,15 @@ export const getBaseBackgroundAttributes = ({
|
|
156
154
|
const overlayAttribute = {
|
157
155
|
isIncludeOverlay: {
|
158
156
|
type: 'boolean',
|
159
|
-
default: null,
|
160
157
|
},
|
161
158
|
overlayColor: {
|
162
159
|
type: 'object',
|
163
|
-
default: null,
|
164
160
|
},
|
165
161
|
};
|
166
162
|
|
167
163
|
return {
|
168
164
|
backgroundColor: {
|
169
165
|
type: 'object',
|
170
|
-
default: null,
|
171
166
|
},
|
172
167
|
|
173
168
|
...(hasBackgroundMedia ? backgroundMediaAttribute : {}),
|
package/src/utils/constants.js
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
export const
|
1
|
+
export const QUERY_TYPE = {
|
2
2
|
LATEST: 'latest',
|
3
3
|
CURATED: 'curated',
|
4
4
|
BY_CATEGORY: 'by_category'
|
5
5
|
};
|
6
6
|
|
7
|
-
export const
|
7
|
+
export const MEDIA_TYPE = {
|
8
8
|
IMAGE: 'image',
|
9
9
|
VIDEO: 'video',
|
10
10
|
ANIMATION: 'animation',
|
11
11
|
};
|
12
12
|
|
13
|
-
export const
|
14
|
-
[
|
15
|
-
[
|
16
|
-
[
|
13
|
+
export const MEDIA_TYPE_LABEL = {
|
14
|
+
[MEDIA_TYPE.IMAGE]: 'Image',
|
15
|
+
[MEDIA_TYPE.VIDEO]: 'Video',
|
16
|
+
[MEDIA_TYPE.ANIMATION]: 'Animation',
|
17
17
|
};
|