@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
42 lines (41 loc) • 1.34 kB
JavaScript
// packages/global-styles-ui/src/background-panel.tsx
import { privateApis as blockEditorPrivateApis } from "@wordpress/block-editor";
import { useStyle, useSetting, useStyleWithResolvedBackground } from "./hooks.mjs";
import { unlock } from "./lock-unlock.mjs";
import { jsx } from "react/jsx-runtime";
var BACKGROUND_DEFAULT_VALUES = {
backgroundSize: "auto"
};
var { BackgroundPanel: StylesBackgroundPanel } = unlock(
blockEditorPrivateApis
);
function hasBackgroundImageValue(style) {
return !!style?.background?.backgroundImage?.id || !!style?.background?.backgroundImage?.url || typeof style?.background?.backgroundImage === "string";
}
function BackgroundPanel() {
const [style] = useStyle("", void 0, "user", false);
const [inheritedStyle, setStyle] = useStyle(
"",
void 0,
"merged",
false
);
const resolvedInheritedStyle = useStyleWithResolvedBackground(inheritedStyle);
const [settings] = useSetting("");
return /* @__PURE__ */ jsx(
StylesBackgroundPanel,
{
inheritedValue: resolvedInheritedStyle,
value: style,
onChange: setStyle,
settings,
defaultValues: BACKGROUND_DEFAULT_VALUES,
showInheritanceLabelIndicators: false
}
);
}
export {
BackgroundPanel as default,
hasBackgroundImageValue
};
//# sourceMappingURL=background-panel.mjs.map