@wordpress/block-library
Version:
Block library for the WordPress editor.
69 lines (68 loc) • 3.28 kB
JavaScript
import { PanelBody, __experimentalVStack } from "@wordpress/components";
import { __ } from "@wordpress/i18n";
import { useState } from "@wordpress/element";
import OverlayTemplatePartSelector from "./overlay-template-part-selector.mjs";
import OverlayVisibilityControl from "./overlay-visibility-control.mjs";
import OverlayMenuPreviewButton from "./overlay-menu-preview-button.mjs";
import OverlayPreview from "./overlay-preview.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/navigation/edit/overlay-panel.jsx
/**
* Overlay Panel component for Navigation block.
*
* @param {Object} props Component props.
* @param {string} props.overlayMenu Overlay menu setting ('never', 'mobile', 'always').
* @param {string} props.overlay Currently selected overlay template part ID.
* @param {Function} props.setAttributes Function to update block attributes.
* @param {Function} props.onNavigateToEntityRecord Function to navigate to template part editor.
* @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 {string} props.overlayMenuPreviewClasses CSS classes for overlay menu preview button.
* @param {string} props.overlayMenuPreviewId ID for overlay menu preview.
* @param {boolean} props.isResponsive Whether overlay menu is responsive.
* @param {string} props.currentTheme Current theme stylesheet name.
* @param {boolean} props.hasOverlays Whether any overlay template parts exist.
* @return {React.JSX.Element} The overlay panel component or null if overlay is disabled.
*/
function OverlayPanel({ overlayMenu, overlay, setAttributes, onNavigateToEntityRecord, overlayMenuPreview, setOverlayMenuPreview, hasIcon, icon, overlayMenuPreviewClasses, overlayMenuPreviewId, isResponsive, currentTheme, hasOverlays }) {
const [isCreatingOverlay, setIsCreatingOverlay] = useState(false);
return /* @__PURE__ */ jsx(PanelBody, {
title: __("Overlay"),
initialOpen: true,
children: /* @__PURE__ */ jsxs(__experimentalVStack, {
spacing: 4,
children: [
/* @__PURE__ */ jsx(OverlayVisibilityControl, {
overlayMenu,
setAttributes
}),
overlayMenu !== "never" && /* @__PURE__ */ jsx(OverlayMenuPreviewButton, {
isResponsive,
overlayMenuPreview,
setOverlayMenuPreview,
hasIcon,
icon,
setAttributes,
overlayMenuPreviewClasses,
overlayMenuPreviewId
}),
overlayMenu !== "never" && /* @__PURE__ */ jsx(OverlayTemplatePartSelector, {
overlay,
overlayMenu,
setAttributes,
onNavigateToEntityRecord,
isCreatingOverlay,
setIsCreatingOverlay
}),
overlayMenu !== "never" && overlay && hasOverlays && !isCreatingOverlay && /* @__PURE__ */ jsx(OverlayPreview, {
overlay,
currentTheme
})
]
})
});
}
export { OverlayPanel as default };
//# sourceMappingURL=overlay-panel.mjs.map