Jake Vanderwerf
7 days ago 46d681c6b825d21b3f698d793c4e630c687d90ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
import { PanelBody, ToggleControl, TextControl } from '@wordpress/components';
 
export default function Edit({ attributes, setAttributes }) {
    const { menuId, collapsed } = attributes;
    const blockProps = useBlockProps();
 
    return (
        <>
            <InspectorControls>
                <PanelBody title="Drawer Settings">
                    <TextControl
                        label="Menu ID"
                        value={menuId}
                        onChange={(value) => setAttributes({ menuId: value })}
                        help="PHP-generated menu identifier"
                    />
                    <ToggleControl
                        label="Start Collapsed"
                        checked={collapsed}
                        onChange={(value) => setAttributes({ collapsed: value })}
                    />
                </PanelBody>
            </InspectorControls>
            <div {...blockProps}>
                <div className="drawer-menu-preview">
                    <p>Drawer Menu: {menuId || 'Not configured'}</p>
                    <p>State: {collapsed ? 'Collapsed' : 'Expanded'}</p>
                </div>
            </div>
        </>
    );
}