@thecb/components 9.1.7-beta.5 → 9.1.7-beta.6
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.cjs.js +10 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +10 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/util/colorUtils.js +13 -4
package/dist/index.cjs.js
CHANGED
|
@@ -18752,6 +18752,14 @@ var hexToRbg = function hexToRbg(hexColor) {
|
|
|
18752
18752
|
var blue = parseInt(hexArr.slice(4, 6), 16);
|
|
18753
18753
|
return [red, green, blue];
|
|
18754
18754
|
};
|
|
18755
|
+
|
|
18756
|
+
var rbgToHex = function rbgToHex(rbgColor) {
|
|
18757
|
+
hexCodes = rbgColor.map(function (c) {
|
|
18758
|
+
var hex = c.toString(16).toUpperCase();
|
|
18759
|
+
return hex.length == 1 ? "0" + hex : hex;
|
|
18760
|
+
});
|
|
18761
|
+
return "#" + hexCodes.join("");
|
|
18762
|
+
};
|
|
18755
18763
|
/*
|
|
18756
18764
|
Function to calculate a new hex color given an original
|
|
18757
18765
|
hex color, a hex background color, and an opacity number
|
|
@@ -18759,7 +18767,7 @@ var hexToRbg = function hexToRbg(hexColor) {
|
|
|
18759
18767
|
|
|
18760
18768
|
For example, to add a 20% black opacity (20% darker) to a green color
|
|
18761
18769
|
("#00ff00"):
|
|
18762
|
-
addOpacityToHex("00ff00", "#000000", .2) => "
|
|
18770
|
+
addOpacityToHex("00ff00", "#000000", .2) => "#00CC00"
|
|
18763
18771
|
*/
|
|
18764
18772
|
|
|
18765
18773
|
|
|
@@ -18773,7 +18781,7 @@ var addOpacityToHex = function addOpacityToHex(hexColor, background, opacity) {
|
|
|
18773
18781
|
var newColor = color.map(function (colorElem, index) {
|
|
18774
18782
|
return Math.floor(opacity * backgroundRbg[index] + (1 - opacity) * colorElem);
|
|
18775
18783
|
});
|
|
18776
|
-
return
|
|
18784
|
+
return rbgToHex(newColor);
|
|
18777
18785
|
};
|
|
18778
18786
|
var darken = function darken(hexColor, opacity) {
|
|
18779
18787
|
return addOpacityToHex(hexColor, "#000000", opacity);
|