@webikon/webentor-core 0.9.12

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.
Files changed (132) hide show
  1. package/.husky/pre-commit +40 -0
  2. package/.prettierrc.js +5 -0
  3. package/CHANGELOG.md +88 -0
  4. package/LICENCE.md +7 -0
  5. package/README.md +26 -0
  6. package/core-js/_alpine.ts +20 -0
  7. package/core-js/_slider.ts +232 -0
  8. package/core-js/_utils.ts +126 -0
  9. package/core-js/blocks-components/block-appender.tsx +36 -0
  10. package/core-js/blocks-components/button.tsx +424 -0
  11. package/core-js/blocks-components/custom-image-sizes-panel.tsx +197 -0
  12. package/core-js/blocks-components/index.ts +4 -0
  13. package/core-js/blocks-components/typography-picker-select.tsx +31 -0
  14. package/core-js/blocks-filters/_filter-core-typography.tsx +108 -0
  15. package/core-js/blocks-filters/_slider-settings.tsx +283 -0
  16. package/core-js/blocks-filters/index.ts +3 -0
  17. package/core-js/blocks-filters/responsive-settings/components/DisabledSliderInfo.tsx +10 -0
  18. package/core-js/blocks-filters/responsive-settings/constants.ts +11 -0
  19. package/core-js/blocks-filters/responsive-settings/index.tsx +196 -0
  20. package/core-js/blocks-filters/responsive-settings/settings/block-link/index.ts +1 -0
  21. package/core-js/blocks-filters/responsive-settings/settings/block-link/panel.tsx +47 -0
  22. package/core-js/blocks-filters/responsive-settings/settings/border/border/index.tsx +1 -0
  23. package/core-js/blocks-filters/responsive-settings/settings/border/border/properties.ts +27 -0
  24. package/core-js/blocks-filters/responsive-settings/settings/border/border/settings.tsx +310 -0
  25. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/index.tsx +1 -0
  26. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/properties.ts +31 -0
  27. package/core-js/blocks-filters/responsive-settings/settings/border/border-radius/settings.tsx +211 -0
  28. package/core-js/blocks-filters/responsive-settings/settings/border/index.ts +1 -0
  29. package/core-js/blocks-filters/responsive-settings/settings/border/panel.tsx +54 -0
  30. package/core-js/blocks-filters/responsive-settings/settings/container/display/index.ts +2 -0
  31. package/core-js/blocks-filters/responsive-settings/settings/container/display/properties.ts +167 -0
  32. package/core-js/blocks-filters/responsive-settings/settings/container/display/settings.tsx +73 -0
  33. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/index.ts +2 -0
  34. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/properties.ts +187 -0
  35. package/core-js/blocks-filters/responsive-settings/settings/container/flexbox/settings.tsx +131 -0
  36. package/core-js/blocks-filters/responsive-settings/settings/container/grid/index.ts +2 -0
  37. package/core-js/blocks-filters/responsive-settings/settings/container/grid/properties.ts +187 -0
  38. package/core-js/blocks-filters/responsive-settings/settings/container/grid/settings.tsx +132 -0
  39. package/core-js/blocks-filters/responsive-settings/settings/container/index.ts +4 -0
  40. package/core-js/blocks-filters/responsive-settings/settings/container/panel.tsx +92 -0
  41. package/core-js/blocks-filters/responsive-settings/settings/spacing/index.ts +3 -0
  42. package/core-js/blocks-filters/responsive-settings/settings/spacing/panel.tsx +45 -0
  43. package/core-js/blocks-filters/responsive-settings/settings/spacing/properties.ts +74 -0
  44. package/core-js/blocks-filters/responsive-settings/settings/spacing/settings.tsx +85 -0
  45. package/core-js/blocks-filters/responsive-settings/types/index.ts +68 -0
  46. package/core-js/blocks-filters/responsive-settings/utils.ts +321 -0
  47. package/core-js/blocks-utils/_use-block-parent.ts +27 -0
  48. package/core-js/blocks-utils/_use-post-types.ts +43 -0
  49. package/core-js/blocks-utils/_use-taxonomies.ts +29 -0
  50. package/core-js/blocks-utils/index.ts +3 -0
  51. package/core-js/config/webentor-config.ts +718 -0
  52. package/core-js/index.ts +14 -0
  53. package/core-js/types/_block-components.ts +7 -0
  54. package/core-js/types/_webentor-config.ts +182 -0
  55. package/package.json +98 -0
  56. package/resources/blocks/e-accordion/block.json +34 -0
  57. package/resources/blocks/e-accordion/e-accordion.block.tsx +125 -0
  58. package/resources/blocks/e-accordion/script.ts +1 -0
  59. package/resources/blocks/e-accordion/style.css +8 -0
  60. package/resources/blocks/e-accordion-group/block.json +56 -0
  61. package/resources/blocks/e-accordion-group/e-accordion-group.block.tsx +99 -0
  62. package/resources/blocks/e-breadcrumbs/block.json +41 -0
  63. package/resources/blocks/e-breadcrumbs/e-breadcrumbs.block.tsx +53 -0
  64. package/resources/blocks/e-button/block.json +32 -0
  65. package/resources/blocks/e-button/e-button.block.tsx +55 -0
  66. package/resources/blocks/e-gallery/block.json +90 -0
  67. package/resources/blocks/e-gallery/e-gallery.block.tsx +316 -0
  68. package/resources/blocks/e-icon-picker/block.json +37 -0
  69. package/resources/blocks/e-icon-picker/e-icon-picker.block.tsx +230 -0
  70. package/resources/blocks/e-icon-picker/style.css +17 -0
  71. package/resources/blocks/e-image/block.json +78 -0
  72. package/resources/blocks/e-image/e-image.block.tsx +331 -0
  73. package/resources/blocks/e-picker-query-loop/block.json +25 -0
  74. package/resources/blocks/e-picker-query-loop/e-picker-query-loop.block.tsx +189 -0
  75. package/resources/blocks/e-post-template/block.json +25 -0
  76. package/resources/blocks/e-post-template/e-post-template.block.tsx +100 -0
  77. package/resources/blocks/e-query-loop/block.json +36 -0
  78. package/resources/blocks/e-query-loop/constants.tsx +8 -0
  79. package/resources/blocks/e-query-loop/e-query-loop.block.tsx +270 -0
  80. package/resources/blocks/e-query-loop/taxonomy-controls.tsx +184 -0
  81. package/resources/blocks/e-slider/block.json +42 -0
  82. package/resources/blocks/e-slider/e-slider.block.tsx +100 -0
  83. package/resources/blocks/e-svg/block.json +37 -0
  84. package/resources/blocks/e-svg/e-svg.block.tsx +156 -0
  85. package/resources/blocks/e-tab-container/block.json +49 -0
  86. package/resources/blocks/e-tab-container/e-tab-container.block.tsx +123 -0
  87. package/resources/blocks/e-table/block.json +30 -0
  88. package/resources/blocks/e-table/e-table.block.tsx +120 -0
  89. package/resources/blocks/e-table/script.ts +48 -0
  90. package/resources/blocks/e-table-cell/block.json +40 -0
  91. package/resources/blocks/e-table-cell/e-table-cell.block.tsx +180 -0
  92. package/resources/blocks/e-table-row/block.json +28 -0
  93. package/resources/blocks/e-table-row/e-table-row.block.tsx +118 -0
  94. package/resources/blocks/e-tabs/block.json +27 -0
  95. package/resources/blocks/e-tabs/e-tabs.block.tsx +90 -0
  96. package/resources/blocks/l-404/block.json +51 -0
  97. package/resources/blocks/l-404/l-404.block.tsx +75 -0
  98. package/resources/blocks/l-flexible-container/block.json +34 -0
  99. package/resources/blocks/l-flexible-container/l-flexible-container.block.tsx +97 -0
  100. package/resources/blocks/l-footer/block.json +23 -0
  101. package/resources/blocks/l-footer/l-footer.block.tsx +51 -0
  102. package/resources/blocks/l-formatted-content/block.json +28 -0
  103. package/resources/blocks/l-formatted-content/l-formatted-content.block.tsx +97 -0
  104. package/resources/blocks/l-header/block.json +26 -0
  105. package/resources/blocks/l-header/l-header.block.tsx +100 -0
  106. package/resources/blocks/l-mobile-nav/block.json +15 -0
  107. package/resources/blocks/l-mobile-nav/l-mobile-nav.block.tsx +56 -0
  108. package/resources/blocks/l-mobile-nav/style.css +54 -0
  109. package/resources/blocks/l-nav-menu/block.json +27 -0
  110. package/resources/blocks/l-nav-menu/l-nav-menu.block.tsx +109 -0
  111. package/resources/blocks/l-nav-menu/style.css +134 -0
  112. package/resources/blocks/l-post-card/block.json +13 -0
  113. package/resources/blocks/l-post-card/l-post-card.block.tsx +52 -0
  114. package/resources/blocks/l-section/block.json +89 -0
  115. package/resources/blocks/l-section/l-section.block.tsx +316 -0
  116. package/resources/blocks/l-site-logo/block.json +15 -0
  117. package/resources/blocks/l-site-logo/l-site-logo.block.tsx +54 -0
  118. package/resources/core-components/slider/slider.script.ts +11 -0
  119. package/resources/core-components/slider/slider.style.css +134 -0
  120. package/resources/scripts/editor.ts +29 -0
  121. package/resources/styles/app.css +21 -0
  122. package/resources/styles/common/_editor.css +86 -0
  123. package/resources/styles/common/_form.css +83 -0
  124. package/resources/styles/common/_global.css +73 -0
  125. package/resources/styles/common/_theme.css +75 -0
  126. package/resources/styles/common/_utilities.css +33 -0
  127. package/resources/styles/common/_wordpress.css +110 -0
  128. package/resources/styles/components/_table.css +102 -0
  129. package/resources/styles/editor.css +16 -0
  130. package/resources/styles/partials/.gitkeep +0 -0
  131. package/resources/styles/partials/_header.css +21 -0
  132. package/resources/styles/partials/_pagination.css +35 -0
