@codacy/ui-components 0.65.55 → 0.65.56
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.
|
@@ -8,13 +8,24 @@ exports.functionalColorsFx = exports.functionalColors = exports.colorNames = exp
|
|
|
8
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
9
9
|
var colorNames = exports.colorNames = ['blue', 'grey', 'purple', 'orange', 'turquoise', 'magenta', 'red', 'green', 'yellow'];
|
|
10
10
|
var semantics = ['danger', 'success', 'warning', 'info', 'attention'];
|
|
11
|
+
// Hack: https://stackoverflow.com/a/44134328
|
|
12
|
+
function hslToHex(hue, saturation, lightness) {
|
|
13
|
+
lightness /= 100;
|
|
14
|
+
var a = saturation * Math.min(lightness, 1 - lightness) / 100;
|
|
15
|
+
var f = function f(n) {
|
|
16
|
+
var k = (n + hue / 30) % 12;
|
|
17
|
+
var color = lightness - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
18
|
+
return Math.round(255 * color).toString(16).padStart(2, '0'); // convert to Hex and prefix "0" if needed
|
|
19
|
+
};
|
|
20
|
+
return "#".concat(f(0)).concat(f(8)).concat(f(4));
|
|
21
|
+
}
|
|
11
22
|
var generateBaseColors = function generateBaseColors(color) {
|
|
12
23
|
var colors = {};
|
|
13
|
-
colors["".concat(color.name, "-99")] =
|
|
14
|
-
colors["".concat(color.name, "-95")] =
|
|
15
|
-
colors["".concat(color.name, "-90")] =
|
|
24
|
+
colors["".concat(color.name, "-99")] = hslToHex(color.hue, color.saturation, 98);
|
|
25
|
+
colors["".concat(color.name, "-95")] = hslToHex(color.hue, color.saturation, 95);
|
|
26
|
+
colors["".concat(color.name, "-90")] = hslToHex(color.hue, color.saturation, 90);
|
|
16
27
|
for (var i = 80; i >= 10; i -= 10) {
|
|
17
|
-
colors["".concat(color.name, "-").concat(i)] =
|
|
28
|
+
colors["".concat(color.name, "-").concat(i)] = hslToHex(color.hue, color.saturation, color.lightnessStart + i);
|
|
18
29
|
}
|
|
19
30
|
return colors;
|
|
20
31
|
};
|