@pushwoosh/kit-charts 0.1.0 → 0.2.1
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/ai-documentation.md +1 -1
- package/core/model/palette.d.ts +3 -1
- package/core/model/palette.js +9 -2
- package/package.json +3 -3
package/ai-documentation.md
CHANGED
|
@@ -26,7 +26,7 @@ npm install @pushwoosh/kit-charts
|
|
|
26
26
|
## Core Dependencies
|
|
27
27
|
|
|
28
28
|
- **react**: >= 18.0.0 (peer dependency)
|
|
29
|
-
- **styled-components**:
|
|
29
|
+
- **styled-components**: ^6.5.3 (peer dependency)
|
|
30
30
|
- **@pushwoosh/kit-constants**: runtime dependency — fonts, greys and tooltip
|
|
31
31
|
colours come from the design system tokens. The series palette is built in.
|
|
32
32
|
|
package/core/model/palette.d.ts
CHANGED
|
@@ -16,8 +16,10 @@ export declare const DEFAULT_SURFACE_COLOR: string;
|
|
|
16
16
|
* reads at 2.8:1, far under the 4.5:1 small text needs.
|
|
17
17
|
*/
|
|
18
18
|
export declare const DEFAULT_ON_FILL_TEXT_COLOR = "#FFFFFF";
|
|
19
|
+
/** WCAG contrast ratio of two colours under the active theme, or null if either cannot be read. */
|
|
20
|
+
export declare function contrastRatio(one: string, other: string): number | null;
|
|
19
21
|
/** Whichever of the two neutrals reads better on a fill. */
|
|
20
22
|
export declare function textColorOn(fill: string): string;
|
|
21
23
|
export declare const DEFAULT_TOOLTIP_SURFACE_COLOR: string;
|
|
22
|
-
export declare const DEFAULT_TOOLTIP_TEXT_COLOR
|
|
24
|
+
export declare const DEFAULT_TOOLTIP_TEXT_COLOR = "#FFFFFF";
|
|
23
25
|
export declare const colorAt: (colors: readonly string[], index: number) => string;
|
package/core/model/palette.js
CHANGED
|
@@ -34,6 +34,12 @@ const luminance = color => {
|
|
|
34
34
|
return 0.2126 * linearChannel(rgba[0]) + 0.7152 * linearChannel(rgba[1]) + 0.0722 * linearChannel(rgba[2]);
|
|
35
35
|
};
|
|
36
36
|
const contrast = (one, other) => (Math.max(one, other) + 0.05) / (Math.min(one, other) + 0.05);
|
|
37
|
+
/** WCAG contrast ratio of two colours under the active theme, or null if either cannot be read. */
|
|
38
|
+
export function contrastRatio(one, other) {
|
|
39
|
+
const first = luminance(one);
|
|
40
|
+
const second = luminance(other);
|
|
41
|
+
return first === null || second === null ? null : contrast(first, second);
|
|
42
|
+
}
|
|
37
43
|
/** Whichever of the two neutrals reads better on a fill. */
|
|
38
44
|
export function textColorOn(fill) {
|
|
39
45
|
const behind = luminance(fill);
|
|
@@ -45,7 +51,8 @@ export function textColorOn(fill) {
|
|
|
45
51
|
const dark = luminance(ON_FILL_DARK_TEXT_COLOR) ?? 0;
|
|
46
52
|
return contrast(behind, light) >= contrast(behind, dark) ? DEFAULT_ON_FILL_TEXT_COLOR : ON_FILL_DARK_TEXT_COLOR;
|
|
47
53
|
}
|
|
48
|
-
// Chart tooltips follow the product hint style: dark bubble, light text.
|
|
54
|
+
// Chart tooltips follow the product hint style: dark bubble, light text. The bubble is
|
|
55
|
+
// BRAND_BLACK in both themes, so the text cannot be `Color.CLEAR`, which goes dark too.
|
|
49
56
|
export const DEFAULT_TOOLTIP_SURFACE_COLOR = Color.BRAND_BLACK;
|
|
50
|
-
export const DEFAULT_TOOLTIP_TEXT_COLOR =
|
|
57
|
+
export const DEFAULT_TOOLTIP_TEXT_COLOR = DEFAULT_ON_FILL_TEXT_COLOR;
|
|
51
58
|
export const colorAt = (colors, index) => colors[index % colors.length] ?? DEFAULT_COLORS[index % DEFAULT_COLORS.length];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/kit-charts",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Small React chart library on SVG, with a Highcharts-shaped configuration model",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@pushwoosh/kit-constants": "^2.1.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@pushwoosh/frontend-builder-engine": "^3.1.
|
|
32
|
+
"@pushwoosh/frontend-builder-engine": "^3.1.6",
|
|
33
33
|
"@testing-library/dom": "^10.4.2",
|
|
34
34
|
"@testing-library/jest-dom": "^6.9.1",
|
|
35
35
|
"@testing-library/react": "^16.3.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=18.0.0",
|
|
48
|
-
"styled-components": "
|
|
48
|
+
"styled-components": "^6.5.3"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">= 24"
|