@@ -0,0 +1,53 @@
1
+ import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
2
+ import { BlockEditProps, registerBlockType } from '@wordpress/blocks';
3
+
4
+ import block from './block.json';
5
+
6
+ /**
7
+ * Edit component.
8
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
9
+ *
10
+ * @param {object} props The block props.
11
+ * @returns {Function} Render the edit screen
12
+ */
13
+
14
+ type AttributesType = {
15
+ coverImage: string;
16
+ };
17
+
18
+ const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
19
+ const { attributes } = props;
20
+
21
+ const blockProps = useBlockProps();
22
+
23
+ const classes = [];
24
+
25
+ // Preview image for block inserter
26
+ if (attributes.coverImage) {
27
+ return <img src={attributes.coverImage} width="468" />;
28
+ }
29
+
30
+ return (
31
+ <div
32
+ {...blockProps}
33
+ className={`${blockProps.className} w-flexible-container ${classes.join(' ')} wbtr:border wbtr:border-dashed wbtr:border-editor-border wbtr:p-2`}
34
+ >
35
+ This would display dynamic Breadcrumbs on FE
36
+ </div>
37
+ );
38
+ };
39
+
40
+ /**
41
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
42
+ *
43
+ * @return {null} Dynamic blocks do not save the HTML.
44
+ */
45
+ const BlockSave = () => <InnerBlocks.Content />;
46
+
47
+ /**
48
+ * Register block.
49
+ */
50
+ registerBlockType(block, {
51
+ edit: BlockEdit,
52
+ save: BlockSave,
53
+ });
@@ -0,0 +1,32 @@
1
+ {
2
+ "$schema": "../../../schemas/webentor-block.json",
3
+ "apiVersion": 3,
4
+ "name": "webentor/e-button",
5
+ "title": "Button",
6
+ "description": "Button block.",
7
+ "category": "webentor-elements",
8
+ "icon": "button",
9
+ "keywords": ["button", "link", "cta", "call to action"],
10
+ "attributes": {
11
+ "button": {
12
+ "type": "object",
13
+ "default": {
14
+ "showButton": true,
15
+ "title": "Button",
16
+ "variant": "primary",
17
+ "size": "medium",
18
+ "url": "#",
19
+ "newTab": false,
20
+ "showIcon": false,
21
+ "icon": null,
22
+ "iconPosition": "right",
23
+ "htmlElement": "a"
24
+ }
25
+ }
26
+ },
27
+ "supports": {
28
+ "webentor": {
29
+ "spacing": true
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,55 @@
1
+ import { useBlockProps } from '@wordpress/block-editor';
2
+ import { BlockEditProps, registerBlockType } from '@wordpress/blocks';
3
+
4
+ import { WebentorButton } from '@webentorCore/blocks-components';
5
+
6
+ import block from './block.json';
7
+
8
+ /**
9
+ * Edit component.
10
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
11
+ *
12
+ * @param {object} props The block props.
13
+ * @returns {Function} Render the edit screen
14
+ */
15
+
16
+ type AttributesType = {
17
+ coverImage: string;
18
+ // button: WebentorButtonAttributes;
19
+ };
20
+
21
+ const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
22
+ const { attributes, setAttributes } = props;
23
+
24
+ const blockProps = useBlockProps();
25
+
26
+ // Preview image for block inserter
27
+ if (attributes.coverImage) {
28
+ return <img src={attributes.coverImage} width="468" />;
29
+ }
30
+
31
+ return (
32
+ <div {...blockProps} className={`${blockProps.className}`}>
33
+ <WebentorButton
34
+ attributes={attributes}
35
+ setAttributes={setAttributes}
36
+ attributeName="button"
37
+ />
38
+ </div>
39
+ );
40
+ };
41
+
42
+ /**
43
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
44
+ *
45
+ * @return {null} Dynamic blocks do not save the HTML.
46
+ */
47
+ const BlockSave = () => null;
48
+
49
+ /**
50
+ * Register block.
51
+ */
52
+ registerBlockType(block, {
53
+ edit: BlockEdit,
54
+ save: BlockSave,
55
+ });
@@ -0,0 +1,90 @@
1
+ {
2
+ "$schema": "../../../schemas/webentor-block.json",
3
+ "apiVersion": 3,
4
+ "name": "webentor/e-gallery",
5
+ "title": "Custom Gallery",
6
+ "description": "Display selected images in a gallery.",
7
+ "category": "webentor-elements",
8
+ "icon": "update",
9
+ "keywords": ["gallery"],
10
+ "attributes": {
11
+ "images": {
12
+ "type": "array",
13
+ "default": []
14
+ },
15
+ "lazyload": {
16
+ "type": "boolean",
17
+ "default": true
18
+ },
19
+ "openInLightbox": {
20
+ "type": "boolean",
21
+ "default": false
22
+ },
23
+ "aspectRatio": {
24
+ "type": "string",
25
+ "default": "auto"
26
+ },
27
+ "objectFit": {
28
+ "type": "string",
29
+ "default": "fill"
30
+ },
31
+ "objectPosition": {
32
+ "type": "string",
33
+ "default": "center"
34
+ },
35
+ "imageSize": {
36
+ "type": "string",
37
+ "default": "large"
38
+ },
39
+ "customSizeEnabled": {
40
+ "type": "boolean",
41
+ "default": false
42
+ },
43
+ "customSize": {
44
+ "type": "object",
45
+ "default": {}
46
+ },
47
+ "display": {
48
+ "type": "object",
49
+ "default": {
50
+ "display": {
51
+ "value": {
52
+ "basic": "flex"
53
+ }
54
+ }
55
+ }
56
+ },
57
+ "flexbox": {
58
+ "type": "object",
59
+ "default": {
60
+ "gap": {
61
+ "value": {
62
+ "basic": "gap-4"
63
+ }
64
+ },
65
+ "flex-wrap": {
66
+ "value": {
67
+ "basic": "flex-wrap"
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "border": {
73
+ "type": "object",
74
+ "default": {
75
+ "border": null,
76
+ "borderRadius": null
77
+ }
78
+ }
79
+ },
80
+ "supports": {
81
+ "webentor": {
82
+ "spacing": true,
83
+ "display": {
84
+ "display": true
85
+ },
86
+ "flexbox": true,
87
+ "grid": true
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,316 @@
1
+ import {
2
+ BlockControls,
3
+ store as blockEditorStore,
4
+ InspectorControls,
5
+ MediaUpload,
6
+ MediaUploadCheck,
7
+ useBlockProps,
8
+ } from '@wordpress/block-editor';
9
+ import { BlockEditProps, registerBlockType } from '@wordpress/blocks';
10
+ import {
11
+ Button,
12
+ PanelBody,
13
+ PanelRow,
14
+ SelectControl,
15
+ ToggleControl,
16
+ ToolbarGroup,
17
+ ToolbarItem,
18
+ } from '@wordpress/components';
19
+ import { useSelect } from '@wordpress/data';
20
+ import { applyFilters } from '@wordpress/hooks';
21
+ import { __ } from '@wordpress/i18n';
22
+
23
+ import { setImmutably } from '@webentorCore/_utils';
24
+ import { CustomImageSizesPanel } from '@webentorCore/blocks-components';
25
+ import { BorderPanel } from '@webentorCore/blocks-filters/responsive-settings/settings/border/panel';
26
+ import { prepareTailwindBorderClassesFromSettings } from '@webentorCore/blocks-filters/responsive-settings/utils';
27
+ import { WebentorConfig } from '@webentorCore/types/_webentor-config';
28
+
29
+ import block from './block.json';
30
+
31
+ /**
32
+ * Edit component.
33
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#edit
34
+ *
35
+ * @param {object} props The block props.
36
+ * @returns {Function} Render the edit screen
37
+ */
38
+
39
+ type AttributesType = {
40
+ images: {
41
+ id: number;
42
+ url: string;
43
+ alt: string;
44
+ }[];
45
+ lazyload: boolean;
46
+ openInLightbox: boolean;
47
+ aspectRatio: string;
48
+ objectFit: string;
49
+ objectPosition: string;
50
+ imageSize: string;
51
+ customSize: {
52
+ enabled: {
53
+ [key: string]: boolean;
54
+ };
55
+ width: {
56
+ [key: string]: string;
57
+ };
58
+ height: {
59
+ [key: string]: string;
60
+ };
61
+ crop: {
62
+ [key: string]: boolean;
63
+ };
64
+ };
65
+ };
66
+
67
+ const BlockEdit: React.FC<BlockEditProps<AttributesType>> = (props) => {
68
+ const { attributes, setAttributes } = props;
69
+ const { images } = attributes;
70
+
71
+ const blockProps = useBlockProps();
72
+
73
+ const imageHeight = 150;
74
+ const imageWidth = 150;
75
+
76
+ const { clientId } = props;
77
+ const { getSettings } = useSelect(blockEditorStore, []);
78
+ const { imageSizes } = useSelect(() => {
79
+ const settings = getSettings();
80
+
81
+ return {
82
+ imageSizes: settings.imageSizes,
83
+ };
84
+ }, [clientId]);
85
+
86
+ const imageSizeOptions = imageSizes.map(({ name, slug }) => ({
87
+ value: slug,
88
+ label: name,
89
+ }));
90
+
91
+ const breakpoints: string[] = applyFilters('webentor.core.twBreakpoints', [
92
+ 'basic',
93
+ ]);
94
+ const twTheme: WebentorConfig['theme'] = applyFilters(
95
+ 'webentor.core.twTheme',
96
+ {},
97
+ );
98
+
99
+ const handleGallerySelect = (images: unknown) => {
100
+ setAttributes({ images });
101
+ };
102
+
103
+ const handleGalleryRemove = () => {
104
+ setAttributes({ images: null });
105
+ };
106
+
107
+ const handleEnabledChange = (enabled: boolean, breakpoint: string) => {
108
+ // Set custom size enabled/disabled
109
+ // For some reason, this doesn't work with setImmutably
110
+ setAttributes({
111
+ customSize: {
112
+ ...attributes.customSize,
113
+ enabled: {
114
+ ...attributes.customSize?.enabled,
115
+ [breakpoint]: enabled,
116
+ },
117
+ },
118
+ });
119
+ };
120
+
121
+ const handleWidthChange = (width: number, breakpoint: string) => {
122
+ setAttributes(
123
+ setImmutably(attributes, ['customSize', 'width', breakpoint], width),
124
+ );
125
+ };
126
+
127
+ const handleHeightChange = (height: number, breakpoint: string) => {
128
+ setAttributes(
129
+ setImmutably(attributes, ['customSize', 'height', breakpoint], height),
130
+ );
131
+ };
132
+
133
+ const handleCropChange = (crop: boolean, breakpoint: string) => {
134
+ setAttributes(
135
+ setImmutably(attributes, ['customSize', 'crop', breakpoint], crop),
136
+ );
137
+ };
138
+
139
+ const GalleryMediaUpload = (
140
+ variant?: 'link' | 'primary' | 'secondary' | 'tertiary',
141
+ ) => (
142
+ <MediaUploadCheck>
143
+ <MediaUpload
144
+ onSelect={handleGallerySelect}
145
+ allowedTypes={['image']}
146
+ value={images?.map(({ id }) => id)}
147
+ gallery
148
+ multiple
149
+ render={({ open }) => (
150
+ <Button onClick={open} variant={variant}>
151
+ {images?.length > 0
152
+ ? __('Edit Gallery Images', 'webentor')
153
+ : __('Select Gallery Images', 'webentor')}
154
+ </Button>
155
+ )}
156
+ />
157
+ </MediaUploadCheck>
158
+ );
159
+
160
+ const borderClasses = prepareTailwindBorderClassesFromSettings(
161
+ attributes,
162
+ 'border',
163
+ ['top', 'right', 'bottom', 'left'],
164
+ );
165
+
166
+ return (
167
+ <>
168
+ <InspectorControls>
169
+ <PanelBody title="Gallery Settings" initialOpen={true}>
170
+ <PanelRow>{GalleryMediaUpload('secondary')}</PanelRow>
171
+
172
+ <PanelRow>
173
+ <ToggleControl
174
+ label={__('Lazyload', 'webentor')}
175
+ checked={attributes.lazyload}
176
+ onChange={(lazyload) => setAttributes({ lazyload })}
177
+ />
178
+ </PanelRow>
179
+
180
+ <PanelRow>
181
+ {/* Open in lightbox */}
182
+ <ToggleControl
183
+ label={__('Open in lightbox', 'webentor')}
184
+ checked={attributes.openInLightbox}
185
+ onChange={(openInLightbox) => setAttributes({ openInLightbox })}
186
+ />
187
+ </PanelRow>
188
+
189
+ {/* Aspect ratio select */}
190
+ <PanelRow>
191
+ <SelectControl
192
+ label={__('Aspect Ratio', 'webentor')}
193
+ value={attributes.aspectRatio}
194
+ options={[
195
+ { label: 'Auto', value: 'auto' },
196
+ { label: 'Square', value: 'square' },
197
+ { label: 'Video (16:9)', value: 'video' },
198
+ ]}
199
+ onChange={(aspectRatio) => setAttributes({ aspectRatio })}
200
+ />
201
+ </PanelRow>
202
+
203
+ {/* Object fit select */}
204
+ <PanelRow>
205
+ <SelectControl
206
+ label={__('Object Fit', 'webentor')}
207
+ value={attributes.objectFit}
208
+ options={[
209
+ { label: 'None', value: 'none' },
210
+ { label: 'Fill', value: 'fill' },
211
+ { label: 'Contain', value: 'contain' },
212
+ { label: 'Cover', value: 'cover' },
213
+ { label: 'Scale down', value: 'scale-down' },
214
+ ]}
215
+ onChange={(objectFit) => setAttributes({ objectFit })}
216
+ />
217
+ </PanelRow>
218
+
219
+ {/* Object position select */}
220
+ {attributes.objectFit && attributes.objectFit !== 'none' && (
221
+ <PanelRow>
222
+ <SelectControl
223
+ label={__('Object Position', 'webentor')}
224
+ value={attributes.objectPosition}
225
+ options={[
226
+ { label: 'Top', value: 'top' },
227
+ { label: 'Right Top', value: 'right-top' },
228
+ { label: 'Right', value: 'right' },
229
+ { label: 'Right Bottom', value: 'right-bottom' },
230
+ { label: 'Bottom', value: 'bottom' },
231
+ { label: 'Left Top', value: 'left-top' },
232
+ { label: 'Left', value: 'left' },
233
+ { label: 'Left Bottom', value: 'left-bottom' },
234
+ { label: 'Center', value: 'center' },
235
+ ]}
236
+ onChange={(objectPosition) => setAttributes({ objectPosition })}
237
+ />
238
+ </PanelRow>
239
+ )}
240
+
241
+ {/* Image size select with fetch for image sizes get_intermediate_image_sizes() */}
242
+ <PanelRow>
243
+ <SelectControl
244
+ label={__('Image Size', 'webentor')}
245
+ value={attributes.imageSize}
246
+ options={imageSizeOptions}
247
+ onChange={(imageSize) => setAttributes({ imageSize })}
248
+ help={__(
249
+ 'These sizes are automatically generated by WordPress. If you want to use custom image sizes, you can do so by enabling them below.',
250
+ 'webentor',
251
+ )}
252
+ />
253
+ </PanelRow>
254
+
255
+ <PanelRow>
256
+ <CustomImageSizesPanel
257
+ attributes={attributes}
258
+ imgSizeAttribute="customSize"
259
+ onEnabledChange={handleEnabledChange}
260
+ onWidthChange={handleWidthChange}
261
+ onHeightChange={handleHeightChange}
262
+ onCropChange={handleCropChange}
263
+ />
264
+ </PanelRow>
265
+ </PanelBody>
266
+
267
+ <BorderPanel {...props} breakpoints={breakpoints} twTheme={twTheme} />
268
+ </InspectorControls>
269
+
270
+ <BlockControls>
271
+ <ToolbarGroup>
272
+ <ToolbarItem as="div">{GalleryMediaUpload()}</ToolbarItem>
273
+ <ToolbarItem as={Button} onClick={handleGalleryRemove}>
274
+ {__('Remove Gallery', 'webentor')}
275
+ </ToolbarItem>
276
+ </ToolbarGroup>
277
+ </BlockControls>
278
+
279
+ <div {...blockProps} className={`${blockProps.className} w-gallery`}>
280
+ {images?.length > 0 ? (
281
+ images.map((image) => (
282
+ <img
283
+ src={image.url}
284
+ key={image.id}
285
+ width={attributes.customSize?.width?.basic || imageWidth}
286
+ height={attributes.customSize?.height?.basic || imageHeight}
287
+ className={`w-gallery__item object-${attributes.objectFit} object-${attributes.objectPosition} aspect-${attributes.aspectRatio} ${borderClasses.join(' ')}`}
288
+ />
289
+ ))
290
+ ) : (
291
+ <div className="wbtr:py-4 wbtr:text-gray-500">
292
+ <div className="wbtr:mb-4">
293
+ Gallery is empty, please select some images.
294
+ </div>
295
+ <div>{GalleryMediaUpload('secondary')}</div>
296
+ </div>
297
+ )}
298
+ </div>
299
+ </>
300
+ );
301
+ };
302
+
303
+ /**
304
+ * See https://wordpress.org/gutenberg/handbook/designers-developers/developers/block-api/block-edit-save/#save
305
+ *
306
+ * @return {null} Dynamic blocks do not save the HTML.
307
+ */
308
+ const BlockSave = () => null;
309
+
310
+ /**
311
+ * Register block.
312
+ */
313
+ registerBlockType(block, {
314
+ edit: BlockEdit,
315
+ save: BlockSave,
316
+ });
@@ -0,0 +1,37 @@
1
+ {
2
+ "$schema": "../../../schemas/webentor-block.json",
3
+ "apiVersion": 3,
4
+ "name": "webentor/e-icon-picker",
5
+ "title": "Icon Picker",
6
+ "description": "Icon Picker block.",
7
+ "category": "webentor-elements",
8
+ "icon": "art",
9
+ "keywords": ["svg", "icon"],
10
+ "attributes": {
11
+ "icon": {
12
+ "type": "object",
13
+ "default": null
14
+ },
15
+ "color": {
16
+ "type": "string",
17
+ "default": "text-black"
18
+ },
19
+ "width": {
20
+ "type": "string",
21
+ "default": "24"
22
+ },
23
+ "height": {
24
+ "type": "string",
25
+ "default": "24"
26
+ },
27
+ "inheritSize": {
28
+ "type": "boolean",
29
+ "default": false
30
+ },
31
+ "link": {
32
+ "type": "object",
33
+ "default": {}
34
+ }
35
+ },
36
+ "supports": {}
37
+ }