@ancon/wildcat-utils 1.50.17 → 1.50.18
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,8 +1,18 @@
|
|
|
1
|
+
import { WCAG2Options } from 'tinycolor2';
|
|
2
|
+
declare type ReadabilityOptions = WCAG2Options & {
|
|
3
|
+
/**
|
|
4
|
+
* Override WCAG2 readability standards with a custom minimum contrast ratio.
|
|
5
|
+
* Colors pass readability if contrast >= this threshold.
|
|
6
|
+
*/
|
|
7
|
+
minimumReadableContrast?: number;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Ensure that foreground and background color combinations are readable
|
|
3
11
|
*
|
|
4
12
|
* @param fgColor - The foreground color
|
|
5
13
|
* @param bgColor - The background color
|
|
14
|
+
* @param options - The WCAG2 options extended with a custom minimum contrast ratio
|
|
6
15
|
* @returns Whether the color combinations are readable
|
|
7
16
|
*/
|
|
8
|
-
export default function isColorsReadable(fgColor: string, bgColor: string): boolean;
|
|
17
|
+
export default function isColorsReadable(fgColor: string, bgColor: string, options?: ReadabilityOptions): boolean;
|
|
18
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const s=require("tinycolor2"),d=1,m=21;function u(t,a,e){const{level:i,size:o,minimumReadableContrast:n}=e??{};if(n){const c=s.readability(t,a),l=Math.min(Math.max(n,d),m);return c>=l}const r={level:i,size:o};return s.isReadable(t,a,r)}module.exports=u;
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import o from "tinycolor2";
|
|
2
|
+
const m = 1, d = 21;
|
|
3
|
+
function R(t, a, e) {
|
|
4
|
+
const { level: s, size: i, minimumReadableContrast: n } = e ?? {};
|
|
5
|
+
if (n) {
|
|
6
|
+
const c = o.readability(t, a), l = Math.min(
|
|
7
|
+
Math.max(n, m),
|
|
8
|
+
d
|
|
9
|
+
);
|
|
10
|
+
return c >= l;
|
|
11
|
+
}
|
|
12
|
+
const r = { level: s, size: i };
|
|
13
|
+
return o.isReadable(t, a, r);
|
|
4
14
|
}
|
|
5
15
|
export {
|
|
6
|
-
|
|
16
|
+
R as default
|
|
7
17
|
};
|