@wordpress/block-library
Version:
Block library for the WordPress editor.
44 lines (43 loc) • 1.98 kB
JavaScript
import { ToggleControl, __experimentalToggleGroupControl, __experimentalToggleGroupControlOption, __experimentalVStack } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import OverlayMenuIcon from "./overlay-menu-icon.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/navigation/edit/overlay-menu-preview-controls.jsx
/**
* Overlay Menu Preview Controls component.
* Used within PanelBody context (not ToolsPanel).
*
* @param {Object} props Component props.
* @param {boolean} props.hasIcon Whether the overlay menu has an icon.
* @param {string} props.icon Icon type for overlay menu.
* @param {Function} props.setAttributes Function to update block attributes.
* @return {React.JSX.Element} The overlay menu preview controls.
*/
function OverlayMenuPreviewControls({ hasIcon, icon, setAttributes }) {
return /* @__PURE__ */ jsxs(__experimentalVStack, {
spacing: 4,
children: [/* @__PURE__ */ jsx(ToggleControl, {
label: __("Show icon button"),
help: __("Configure the visual appearance of the button that toggles the overlay menu."),
onChange: (value) => setAttributes({ hasIcon: value }),
checked: hasIcon
}), /* @__PURE__ */ jsxs(__experimentalToggleGroupControl, {
className: "wp-block-navigation__overlay-menu-icon-toggle-group",
label: __("Icon"),
value: icon,
onChange: (value) => setAttributes({ icon: value }),
isBlock: true,
children: [/* @__PURE__ */ jsx(__experimentalToggleGroupControlOption, {
value: "handle",
"aria-label": __("handle"),
label: /* @__PURE__ */ jsx(OverlayMenuIcon, { icon: "handle" })
}), /* @__PURE__ */ jsx(__experimentalToggleGroupControlOption, {
value: "menu",
"aria-label": __("menu"),
label: /* @__PURE__ */ jsx(OverlayMenuIcon, { icon: "menu" })
})]
})]
});
}
export { OverlayMenuPreviewControls as default };
//# sourceMappingURL=overlay-menu-preview-controls.mjs.map