import { useState } from '@wordpress/element'; import { BlockControls } from '@wordpress/block-editor'; import { Popover, TabPanel, ToolbarButton } from '@wordpress/components'; import Half3Icon from 'blockbite-icons/dist/Half3'; import { StyleInspectorClasses } from './StyleInspectorClasses'; import { StyleInspectorPresets } from './StyleInspectorPresets'; export const StyleInspector = (props: any) => { const { attributes, handleStyleInspectorOpen, name: blockname, setAttributes, } = props; const [isVisible, setIsVisible] = useState(false); return ( } label="Inspect Blockbite styles and presets" onClick={() => { setIsVisible((prev) => { if (!prev) { handleStyleInspectorOpen(); } return !prev; }); }} > {isVisible && ( { // Timeout required for allowing the ToolbarButton to toggle the popover without interference setTimeout(() => setIsVisible(false), 100); }} onClick={(e) => e.stopPropagation()} > { switch (tab.name) { case 'styles': return ; case 'presets': return ( ); default: return null; } }} /> )} ); };