import { __ } from "@wordpress/i18n"; import "./editor.scss"; import keyIcon from "./img/icon_feather_key.svg"; import chainIcon from "./img/icon_block_chain.svg"; import houseIcon from "./img/icon_house.svg"; import bulbIcon from "./img/icon_bulb.svg"; import { RichText, useBlockProps, BlockControls, InnerBlocks, InspectorControls, } from "@wordpress/block-editor"; import { ToolbarButton, ToggleControl, PanelBody } from "@wordpress/components"; export default function Edit({ attributes, setAttributes }) { const { title, iconName, hasTitle } = attributes; const handleIconChange = (newIconName) => { setAttributes({ iconName: newIconName }); }; function getIconPicture() { switch (iconName) { case "key": return keyIcon; case "chain": return chainIcon; case "house": return houseIcon; case "bulb": return bulbIcon; } } function getDashiconSymbol() { switch (iconName) { case "key": return "admin-network"; case "chain": return "admin-links"; case "house": return "admin-home"; case "bulb": return "lightbulb"; } } function onHasTitleChange() { setAttributes({ hasTitle: !hasTitle, title: undefined, }); } let iconPicture = getIconPicture(); let iconDashiconSymbol = getDashiconSymbol(); return ( <> handleIconChange("key")} /> handleIconChange("chain")} /> handleIconChange("house")} /> handleIconChange("bulb")} />
{hasTitle && (
setAttributes({ title: value })} value={title} placeholder={__( "Insérez un titre", "homegrade-blocks__texte-fonctionnel" )} tagName="h3" allowedFormats={[]} />
)}
); }