@leanix/components 0.2.228 → 0.2.229

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.
@@ -1,10 +1,22 @@
1
1
  import * as Color from 'color';
2
+ /**
3
+ * Compute the most eligible text color for a given background color (black or white), depending on the luminance of the
4
+ * background color. In case the provided color is undefined or invalid, white (#FFFFFF) is returned.
5
+ *
6
+ * @param colorHex Color string in hexadecimal encoding.
7
+ * @returns Equivalent contrast color in hexadecimal encoding.
8
+ */
2
9
  export function getContrastColor(colorHex) {
3
- const color = Color(colorHex || '#000');
4
- // Check http://codepen.io/WebSeed/pen/pvgqEq
5
- const a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
6
- const d = a < 0.4 ? 0 : 255;
7
- return Color({ r: d, g: d, b: d }).hex();
10
+ try {
11
+ const color = Color(colorHex || '#000');
12
+ // Check http://codepen.io/WebSeed/pen/pvgqEq
13
+ const a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
14
+ const d = a < 0.4 ? 0 : 255;
15
+ return Color({ r: d, g: d, b: d }).hex();
16
+ }
17
+ catch (_a) {
18
+ return '#FFFFFF';
19
+ }
8
20
  }
9
21
  export function shorthandHexHandle(hex) {
10
22
  const shorthandRegex = /^(#)([a-f\d])([a-f\d])([a-f\d])$/i;
@@ -1 +1 @@
1
- {"version":3,"file":"core-css.helpers.js","sourceRoot":"","sources":["core-css.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC;IACxC,6CAA6C;IAC7C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,KAA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AAG,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC;QACzF,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAC5B,OAAO,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;KAC1C;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAW;IAC5C,MAAM,cAAc,GAAG,mCAAmC,CAAC;IAC3D,MAAM,SAAS,GAAG,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC5C,IAAI,SAAS,EAAE;QACb,MAAM,YAAY,GAAG,SAAS,CAAC,CAAC,CAAE,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAC7H,OAAO,YAAY,CAAC;KACrB;SAAM;QACL,OAAO,GAAG,CAAC;KACZ;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAa;IAC3C,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -928,12 +928,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.4", ngImpor
928
928
  type: Input
929
929
  }] } });
930
930
 
931
+ /**
932
+ * Compute the most eligible text color for a given background color (black or white), depending on the luminance of the
933
+ * background color. In case the provided color is undefined or invalid, white (#FFFFFF) is returned.
934
+ *
935
+ * @param colorHex Color string in hexadecimal encoding.
936
+ * @returns Equivalent contrast color in hexadecimal encoding.
937
+ */
931
938
  function getContrastColor(colorHex) {
932
- const color = Color(colorHex || '#000');
933
- // Check http://codepen.io/WebSeed/pen/pvgqEq
934
- const a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
935
- const d = a < 0.4 ? 0 : 255;
936
- return Color({ r: d, g: d, b: d }).hex();
939
+ try {
940
+ const color = Color(colorHex || '#000');
941
+ // Check http://codepen.io/WebSeed/pen/pvgqEq
942
+ const a = 1 - (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
943
+ const d = a < 0.4 ? 0 : 255;
944
+ return Color({ r: d, g: d, b: d }).hex();
945
+ }
946
+ catch (_a) {
947
+ return '#FFFFFF';
948
+ }
937
949
  }
938
950
  function shorthandHexHandle(hex) {
939
951
  const shorthandRegex = /^(#)([a-f\d])([a-f\d])([a-f\d])$/i;