diff --git a/includes/blocks/lcp-button/components/DimensionValueControl.js b/includes/blocks/lcp-button/components/DimensionValueControl.js
new file mode 100644
index 0000000..113f8fe
--- /dev/null
+++ b/includes/blocks/lcp-button/components/DimensionValueControl.js
@@ -0,0 +1,47 @@
+import { __ } from '@wordpress/i18n';
+import { BaseControl, NumberControl, SelectControl, __experimentalHStack as HStack } from '@wordpress/components';
+
+/**
+ * Control component with a number input and a select dropdown for units (px, rem, em, % etc.).
+ */
+export function NumberWithUnitControl() {
+ // Example options for select control (CSS units)
+ const unitOptions = [
+ { label: __('px'), value: 'px' },
+ { label: __('rem'), value: 'rem' },
+ { label: __('em'), value: 'em' },
+ { label: __('%'), value: '%' },
+ { label: __('vh'), value: 'vh' },
+ { label: __('vw'), value: 'vw' },
+ { label: __('pt'), value: 'pt' },
+ { label: __('cm'), value: 'cm' },
+ { label: __('mm'), value: 'mm' },
+ ];
+
+ // State to manage the number and unit values
+ const [value, setValue] = React.useState(10);
+ const [unit, setUnit] = React.useState('px');
+
+ return (
+
+
+ {/* Number input control */}
+ setValue(newValue)}
+ min={0}
+ step={1}
+ label={__('Value')}
+ />
+
+ {/* Select dropdown control for units */}
+ setUnit(newUnit)}
+ label={__('Unit')}
+ />
+
+
+ );
+}
diff --git a/includes/blocks/lcp-button/components/IconSelectControl.js b/includes/blocks/lcp-button/components/IconSelectControl.js
index ecaa8bb..1c00e70 100644
--- a/includes/blocks/lcp-button/components/IconSelectControl.js
+++ b/includes/blocks/lcp-button/components/IconSelectControl.js
@@ -10,10 +10,10 @@ export function IconSelectControl(props) {
useEffect(() => {
const fetchIconData = async () => {
try {
- const response = await fetch('/wp-content/themes/local-content-pro/assets/json/icons.json');
+ const response = await fetch('/wp-json/lcp/v1/icons');
const data = await response.json();
- if (data && data.length > 0) {
- setIconData(data[0].svgs); // Assuming the structure is correct
+ if (Array.isArray(data) && data.length > 0) {
+ setIconData(data); // Set the fetched data directly
}
} catch (error) {
console.error('Error fetching icons:', error);
@@ -24,15 +24,17 @@ export function IconSelectControl(props) {
}, []);
const handleIconChange = (selectedIconId) => {
- const selectedIcon = iconData.find(icon => icon.id === selectedIconId);
+ const selectedIcon = iconData.find(icon => icon.iconSvgId === selectedIconId);
if (selectedIcon && onIconChange) {
// Send both icon ID and path (SVG) to the parent component
onIconChange({
- iconSvgId: selectedIcon.id, // Pass icon ID to parent
- iconSvgPath: selectedIcon.path // Pass icon path (SVG) to parent
+ iconSvgId: selectedIcon.iconSvgId, // Pass icon ID to parent
+ iconSvgPath: selectedIcon.iconSvgPaths, // Pass icon paths to parent
+ viewbox: selectedIcon.selectedIconViewbox // Pass the viewbox to parent
});
- console.log("Selected Icon ID:", selectedIcon.id); // Debugging output
- console.log("Selected Icon Path:", selectedIcon.path); // Debugging output
+ console.log("Selected Icon ID:", selectedIcon.iconSvgId); // Debugging output
+ console.log("Selected Icon Path:", selectedIcon.iconSvgPaths); // Debugging output
+ console.log("Selected Icon Viewbox:", selectedIcon.selectedIconViewbox); // Debugging output
}
};
@@ -41,20 +43,11 @@ export function IconSelectControl(props) {
}
const iconOptions = iconData.map((icon) => ({
- value: icon.id, // Use icon ID as value for the SelectControl
- label: (
-
-
- {icon.name} {/* Show icon name */}
-
- ),
+ value: icon.iconSvgId, // Use icon ID as value for the SelectControl
+ label: icon.name, // Directly use the icon's name as the label
}));
-
+
+
return (
+ {/* Padding label and Unlink button */}
+
+ {__('Padding')}
+
+
+
+ {/* Extra Large Padding Controls */}
+ {/* Will update all padding values for all screen sizes if updateAllScreenSizes is true */}
+
+ {/* Top and Bottom HStack */}
+
+ {/* Top and Bottom Icon */}
+
+
+ {/* RangeControl wrapped in HStack with flex: 1 applied to its parent */}
+