@lightdash/common 0.2251.2 → 0.2251.4
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/utils/colors.d.ts +1 -1
- package/dist/cjs/utils/colors.d.ts.map +1 -1
- package/dist/cjs/utils/colors.js +8 -5
- package/dist/cjs/utils/colors.js.map +1 -1
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/utils/colors.d.ts +1 -1
- package/dist/esm/utils/colors.d.ts.map +1 -1
- package/dist/esm/utils/colors.js +8 -5
- package/dist/esm/utils/colors.js.map +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/utils/colors.d.ts +1 -1
- package/dist/types/utils/colors.d.ts.map +1 -1
- package/dist/types/utils/colors.js +8 -5
- package/dist/types/utils/colors.js.map +1 -1
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ export declare const cleanColorArray: (colors: string[]) => string[];
|
|
|
14
14
|
/**
|
|
15
15
|
* Returns the best contrasting text color (black or white) for a given background color
|
|
16
16
|
* Uses APCA contrast algorithm for accurate perception-based contrast
|
|
17
|
-
* @param backgroundColor
|
|
17
|
+
* @param backgroundColor Any valid color string (hex, rgb, rgba, named colors, etc.)
|
|
18
18
|
* @returns 'white' or 'black' depending on which has better contrast
|
|
19
19
|
*/
|
|
20
20
|
export declare const getReadableTextColor: (backgroundColor: string) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,OACR,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,EAAE,KAAG,MAAM,EACT,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,EAAE,KAAG,MAAM,EACkB,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,oBAAqB,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,OACR,CAAC;AAExC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,WAAY,MAAM,EAAE,KAAG,MAAM,EACT,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,EAAE,KAAG,MAAM,EACkB,CAAC;AAE5E;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,oBAAqB,MAAM,KAAG,MAS9D,CAAC"}
|
|
@@ -16,15 +16,18 @@ export const cleanColorArray = (colors) => colors.map((color) => color.trim()).f
|
|
|
16
16
|
/**
|
|
17
17
|
* Returns the best contrasting text color (black or white) for a given background color
|
|
18
18
|
* Uses APCA contrast algorithm for accurate perception-based contrast
|
|
19
|
-
* @param backgroundColor
|
|
19
|
+
* @param backgroundColor Any valid color string (hex, rgb, rgba, named colors, etc.)
|
|
20
20
|
* @returns 'white' or 'black' depending on which has better contrast
|
|
21
21
|
*/
|
|
22
22
|
export const getReadableTextColor = (backgroundColor) => {
|
|
23
|
-
|
|
23
|
+
try {
|
|
24
|
+
const onWhite = Math.abs(Color.contrastAPCA('white', backgroundColor));
|
|
25
|
+
const onBlack = Math.abs(Color.contrastAPCA('black', backgroundColor));
|
|
26
|
+
return onWhite > onBlack ? 'white' : 'black';
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// Not supported color string, default to black
|
|
24
30
|
return 'black';
|
|
25
31
|
}
|
|
26
|
-
const onWhite = Math.abs(Color.contrastAPCA('white', backgroundColor));
|
|
27
|
-
const onBlack = Math.abs(Color.contrastAPCA('black', backgroundColor));
|
|
28
|
-
return onWhite > onBlack ? 'white' : 'black';
|
|
29
32
|
};
|
|
30
33
|
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,uBAAuB,GACzB,mDAAmD,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAW,EAAE,CACrD,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAgB,EAAY,EAAE,CAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAErD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAY,EAAE,CAC1D,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,eAAuB,EAAU,EAAE;IACpE,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/utils/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAE/B,MAAM,uBAAuB,GACzB,mDAAmD,CAAC;AAExD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAW,EAAE,CACrD,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,MAAgB,EAAY,EAAE,CAC9D,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,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