UNPKG

tailwindcss-palette-generator

Version:
28 lines 940 B
import chroma from "chroma-js"; import { getHexColor } from "./utils.js"; const calculateDarkenValue = (shade, mainShade) => { return (shade - mainShade) / 100 / 2; }; const shadeColor = (primaryColor, mainShade, shade) => { return chroma(primaryColor).darken(calculateDarkenValue(shade, mainShade)).hex(); }; const colorResult = (fn, options) => { return options.shades.reduce((acc, shade) => { acc[String(shade)] = fn(options.primaryColor, options.mainShade, shade); return acc; }, {}); }; const generateColorPalette = (options) => { try { const palette = colorResult(shadeColor, options); palette.DEFAULT = getHexColor(options.primaryColor); return Object.freeze(palette); } catch (error) { return /* @__PURE__ */ Object.create(null); } }; var generateColorPalette_default = generateColorPalette; export { generateColorPalette_default as default }; //# sourceMappingURL=generateColorPalette.js.map