@wordpress/block-library
Version:
Block library for the WordPress editor.
46 lines (45 loc) • 2.71 kB
JavaScript
import { Button, __experimentalVStack } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { Icon, close } from "@wordpress/icons";
import OverlayMenuIcon from "./overlay-menu-icon.mjs";
import OverlayMenuPreviewControls from "./overlay-menu-preview-controls.mjs";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/navigation/edit/overlay-menu-preview-button.jsx
/**
* Overlay Menu Preview Button component.
*
* @param {Object} props Component props.
* @param {boolean} props.isResponsive Whether overlay menu is responsive.
* @param {boolean} props.overlayMenuPreview Whether overlay menu preview is open.
* @param {Function} props.setOverlayMenuPreview Function to toggle overlay menu preview.
* @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.
* @param {string} props.overlayMenuPreviewClasses CSS classes for overlay menu preview button.
* @param {string} props.overlayMenuPreviewId ID for overlay menu preview.
* @param {string} props.containerStyle Optional style for the preview container.
* @return {React.JSX.Element} The overlay menu preview button or null if not responsive.
*/
function OverlayMenuPreviewButton({ isResponsive, overlayMenuPreview, setOverlayMenuPreview, hasIcon, icon, setAttributes, overlayMenuPreviewClasses, overlayMenuPreviewId, containerStyle }) {
if (!isResponsive) return null;
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(Button, {
__next40pxDefaultSize: true,
className: overlayMenuPreviewClasses,
onClick: () => setOverlayMenuPreview(!overlayMenuPreview),
"aria-label": __("Overlay menu controls"),
"aria-controls": overlayMenuPreviewId,
"aria-expanded": overlayMenuPreview,
children: [hasIcon && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(OverlayMenuIcon, { icon }), /* @__PURE__ */ jsx(Icon, { icon: close })] }), !hasIcon && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: __("Menu") }), /* @__PURE__ */ jsx("span", { children: __("Close") })] })]
}), overlayMenuPreview && /* @__PURE__ */ jsx(__experimentalVStack, {
id: overlayMenuPreviewId,
spacing: 4,
style: containerStyle,
children: /* @__PURE__ */ jsx(OverlayMenuPreviewControls, {
hasIcon,
icon,
setAttributes
})
})] });
}
export { OverlayMenuPreviewButton as default };
//# sourceMappingURL=overlay-menu-preview-button.mjs.map