UNPKG

@wordpress/global-styles-ui

Version:
23 lines (22 loc) • 1.36 kB
import { useSetting, useStyle } from "./hooks.mjs"; import { prioritizePaletteColors } from "./palette-colors.mjs"; // packages/global-styles-ui/src/preview-hooks.tsx function useStylesPreviewColors() { const [textColor = "black"] = useStyle("color.text"); const [backgroundColor = "white"] = useStyle("color.background"); const [headingColor = textColor] = useStyle("elements.h1.color.text"); const [linkColor = headingColor] = useStyle("elements.link.color.text"); const [buttonBackgroundColor = linkColor] = useStyle("elements.button.color.background"); const [coreColors] = useSetting("color.palette.core") || []; const [themeColors] = useSetting("color.palette.theme") || []; const [customColors] = useSetting("color.palette.custom") || []; const paletteColors = prioritizePaletteColors((themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []), backgroundColor, textColor); const textColorObject = paletteColors.filter(({ color }) => color === textColor); const buttonBackgroundColorObject = paletteColors.filter(({ color }) => color === buttonBackgroundColor); return { paletteColors, highlightedColors: textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter(({ color }) => color !== backgroundColor).slice(0, 2) }; } export { useStylesPreviewColors }; //# sourceMappingURL=preview-hooks.mjs.map