@secretstache/wordpress-gutenberg 0.3.1 → 0.3.3
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 +3 -3
- package/build/index.js.map +1 -1
- package/build/styles.css +2 -0
- package/package.json +1 -1
- package/src/components/{MediaPicker.js → MediaControl.js} +30 -17
- package/src/components/MediaTypeControl.js +6 -6
- package/src/components/index.js +1 -1
- package/src/styles/_responsive-spacing.scss +4 -0
package/build/styles.css
CHANGED
@@ -128,6 +128,8 @@
|
|
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-range-control__root .components-base-control__help {
|
132
|
+
margin-left: -11px; }
|
131
133
|
|
132
134
|
.block-editor__container .bc-add-new-child-btn {
|
133
135
|
display: flex;
|
package/package.json
CHANGED
@@ -4,12 +4,14 @@ import { page as pageIcon } from '@wordpress/icons';
|
|
4
4
|
|
5
5
|
import { MEDIA_TYPES } from '../utils/index.js';
|
6
6
|
|
7
|
-
export const
|
7
|
+
export const ImageRenderer = ({
|
8
8
|
imageId,
|
9
9
|
imageUrl,
|
10
10
|
onImageClick,
|
11
11
|
onRemoveClick,
|
12
12
|
onSelectClick,
|
13
|
+
selectButtonLabel = "Select Image",
|
14
|
+
removeButtonLabel = "Remove Image",
|
13
15
|
}) => {
|
14
16
|
return imageId && imageUrl ? (
|
15
17
|
<>
|
@@ -28,7 +30,7 @@ export const BCImageRenderer = ({
|
|
28
30
|
isSecondary
|
29
31
|
isDestructive
|
30
32
|
>
|
31
|
-
|
33
|
+
{removeButtonLabel}
|
32
34
|
</Button>
|
33
35
|
</>
|
34
36
|
) : (
|
@@ -37,16 +39,18 @@ export const BCImageRenderer = ({
|
|
37
39
|
onClick={onSelectClick}
|
38
40
|
className="bc-select-btn"
|
39
41
|
>
|
40
|
-
|
42
|
+
{selectButtonLabel}
|
41
43
|
</Button>
|
42
44
|
);
|
43
45
|
};
|
44
46
|
|
45
|
-
export const
|
47
|
+
export const VideoRenderer = ({
|
46
48
|
videoId,
|
47
49
|
videoUrl,
|
48
50
|
onRemoveClick,
|
49
51
|
onSelectClick,
|
52
|
+
selectButtonLabel = "Select Video",
|
53
|
+
removeButtonLabel = "Remove Video",
|
50
54
|
}) => {
|
51
55
|
return videoId && videoUrl ? (
|
52
56
|
<>
|
@@ -60,7 +64,7 @@ export const BCVideoRenderer = ({
|
|
60
64
|
isSecondary
|
61
65
|
isDestructive
|
62
66
|
>
|
63
|
-
|
67
|
+
{removeButtonLabel}
|
64
68
|
</Button>
|
65
69
|
</>
|
66
70
|
) : (
|
@@ -69,22 +73,24 @@ export const BCVideoRenderer = ({
|
|
69
73
|
onClick={onSelectClick}
|
70
74
|
className="bc-select-btn"
|
71
75
|
>
|
72
|
-
|
76
|
+
{selectButtonLabel}
|
73
77
|
</Button>
|
74
78
|
);
|
75
79
|
};
|
76
80
|
|
77
|
-
export const
|
81
|
+
export const AnimationRenderer = ({
|
78
82
|
animationFileId,
|
79
83
|
animationFileUrl,
|
80
84
|
animationFileName,
|
81
85
|
onSelectClick,
|
82
86
|
onRemoveClick,
|
87
|
+
selectButtonLabel = "Select File",
|
88
|
+
removeButtonLabel = "Remove File",
|
83
89
|
}) => {
|
84
90
|
return animationFileId && animationFileUrl ? (
|
85
91
|
<>
|
86
92
|
<div className="bc-animation-block-json-file" onClick={onSelectClick}>
|
87
|
-
<WPIcon icon={pageIcon} size={36}/>
|
93
|
+
<WPIcon icon={pageIcon} size={36} />
|
88
94
|
<span>{animationFileName}</span>
|
89
95
|
</div>
|
90
96
|
<Button
|
@@ -93,24 +99,25 @@ export const BCAnimationRenderer = ({
|
|
93
99
|
className="bc-remove-btn"
|
94
100
|
onClick={onRemoveClick}
|
95
101
|
>
|
96
|
-
|
102
|
+
{removeButtonLabel}
|
97
103
|
</Button>
|
98
104
|
</>
|
99
105
|
) : (
|
100
106
|
<Button variant="secondary" onClick={onSelectClick}>
|
101
|
-
|
107
|
+
{selectButtonLabel}
|
102
108
|
</Button>
|
103
109
|
)
|
104
110
|
};
|
105
111
|
|
106
|
-
|
107
|
-
export const BCMediaPicker = ({
|
112
|
+
export const MediaControl = ({
|
108
113
|
mediaId,
|
109
114
|
mediaUrl,
|
110
115
|
mediaFileName = '',
|
111
116
|
onSelect,
|
112
117
|
onRemove,
|
113
118
|
type = MEDIA_TYPES.IMAGE,
|
119
|
+
selectButtonLabel,
|
120
|
+
removeButtonLabel,
|
114
121
|
...other
|
115
122
|
}) => {
|
116
123
|
if (type === MEDIA_TYPES.IMAGE) {
|
@@ -122,15 +129,17 @@ export const BCMediaPicker = ({
|
|
122
129
|
accept="image/*"
|
123
130
|
value={mediaId}
|
124
131
|
render={({ open }) => (
|
125
|
-
<
|
132
|
+
<ImageRenderer
|
126
133
|
imageId={mediaId}
|
127
134
|
imageUrl={mediaUrl}
|
128
135
|
onImageClick={open}
|
129
136
|
onSelectClick={open}
|
130
137
|
onRemoveClick={onRemove}
|
138
|
+
selectButtonLabel={selectButtonLabel}
|
139
|
+
removeButtonLabel={removeButtonLabel}
|
131
140
|
/>
|
132
141
|
)}
|
133
|
-
{
|
142
|
+
{...other}
|
134
143
|
/>
|
135
144
|
</MediaUploadCheck>
|
136
145
|
);
|
@@ -142,14 +151,16 @@ export const BCMediaPicker = ({
|
|
142
151
|
allowedTypes={['video']}
|
143
152
|
value={mediaId}
|
144
153
|
render={({ open }) => (
|
145
|
-
<
|
154
|
+
<VideoRenderer
|
146
155
|
videoId={mediaId}
|
147
156
|
videoUrl={mediaUrl}
|
148
157
|
onSelectClick={open}
|
149
158
|
onRemoveClick={onRemove}
|
159
|
+
selectButtonLabel={selectButtonLabel}
|
160
|
+
removeButtonLabel={removeButtonLabel}
|
150
161
|
/>
|
151
162
|
)}
|
152
|
-
{
|
163
|
+
{...other}
|
153
164
|
/>
|
154
165
|
</MediaUploadCheck>
|
155
166
|
);
|
@@ -161,12 +172,14 @@ export const BCMediaPicker = ({
|
|
161
172
|
allowedTypes={['application/json', 'text/plain', 'application/lottie']}
|
162
173
|
value={mediaId}
|
163
174
|
render={({ open }) => (
|
164
|
-
<
|
175
|
+
<AnimationRenderer
|
165
176
|
animationFileId={mediaId}
|
166
177
|
animationFileUrl={mediaUrl}
|
167
178
|
animationFileName={mediaFileName}
|
168
179
|
onSelectClick={open}
|
169
180
|
onRemoveClick={onRemove}
|
181
|
+
selectButtonLabel={selectButtonLabel}
|
182
|
+
removeButtonLabel={removeButtonLabel}
|
170
183
|
/>
|
171
184
|
)}
|
172
185
|
{...other}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { useState } from '@wordpress/element';
|
2
2
|
import { SelectControl } from '@wordpress/components';
|
3
3
|
|
4
|
-
import {
|
5
|
-
import { MEDIA_TYPE_LABELS} from '../utils/index.js';
|
4
|
+
import { MediaControl } from './MediaControl.js';
|
5
|
+
import { MEDIA_TYPE_LABELS } from '../utils/index.js';
|
6
6
|
|
7
7
|
export const MediaTypeControl = (props) => {
|
8
8
|
const {
|
@@ -12,9 +12,10 @@ export const MediaTypeControl = (props) => {
|
|
12
12
|
mediaFileName = '',
|
13
13
|
mediaOnSelect,
|
14
14
|
mediaOnRemove,
|
15
|
+
label = 'Media Type',
|
15
16
|
} = props;
|
16
17
|
|
17
|
-
const [
|
18
|
+
const [selectedMediaType, setSelectedMediaType] = useState(mediaTypes?.[0]);
|
18
19
|
|
19
20
|
const mediaTypesOptions = mediaTypes
|
20
21
|
?.filter((type) => MEDIA_TYPE_LABELS[type]) // Ensure it's an allowed type
|
@@ -26,10 +27,9 @@ export const MediaTypeControl = (props) => {
|
|
26
27
|
return (
|
27
28
|
<>
|
28
29
|
{
|
29
|
-
// TODO: add custom label
|
30
30
|
mediaTypes && (
|
31
31
|
<SelectControl
|
32
|
-
label=
|
32
|
+
label={label}
|
33
33
|
value={selectedMediaType}
|
34
34
|
onChange={(mediaType) => setSelectedMediaType(mediaType)}
|
35
35
|
options={mediaTypesOptions}
|
@@ -39,7 +39,7 @@ export const MediaTypeControl = (props) => {
|
|
39
39
|
|
40
40
|
{
|
41
41
|
selectedMediaType && (
|
42
|
-
<
|
42
|
+
<MediaControl
|
43
43
|
mediaId={mediaId}
|
44
44
|
mediaUrl={mediaUrl}
|
45
45
|
mediaFileName={mediaFileName}
|
package/src/components/index.js
CHANGED
@@ -2,7 +2,7 @@ export { ColorPaletteControl } from './ColorPaletteControl';
|
|
2
2
|
export { IconPicker } from './IconPicker';
|
3
3
|
export { ImageActions } from './ImageActions';
|
4
4
|
export { LinkControl } from './LinkControl';
|
5
|
-
export {
|
5
|
+
export { ImageRenderer, VideoRenderer, AnimationRenderer, MediaControl } from './MediaControl.js';
|
6
6
|
export { SortableSelect, SortableSelectAsync } from './SortableSelect';
|
7
7
|
export { DataQueryControls } from './DataQueryControls.js';
|
8
8
|
export { SpacingControl } from './SpacingControl.js';
|