@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
89 lines (88 loc) • 2.93 kB
JavaScript
// packages/global-styles-ui/src/screen-header.tsx
import {
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalSpacer as Spacer,
__experimentalHeading as Heading,
__experimentalView as View,
__experimentalText as WCText,
Button,
Navigator
} from "@wordpress/components";
import { isRTL, __ } from "@wordpress/i18n";
import { chevronRight, chevronLeft } from "@wordpress/icons";
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
import { unlock } from "./lock-unlock.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
var { StateControl, StateControlBadges } = unlock(blockEditorPrivateApis);
function ScreenHeader({
title,
description,
onBack,
viewportStates,
pseudoStates,
selectedViewport = "default",
selectedPseudoState = "default",
onChangeViewport,
onChangePseudoState,
showResponsiveStateControls = true
}) {
return /* @__PURE__ */ jsx(VStack, { spacing: 0, children: /* @__PURE__ */ jsx(View, { children: /* @__PURE__ */ jsx(Spacer, { marginBottom: 0, paddingX: 4, paddingY: 3, children: /* @__PURE__ */ jsxs(VStack, { spacing: 2, children: [
/* @__PURE__ */ jsxs(HStack, { spacing: 2, alignment: "top", children: [
onBack ? /* @__PURE__ */ jsx(
Button,
{
icon: isRTL() ? chevronRight : chevronLeft,
size: "small",
label: __("Back"),
onClick: onBack
}
) : /* @__PURE__ */ jsx(
Navigator.BackButton,
{
icon: isRTL() ? chevronRight : chevronLeft,
size: "small",
label: __("Back")
}
),
/* @__PURE__ */ jsx(Spacer, { children: /* @__PURE__ */ jsxs(HStack, { justify: "space-between", alignment: "top", children: [
/* @__PURE__ */ jsx(
Heading,
{
className: "global-styles-ui-header",
level: 2,
size: 13,
children: title
}
),
/* @__PURE__ */ jsxs(VStack, { spacing: 2, alignment: "right", children: [
/* @__PURE__ */ jsx(
StateControl,
{
viewportStates: showResponsiveStateControls ? viewportStates : [],
pseudoStates,
viewportValue: selectedViewport,
pseudoStateValue: selectedPseudoState,
onChangeViewport,
onChangePseudoState
}
),
/* @__PURE__ */ jsx(
StateControlBadges,
{
viewportStates,
pseudoStates,
viewportValue: selectedViewport,
pseudoStateValue: selectedPseudoState
}
)
] })
] }) })
] }),
description && /* @__PURE__ */ jsx(WCText, { className: "global-styles-ui-header__description", children: description })
] }) }) }) });
}
export {
ScreenHeader
};
//# sourceMappingURL=screen-header.mjs.map