colorizr 3.0.2 → 3.0.3
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/dist/index.d.mts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +25 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/swatch.ts +26 -21
package/dist/index.d.mts
CHANGED
|
@@ -314,12 +314,17 @@ type Swatch = {
|
|
|
314
314
|
};
|
|
315
315
|
interface SwatchOptions {
|
|
316
316
|
format?: ColorType;
|
|
317
|
+
/**
|
|
318
|
+
* Generate a monochromatic swatch.
|
|
319
|
+
* @default false
|
|
320
|
+
*/
|
|
321
|
+
monochromatic?: boolean;
|
|
317
322
|
/**
|
|
318
323
|
* The scale of the swatch.
|
|
319
324
|
* Linear scale will have equal distance between each shade.
|
|
320
325
|
* @default 'dynamic'
|
|
321
326
|
*/
|
|
322
|
-
scale?: 'dynamic' | 'linear';
|
|
327
|
+
scale?: 'dynamic' | 'linear' | 'monochromatic';
|
|
323
328
|
}
|
|
324
329
|
/**
|
|
325
330
|
* Generate a palette of shades of a color
|
package/dist/index.d.ts
CHANGED
|
@@ -314,12 +314,17 @@ type Swatch = {
|
|
|
314
314
|
};
|
|
315
315
|
interface SwatchOptions {
|
|
316
316
|
format?: ColorType;
|
|
317
|
+
/**
|
|
318
|
+
* Generate a monochromatic swatch.
|
|
319
|
+
* @default false
|
|
320
|
+
*/
|
|
321
|
+
monochromatic?: boolean;
|
|
317
322
|
/**
|
|
318
323
|
* The scale of the swatch.
|
|
319
324
|
* Linear scale will have equal distance between each shade.
|
|
320
325
|
* @default 'dynamic'
|
|
321
326
|
*/
|
|
322
|
-
scale?: 'dynamic' | 'linear';
|
|
327
|
+
scale?: 'dynamic' | 'linear' | 'monochromatic';
|
|
323
328
|
}
|
|
324
329
|
/**
|
|
325
330
|
* Generate a palette of shades of a color
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
21
21
|
|
|
22
22
|
// src/index.ts
|
|
23
|
-
var
|
|
24
|
-
__export(
|
|
23
|
+
var index_exports = {};
|
|
24
|
+
__export(index_exports, {
|
|
25
25
|
addAlphaToHex: () => addAlphaToHex,
|
|
26
26
|
brightnessDifference: () => brightnessDifference,
|
|
27
27
|
chroma: () => chroma,
|
|
@@ -31,7 +31,7 @@ __export(src_exports, {
|
|
|
31
31
|
convert: () => convert,
|
|
32
32
|
convertAlphaToHex: () => convertAlphaToHex,
|
|
33
33
|
darken: () => darken,
|
|
34
|
-
default: () =>
|
|
34
|
+
default: () => index_default,
|
|
35
35
|
desaturate: () => desaturate,
|
|
36
36
|
extractAlphaFromHex: () => extractAlphaFromHex,
|
|
37
37
|
extractColorParts: () => extractColorParts,
|
|
@@ -82,7 +82,7 @@ __export(src_exports, {
|
|
|
82
82
|
textColor: () => textColor,
|
|
83
83
|
transparentize: () => transparentize
|
|
84
84
|
});
|
|
85
|
-
module.exports = __toCommonJS(
|
|
85
|
+
module.exports = __toCommonJS(index_exports);
|
|
86
86
|
|
|
87
87
|
// src/modules/invariant.ts
|
|
88
88
|
function invariant(condition, message) {
|
|
@@ -1582,7 +1582,7 @@ function shadeColor(input, lightness, chromaTuningFactor = 0) {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
function swatch(input, options = {}) {
|
|
1584
1584
|
invariant(isString(input), MESSAGES.inputString);
|
|
1585
|
-
const { format, scale = "dynamic" } = options;
|
|
1585
|
+
const { format, monochromatic = false, scale = "dynamic" } = options;
|
|
1586
1586
|
const lch = parseCSS(input, "oklch");
|
|
1587
1587
|
lch.l = 50;
|
|
1588
1588
|
const colorFormat = isHex(input) || isNamedColor(input) ? "hex" : extractColorParts(input).model;
|
|
@@ -1592,27 +1592,27 @@ function swatch(input, options = {}) {
|
|
|
1592
1592
|
const lightBase = (safeMaxLightness - currentLightness) / 5;
|
|
1593
1593
|
const darkBase = -1 * (currentLightness - safeMinLightness) / 8;
|
|
1594
1594
|
const output = scale === "linear" ? {
|
|
1595
|
-
50: shadeColor(lch, 95, -375e-5),
|
|
1596
|
-
100: shadeColor(lch, 90, -375e-5),
|
|
1597
|
-
200: shadeColor(lch, 80, -375e-5),
|
|
1598
|
-
300: shadeColor(lch, 70, -375e-5),
|
|
1599
|
-
400: shadeColor(lch, 60, -375e-5),
|
|
1600
|
-
500: shadeColor(lch, 50),
|
|
1601
|
-
600: shadeColor(lch, 40, 0.025),
|
|
1602
|
-
700: shadeColor(lch, 30, 0.05),
|
|
1603
|
-
800: shadeColor(lch, 20, 0.075),
|
|
1604
|
-
900: shadeColor(lch, 10, 0.1)
|
|
1595
|
+
50: shadeColor(lch, 95, monochromatic ? 0 : -375e-5),
|
|
1596
|
+
100: shadeColor(lch, 90, monochromatic ? 0 : -375e-5),
|
|
1597
|
+
200: shadeColor(lch, 80, monochromatic ? 0 : -375e-5),
|
|
1598
|
+
300: shadeColor(lch, 70, monochromatic ? 0 : -375e-5),
|
|
1599
|
+
400: shadeColor(lch, 60, monochromatic ? 0 : -375e-5),
|
|
1600
|
+
500: shadeColor(lch, 50, 0),
|
|
1601
|
+
600: shadeColor(lch, 40, monochromatic ? 0 : 0.025),
|
|
1602
|
+
700: shadeColor(lch, 30, monochromatic ? 0 : 0.05),
|
|
1603
|
+
800: shadeColor(lch, 20, monochromatic ? 0 : 0.075),
|
|
1604
|
+
900: shadeColor(lch, 10, monochromatic ? 0 : 0.1)
|
|
1605
1605
|
} : {
|
|
1606
|
-
50: shadeColorDynamic(lch, 5 * lightBase, -375e-5),
|
|
1607
|
-
100: shadeColorDynamic(lch, 4 * lightBase, -375e-5),
|
|
1608
|
-
200: shadeColorDynamic(lch, 3 * lightBase, -375e-5),
|
|
1609
|
-
300: shadeColorDynamic(lch, 2 * lightBase, -375e-5),
|
|
1610
|
-
400: shadeColorDynamic(lch, lightBase, -375e-5),
|
|
1606
|
+
50: shadeColorDynamic(lch, 5 * lightBase, monochromatic ? 0 : -375e-5),
|
|
1607
|
+
100: shadeColorDynamic(lch, 4 * lightBase, monochromatic ? 0 : -375e-5),
|
|
1608
|
+
200: shadeColorDynamic(lch, 3 * lightBase, monochromatic ? 0 : -375e-5),
|
|
1609
|
+
300: shadeColorDynamic(lch, 2 * lightBase, monochromatic ? 0 : -375e-5),
|
|
1610
|
+
400: shadeColorDynamic(lch, lightBase, monochromatic ? 0 : -375e-5),
|
|
1611
1611
|
500: shadeColorDynamic(lch, 0),
|
|
1612
|
-
600: shadeColorDynamic(lch, 1.6 * darkBase, 0.025),
|
|
1613
|
-
700: shadeColorDynamic(lch, 1.875 * 2 * darkBase, 0.05),
|
|
1614
|
-
800: shadeColorDynamic(lch, 3 * 2 * darkBase, 0.075),
|
|
1615
|
-
900: shadeColorDynamic(lch, 4 * 2 * darkBase, 0.1)
|
|
1612
|
+
600: shadeColorDynamic(lch, 1.6 * darkBase, monochromatic ? 0 : 0.025),
|
|
1613
|
+
700: shadeColorDynamic(lch, 1.875 * 2 * darkBase, monochromatic ? 0 : 0.05),
|
|
1614
|
+
800: shadeColorDynamic(lch, 3 * 2 * darkBase, monochromatic ? 0 : 0.075),
|
|
1615
|
+
900: shadeColorDynamic(lch, 4 * 2 * darkBase, monochromatic ? 0 : 0.1)
|
|
1616
1616
|
};
|
|
1617
1617
|
return Object.entries(output).reduce((acc, [key, value]) => {
|
|
1618
1618
|
return {
|
|
@@ -1623,7 +1623,7 @@ function swatch(input, options = {}) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
|
|
1625
1625
|
// src/index.ts
|
|
1626
|
-
var
|
|
1626
|
+
var index_default = Colorizr;
|
|
1627
1627
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1628
1628
|
0 && (module.exports = {
|
|
1629
1629
|
addAlphaToHex,
|