UNPKG

@wordpress/global-styles-ui

Version:
62 lines (61 loc) • 2.59 kB
import { __, sprintf } from "@wordpress/i18n"; import { Stack } from "@wordpress/ui"; import { ScreenHeader } from "./screen-header.mjs"; import { ScreenBody } from "./screen-body.mjs"; import PresetGroup from "./presets/preset-group.mjs"; import { usePresets } from "./presets/use-presets.mjs"; import { useSetting } from "./hooks.mjs"; import { getNewIndexFromPresets } from "./utils.mjs"; import { Fragment, jsx, jsxs } from "react/jsx-runtime"; // packages/global-styles-ui/src/screen-text-shadows.tsx const DEFAULT_TEXT_SHADOW = "0.05em 0.05em 0.1em rgba(0, 0, 0, 0.3)"; function ScreenTextShadows() { const [defaultEnabled] = useSetting("typography.defaultTextShadowPresets"); const def = usePresets("typography.textShadowPresets", "default"); const theme = usePresets("typography.textShadowPresets", "theme"); const custom = usePresets("typography.textShadowPresets", "custom"); const addCustomTextShadow = () => { const index = getNewIndexFromPresets(custom.presets, "text-shadow-"); custom.setPresets([...custom.presets, { name: sprintf(__("Text Shadow %d"), index), textShadow: DEFAULT_TEXT_SHADOW, slug: `text-shadow-${index}` }]); }; return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ScreenHeader, { title: __("Text shadows"), description: __("Manage and create text shadow styles for use across the site.") }), /* @__PURE__ */ jsx(ScreenBody, { children: /* @__PURE__ */ jsxs(Stack, { direction: "column", className: "global-styles-ui__text-shadows-panel", gap: "xl", children: [ defaultEnabled && /* @__PURE__ */ jsx(PresetGroup, { label: __("Default"), items: def.presets, getEditPath: (slug) => `/typography/text-shadows/edit/default/${slug}` }), theme.presets.length > 0 && /* @__PURE__ */ jsx(PresetGroup, { label: __("Theme"), items: theme.presets, getEditPath: (slug) => `/typography/text-shadows/edit/theme/${slug}` }), /* @__PURE__ */ jsx(PresetGroup, { label: __("Custom"), items: custom.presets, getEditPath: (slug) => `/typography/text-shadows/edit/custom/${slug}`, addLabel: __("Add text shadow"), onAdd: addCustomTextShadow, menuAction: { label: __("Remove all custom text shadows"), optionsLabel: __("Text shadow options"), confirmText: __("Are you sure you want to remove all custom text shadows?"), confirmButtonText: __("Remove"), onConfirm: () => custom.setPresets([]) } }) ] }) })] }); } export { DEFAULT_TEXT_SHADOW, ScreenTextShadows as default }; //# sourceMappingURL=screen-text-shadows.mjs.map