@wordpress/global-styles-ui
Version:
Global Styles UI components for WordPress.
90 lines (89 loc) • 4.25 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
// \0rolldown/runtime.js
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
key = keys[i];
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
get: ((k) => from[k]).bind(null, key),
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
});
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
value: mod,
enumerable: true
}) : target, mod));
let _wordpress_i18n = require("@wordpress/i18n");
let _wordpress_ui = require("@wordpress/ui");
let __screen_header_tsx = require("./screen-header.cjs");
let __screen_body_tsx = require("./screen-body.cjs");
let __presets_preset_group_tsx = require("./presets/preset-group.cjs");
__presets_preset_group_tsx = __toESM(__presets_preset_group_tsx);
let __presets_use_presets_ts = require("./presets/use-presets.cjs");
let __hooks_ts = require("./hooks.cjs");
let __utils_ts = require("./utils.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/global-styles-ui/src/shadows-panel.tsx
const defaultShadow = "6px 6px 9px rgba(0, 0, 0, 0.2)";
function ShadowsPanel() {
const [defaultEnabled] = (0, __hooks_ts.useSetting)("shadow.defaultPresets");
const def = (0, __presets_use_presets_ts.usePresets)("shadow.presets", "default");
const theme = (0, __presets_use_presets_ts.usePresets)("shadow.presets", "theme");
const custom = (0, __presets_use_presets_ts.usePresets)("shadow.presets", "custom");
const addCustomShadow = () => {
const index = (0, __utils_ts.getNewIndexFromPresets)(custom.presets, "shadow-");
custom.setPresets([...custom.presets, {
name: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Shadow %d"), index),
shadow: defaultShadow,
slug: `shadow-${index}`
}]);
};
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__screen_header_tsx.ScreenHeader, {
title: (0, _wordpress_i18n.__)("Shadows"),
description: (0, _wordpress_i18n.__)("Manage and create shadow styles for use across the site.")
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__screen_body_tsx.ScreenBody, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
direction: "column",
className: "global-styles-ui__shadows-panel",
gap: "xl",
children: [
defaultEnabled && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__presets_preset_group_tsx.default, {
label: (0, _wordpress_i18n.__)("Default"),
items: def.presets,
getEditPath: (slug) => `/shadows/edit/default/${slug}`
}),
theme.presets.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(__presets_preset_group_tsx.default, {
label: (0, _wordpress_i18n.__)("Theme"),
items: theme.presets,
getEditPath: (slug) => `/shadows/edit/theme/${slug}`
}),
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(__presets_preset_group_tsx.default, {
label: (0, _wordpress_i18n.__)("Custom"),
items: custom.presets,
getEditPath: (slug) => `/shadows/edit/custom/${slug}`,
addLabel: (0, _wordpress_i18n.__)("Add shadow"),
onAdd: addCustomShadow,
menuAction: {
label: (0, _wordpress_i18n.__)("Remove all custom shadows"),
optionsLabel: (0, _wordpress_i18n.__)("Shadow options"),
confirmText: (0, _wordpress_i18n.__)("Are you sure you want to remove all custom shadows?"),
confirmButtonText: (0, _wordpress_i18n.__)("Remove"),
onConfirm: () => custom.setPresets([])
}
})
]
}) })] });
}
exports.default = ShadowsPanel;
exports.defaultShadow = defaultShadow;
//# sourceMappingURL=shadows-panel.cjs.map