@qrvey/utils 1.12.0-29 → 1.12.0-30
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.
|
@@ -2,6 +2,7 @@ import { IColorType } from "../interfaces/IColorType";
|
|
|
2
2
|
/**
|
|
3
3
|
* Validates if the given color is light or dark
|
|
4
4
|
* The module extracts the rgba channels and calculate the brightness or darkness by a threshold
|
|
5
|
+
* - If there is not color provided, the returning will be Light
|
|
5
6
|
* @param color the string of the color.
|
|
6
7
|
* @returns the color type (Dark or Light)
|
|
7
8
|
*/
|
|
@@ -9,12 +9,13 @@ const isRGBAColor_1 = require("./isRGBAColor");
|
|
|
9
9
|
/**
|
|
10
10
|
* Validates if the given color is light or dark
|
|
11
11
|
* The module extracts the rgba channels and calculate the brightness or darkness by a threshold
|
|
12
|
+
* - If there is not color provided, the returning will be Light
|
|
12
13
|
* @param color the string of the color.
|
|
13
14
|
* @returns the color type (Dark or Light)
|
|
14
15
|
*/
|
|
15
16
|
function lightOrDark(color, brightnessThreshold = 127.5, opacityThreshold = 0.5) {
|
|
16
17
|
if ((0, isEmpty_1.isEmpty)(color))
|
|
17
|
-
return;
|
|
18
|
+
return COLOR_TYPE_1.COLOR_TYPE.LIGHT;
|
|
18
19
|
const rgbaColor = (0, isRGBAColor_1.isRGBAColor)(color);
|
|
19
20
|
const hexadecimalColor = (0, isHexadecimalColor_1.isHexadecimalColor)(color);
|
|
20
21
|
if (!rgbaColor && !hexadecimalColor)
|
|
@@ -2,6 +2,7 @@ import { IColorType } from "../interfaces/IColorType";
|
|
|
2
2
|
/**
|
|
3
3
|
* Validates if the given color is light or dark
|
|
4
4
|
* The module extracts the rgba channels and calculate the brightness or darkness by a threshold
|
|
5
|
+
* - If there is not color provided, the returning will be Light
|
|
5
6
|
* @param color the string of the color.
|
|
6
7
|
* @returns the color type (Dark or Light)
|
|
7
8
|
*/
|
|
@@ -6,12 +6,13 @@ import { isRGBAColor } from "./isRGBAColor";
|
|
|
6
6
|
/**
|
|
7
7
|
* Validates if the given color is light or dark
|
|
8
8
|
* The module extracts the rgba channels and calculate the brightness or darkness by a threshold
|
|
9
|
+
* - If there is not color provided, the returning will be Light
|
|
9
10
|
* @param color the string of the color.
|
|
10
11
|
* @returns the color type (Dark or Light)
|
|
11
12
|
*/
|
|
12
13
|
export function lightOrDark(color, brightnessThreshold = 127.5, opacityThreshold = 0.5) {
|
|
13
14
|
if (isEmpty(color))
|
|
14
|
-
return;
|
|
15
|
+
return COLOR_TYPE.LIGHT;
|
|
15
16
|
const rgbaColor = isRGBAColor(color);
|
|
16
17
|
const hexadecimalColor = isHexadecimalColor(color);
|
|
17
18
|
if (!rgbaColor && !hexadecimalColor)
|