UNPKG

@wordpress/global-styles-ui

Version:
126 lines (124 loc) • 5.24 kB
"use strict"; 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 __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // packages/global-styles-ui/src/shadows-panel.tsx var shadows_panel_exports = {}; __export(shadows_panel_exports, { default: () => ShadowsPanel, defaultShadow: () => defaultShadow }); module.exports = __toCommonJS(shadows_panel_exports); var import_i18n = require("@wordpress/i18n"); var import_ui = require("@wordpress/ui"); var import_screen_header = require("./screen-header.cjs"); var import_screen_body = require("./screen-body.cjs"); var import_preset_group = __toESM(require("./presets/preset-group.cjs")); var import_use_presets = require("./presets/use-presets.cjs"); var import_hooks = require("./hooks.cjs"); var import_utils = require("./utils.cjs"); var import_jsx_runtime = require("react/jsx-runtime"); var defaultShadow = "6px 6px 9px rgba(0, 0, 0, 0.2)"; function ShadowsPanel() { const [defaultEnabled] = (0, import_hooks.useSetting)("shadow.defaultPresets"); const def = (0, import_use_presets.usePresets)("shadow.presets", "default"); const theme = (0, import_use_presets.usePresets)("shadow.presets", "theme"); const custom = (0, import_use_presets.usePresets)("shadow.presets", "custom"); const addCustomShadow = () => { const index = (0, import_utils.getNewIndexFromPresets)(custom.presets, "shadow-"); custom.setPresets([ ...custom.presets, { /* translators: %d: is an index for a preset */ name: (0, import_i18n.sprintf)((0, import_i18n.__)("Shadow %d"), index), shadow: defaultShadow, slug: `shadow-${index}` } ]); }; return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [ /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_screen_header.ScreenHeader, { title: (0, import_i18n.__)("Shadows"), description: (0, import_i18n.__)( "Manage and create shadow styles for use across the site." ) } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_screen_body.ScreenBody, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)( import_ui.Stack, { direction: "column", className: "global-styles-ui__shadows-panel", gap: "xl", children: [ defaultEnabled && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_preset_group.default, { label: (0, import_i18n.__)("Default"), items: def.presets, getEditPath: (slug) => `/shadows/edit/default/${slug}` } ), theme.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_preset_group.default, { label: (0, import_i18n.__)("Theme"), items: theme.presets, getEditPath: (slug) => `/shadows/edit/theme/${slug}` } ), /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_preset_group.default, { label: (0, import_i18n.__)("Custom"), items: custom.presets, getEditPath: (slug) => `/shadows/edit/custom/${slug}`, addLabel: (0, import_i18n.__)("Add shadow"), onAdd: addCustomShadow, menuAction: { label: (0, import_i18n.__)("Remove all custom shadows"), optionsLabel: (0, import_i18n.__)("Shadow options"), confirmText: (0, import_i18n.__)( "Are you sure you want to remove all custom shadows?" ), confirmButtonText: (0, import_i18n.__)("Remove"), onConfirm: () => custom.setPresets([]) } } ) ] } ) }) ] }); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { defaultShadow }); //# sourceMappingURL=shadows-panel.cjs.map