Remove unnecessary controls

This commit is contained in:
2024-12-11 16:48:23 +00:00
parent 51a775a179
commit be6db4f18d

View File

@ -11,21 +11,12 @@ export default function Edit(props) {
const [popups, setPopups] = useState([]); const [popups, setPopups] = useState([]);
const [icons, setIcons] = useState([]); // To hold the icon data const [icons, setIcons] = useState([]); // To hold the icon data
// Fetch published popups (lcp-popup CPT)
useEffect(() => {
const fetchPopups = async () => {
const response = await fetch('/wp-json/wp/v2/lcp-popup');
const data = await response.json();
setPopups(data);
};
fetchPopups();
}, []);
// Fetch icon data from the JSON source (local or remote) // Fetch icon data from the JSON source
useEffect(() => { useEffect(() => {
const fetchIcons = async () => { const fetchIcons = async () => {
// Assuming the icon data is in a file called 'icons.json' // Assuming the icon data is in a file called 'icons.json'
const response = await fetch('/path/to/icons.json'); const response = await fetch('/iconsvgs.json');
const iconData = await response.json(); const iconData = await response.json();
setIcons(iconData); // Set the fetched icon data setIcons(iconData); // Set the fetched icon data
}; };
@ -46,22 +37,9 @@ export default function Edit(props) {
return ( return (
<> <>
<InspectorControls>
<PanelBody title={__("Popup Settings")}>
<SelectControl
label={__("Popup")}
value={popUpId}
options={popups.map((popup) => ({
label: popup.title.rendered,
value: popup.id,
}))}
onChange={(value) => setAttributes({ popUpId: value })}
/>
<TextControl
label={__("Button Text")}
value={buttonText}
onChange={(value) => setAttributes({ buttonText: value })}
/>
{/* Pass the icons array to the IconSelectControl component */} {/* Pass the icons array to the IconSelectControl component */}
<IconSelectControl <IconSelectControl
label={__("Icon")} label={__("Icon")}
@ -69,13 +47,8 @@ export default function Edit(props) {
onChange={handleIconChange} onChange={handleIconChange}
icons={icons} // Passing the icons data here icons={icons} // Passing the icons data here
/> />
</PanelBody>
</InspectorControls>
<div {...useBlockProps()}>
<div className="button-container">
<span>{buttonText}</span>
</div>
</div>
</> </>
); );
} }