@mantine/colors-generator 7.6.0-alpha.0 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/generate-colors.cjs
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
var chroma = require('chroma-js');
|
|
5
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var chroma__default = /*#__PURE__*/_interopDefault(chroma);
|
|
9
|
+
|
|
6
10
|
const LIGHTNESS_MAP = [0.96, 0.907, 0.805, 0.697, 0.605, 0.547, 0.518, 0.445, 0.395, 0.34];
|
|
7
11
|
const SATURATION_MAP = [0.32, 0.16, 0.08, 0.04, 0, 0, 0.04, 0.08, 0.16, 0.32];
|
|
8
12
|
function getClosestLightness(colorObject) {
|
|
@@ -12,10 +16,10 @@ function getClosestLightness(colorObject) {
|
|
|
12
16
|
);
|
|
13
17
|
}
|
|
14
18
|
function generateColorsMap(color) {
|
|
15
|
-
const colorObject =
|
|
19
|
+
const colorObject = chroma__default.default(color);
|
|
16
20
|
const closestLightness = getClosestLightness(colorObject);
|
|
17
21
|
const baseColorIndex = LIGHTNESS_MAP.findIndex((l) => l === closestLightness);
|
|
18
|
-
const colors = LIGHTNESS_MAP.map((l) => colorObject.set("hsl.l", l)).map((c) =>
|
|
22
|
+
const colors = LIGHTNESS_MAP.map((l) => colorObject.set("hsl.l", l)).map((c) => chroma__default.default(c)).map((c, i) => {
|
|
19
23
|
const saturationDelta = SATURATION_MAP[i] - SATURATION_MAP[baseColorIndex];
|
|
20
24
|
return saturationDelta >= 0 ? c.saturate(saturationDelta) : c.desaturate(saturationDelta * -1);
|
|
21
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-colors.cjs","sources":["../src/generate-colors.ts"],"sourcesContent":["import chroma from 'chroma-js';\n\nconst LIGHTNESS_MAP = [0.96, 0.907, 0.805, 0.697, 0.605, 0.547, 0.518, 0.445, 0.395, 0.34];\nconst SATURATION_MAP = [0.32, 0.16, 0.08, 0.04, 0, 0, 0.04, 0.08, 0.16, 0.32];\n\nfunction getClosestLightness(colorObject: chroma.Color) {\n const lightnessGoal = colorObject.get('hsl.l');\n return LIGHTNESS_MAP.reduce((prev, curr) =>\n Math.abs(curr - lightnessGoal) < Math.abs(prev - lightnessGoal) ? curr : prev\n );\n}\n\nexport function generateColorsMap(color: string) {\n const colorObject = chroma(color);\n const closestLightness = getClosestLightness(colorObject);\n const baseColorIndex = LIGHTNESS_MAP.findIndex((l) => l === closestLightness);\n\n const colors = LIGHTNESS_MAP.map((l) => colorObject.set('hsl.l', l))\n .map((c) => chroma(c))\n .map((c, i) => {\n const saturationDelta = SATURATION_MAP[i] - SATURATION_MAP[baseColorIndex];\n return saturationDelta >= 0\n ? c.saturate(saturationDelta)\n : c.desaturate(saturationDelta * -1);\n });\n\n return { baseColorIndex, colors };\n}\n\nexport type MantineColorsTuple = readonly [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n ...string[],\n];\n\nexport function generateColors(color: string) {\n return generateColorsMap(color).colors.map((c) => c.hex()) as unknown as MantineColorsTuple;\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generate-colors.cjs","sources":["../src/generate-colors.ts"],"sourcesContent":["import chroma from 'chroma-js';\n\nconst LIGHTNESS_MAP = [0.96, 0.907, 0.805, 0.697, 0.605, 0.547, 0.518, 0.445, 0.395, 0.34];\nconst SATURATION_MAP = [0.32, 0.16, 0.08, 0.04, 0, 0, 0.04, 0.08, 0.16, 0.32];\n\nfunction getClosestLightness(colorObject: chroma.Color) {\n const lightnessGoal = colorObject.get('hsl.l');\n return LIGHTNESS_MAP.reduce((prev, curr) =>\n Math.abs(curr - lightnessGoal) < Math.abs(prev - lightnessGoal) ? curr : prev\n );\n}\n\nexport function generateColorsMap(color: string) {\n const colorObject = chroma(color);\n const closestLightness = getClosestLightness(colorObject);\n const baseColorIndex = LIGHTNESS_MAP.findIndex((l) => l === closestLightness);\n\n const colors = LIGHTNESS_MAP.map((l) => colorObject.set('hsl.l', l))\n .map((c) => chroma(c))\n .map((c, i) => {\n const saturationDelta = SATURATION_MAP[i] - SATURATION_MAP[baseColorIndex];\n return saturationDelta >= 0\n ? c.saturate(saturationDelta)\n : c.desaturate(saturationDelta * -1);\n });\n\n return { baseColorIndex, colors };\n}\n\nexport type MantineColorsTuple = readonly [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n ...string[],\n];\n\nexport function generateColors(color: string) {\n return generateColorsMap(color).colors.map((c) => c.hex()) as unknown as MantineColorsTuple;\n}\n"],"names":["chroma"],"mappings":";;;;;;;;;AAEA,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAa,GAAG,CAAC,CAAA,CAAA,CAAA,CAAI,EAAE,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,KAAK,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,CAAE,CAAA,CAAA,CAAA,CAAA,CAAA,CAAK,EAAE,CAAK,CAAA,CAAA,CAAA,CAAA,CAAA,CAAE,CAAI,CAAA,CAAA,CAAA,CAAC,CAAC;AAC3F,CAAM,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAc,GAAG,CAAC,CAAA,CAAA,CAAA,CAAI,EAAE,CAAI,CAAA,CAAA,CAAA,CAAA,CAAE,CAAI,CAAA,CAAA,CAAA,CAAA,CAAE,CAAI,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