@leanix/components 0.2.228 → 0.2.229

Sign up to get free protection for your applications and to get access to all the features.
@@ -1328,12 +1328,24 @@
1328
1328
  type: i0.Input
1329
1329
  }] } });
1330
1330
 
1331
+ /**
1332
+ * Compute the most eligible text color for a given background color (black or white), depending on the luminance of the
1333
+ * background color. In case the provided color is undefined or invalid, white (#FFFFFF) is returned.
1334
+ *
1335
+ * @param colorHex Color string in hexadecimal encoding.
1336
+ * @returns Equivalent contrast color in hexadecimal encoding.
1337
+ */
1331
1338
  function getContrastColor(colorHex) {
1332
- var color = Color__namespace(colorHex || '#000');
1333
- // Check http://codepen.io/WebSeed/pen/pvgqEq
1334
- var a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
1335
- var d = a < 0.4 ? 0 : 255;
1336
- return Color__namespace({ r: d, g: d, b: d }).hex();
1339
+ try {
1340
+ var color = Color__namespace(colorHex || '#000');
1341
+ // Check http://codepen.io/WebSeed/pen/pvgqEq
1342
+ var a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
1343
+ var d = a < 0.4 ? 0 : 255;
1344
+ return Color__namespace({ r: d, g: d, b: d }).hex();
1345
+ }
1346
+ catch (_a) {
1347
+ return '#FFFFFF';
1348
+ }
1337
1349
  }
1338
1350
  function shorthandHexHandle(hex) {
1339
1351
  var shorthandRegex = /^(#)([a-f\d])([a-f\d])([a-f\d])$/i;