@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
66 lines (65 loc) • 2.69 kB
JavaScript
import { Button, Navigator, __experimentalHStack, __experimentalHeading, __experimentalSpacer, __experimentalText, __experimentalVStack, __experimentalView } from "@wordpress/components";
import { __, isRTL } from "@wordpress/i18n";
import { chevronLeft, chevronRight } from "@wordpress/icons";
import { privateApis } from "@wordpress/block-editor";
import { unlock } from "./lock-unlock.mjs";
import { jsx, jsxs } from "react/jsx-runtime";
// packages/global-styles-ui/src/screen-header.tsx
const { StateControl, StateControlBadges } = unlock(privateApis);
function ScreenHeader({ title, description, onBack, viewportStates, pseudoStates, selectedViewport = "default", selectedPseudoState = "default", onChangeViewport, onChangePseudoState, showResponsiveStateControls = true }) {
return /* @__PURE__ */ jsx(__experimentalVStack, {
spacing: 0,
children: /* @__PURE__ */ jsx(__experimentalView, { children: /* @__PURE__ */ jsx(__experimentalSpacer, {
marginBottom: 0,
paddingX: 4,
paddingY: 3,
children: /* @__PURE__ */ jsxs(__experimentalVStack, {
spacing: 2,
children: [/* @__PURE__ */ jsxs(__experimentalHStack, {
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(__experimentalSpacer, { children: /* @__PURE__ */ jsxs(__experimentalHStack, {
justify: "space-between",
alignment: "top",
children: [/* @__PURE__ */ jsx(__experimentalHeading, {
className: "global-styles-ui-header",
level: 2,
size: 13,
children: title
}), /* @__PURE__ */ jsxs(__experimentalVStack, {
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(__experimentalText, {
className: "global-styles-ui-header__description",
children: description
})]
})
}) })
});
}
export { ScreenHeader };
//# sourceMappingURL=screen-header.mjs.map