pixelize-design-library 2.4.2-beta.21 → 2.4.2-beta.23
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.
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Button = void 0;
|
|
4
4
|
const accentText_1 = require("../../Theme/tokens/builders/accentText");
|
|
5
|
+
const color_1 = require("../../Theme/tokens/builders/color");
|
|
5
6
|
const gradientInk_1 = require("../../Theme/tokens/builders/gradientInk");
|
|
6
7
|
/**
|
|
7
8
|
* Outline/ghost/link text sits ON the canvas, so it needs a rung that stays readable there —
|
|
@@ -30,9 +31,34 @@ const onCanvasHoverBg = (theme, colorScheme, step) => {
|
|
|
30
31
|
* ~3.2 contrast.
|
|
31
32
|
*/
|
|
32
33
|
const FILL_STEP_RUNGS = { light: [600, 700], dark: [400, 300] };
|
|
34
|
+
const RUNGS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
35
|
+
const AA_NORMAL_TEXT = 4.5;
|
|
36
|
+
// Semantic scales (red/green) carry no opacity ramp; brand scales do and keep their own [500].
|
|
37
|
+
const solidRung = (theme, colorScheme) => {
|
|
38
|
+
const scale = theme.colors[colorScheme];
|
|
39
|
+
const white = theme.colors.white;
|
|
40
|
+
if ("opacity" in scale)
|
|
41
|
+
return 500;
|
|
42
|
+
if ((0, color_1.contrastRatio)(scale[500], white) >= AA_NORMAL_TEXT)
|
|
43
|
+
return 500;
|
|
44
|
+
const passing = RUNGS.filter((r) => scale[r] && (0, color_1.contrastRatio)(scale[r], white) >= AA_NORMAL_TEXT);
|
|
45
|
+
if (!passing.length)
|
|
46
|
+
return 500;
|
|
47
|
+
return passing.reduce((a, b) => (0, color_1.contrastRatio)(scale[a], white) <= (0, color_1.contrastRatio)(scale[b], white) ? a : b);
|
|
48
|
+
};
|
|
49
|
+
const steppedRung = (theme, base, step) => {
|
|
50
|
+
const dir = (0, accentText_1.isDarkCanvas)(theme.colors.backgroundColor.main) ? -100 : 100;
|
|
51
|
+
return Math.min(900, Math.max(50, base + dir * step));
|
|
52
|
+
};
|
|
33
53
|
const darkerFill = (theme, colorScheme, step) => {
|
|
34
|
-
|
|
35
|
-
|
|
54
|
+
var _a;
|
|
55
|
+
const scale = theme.colors[colorScheme];
|
|
56
|
+
const base = solidRung(theme, colorScheme);
|
|
57
|
+
if (base === 500) {
|
|
58
|
+
const mode = (0, accentText_1.isDarkCanvas)(theme.colors.backgroundColor.main) ? "dark" : "light";
|
|
59
|
+
return scale[FILL_STEP_RUNGS[mode][step]];
|
|
60
|
+
}
|
|
61
|
+
return (_a = scale[steppedRung(theme, base, step === 0 ? 1 : 2)]) !== null && _a !== void 0 ? _a : scale[base];
|
|
36
62
|
};
|
|
37
63
|
/** Label for the solid variant's filled bg — derived from THAT fill, since hover/active swap it. */
|
|
38
64
|
const labelFor = (theme, fill) => (0, accentText_1.onFilled)(fill, theme.colors.white, theme.colors.black);
|
|
@@ -49,7 +75,7 @@ exports.Button = {
|
|
|
49
75
|
}),
|
|
50
76
|
variants: {
|
|
51
77
|
solid: ({ theme, colorScheme = "primary" }) => {
|
|
52
|
-
const fill = theme.colors[colorScheme][
|
|
78
|
+
const fill = theme.colors[colorScheme][solidRung(theme, colorScheme)];
|
|
53
79
|
const hoverFill = darkerFill(theme, colorScheme, 0);
|
|
54
80
|
const activeFill = darkerFill(theme, colorScheme, 1);
|
|
55
81
|
const hoverLabel = labelFor(theme, hoverFill);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { accentTextOnCanvas, isDarkCanvas, onFilled } from "../../Theme/tokens/builders/accentText.js";
|
|
2
|
+
import { contrastRatio } from "../../Theme/tokens/builders/color.js";
|
|
2
3
|
import { resolveGradient, gradientCss } from "../../Theme/tokens/builders/gradientInk.js";
|
|
3
4
|
/**
|
|
4
5
|
* Outline/ghost/link text sits ON the canvas, so it needs a rung that stays readable there —
|
|
@@ -27,9 +28,34 @@ const onCanvasHoverBg = (theme, colorScheme, step) => {
|
|
|
27
28
|
* ~3.2 contrast.
|
|
28
29
|
*/
|
|
29
30
|
const FILL_STEP_RUNGS = { light: [600, 700], dark: [400, 300] };
|
|
31
|
+
const RUNGS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
32
|
+
const AA_NORMAL_TEXT = 4.5;
|
|
33
|
+
// Semantic scales (red/green) carry no opacity ramp; brand scales do and keep their own [500].
|
|
34
|
+
const solidRung = (theme, colorScheme) => {
|
|
35
|
+
const scale = theme.colors[colorScheme];
|
|
36
|
+
const white = theme.colors.white;
|
|
37
|
+
if ("opacity" in scale)
|
|
38
|
+
return 500;
|
|
39
|
+
if (contrastRatio(scale[500], white) >= AA_NORMAL_TEXT)
|
|
40
|
+
return 500;
|
|
41
|
+
const passing = RUNGS.filter((r) => scale[r] && contrastRatio(scale[r], white) >= AA_NORMAL_TEXT);
|
|
42
|
+
if (!passing.length)
|
|
43
|
+
return 500;
|
|
44
|
+
return passing.reduce((a, b) => contrastRatio(scale[a], white) <= contrastRatio(scale[b], white) ? a : b);
|
|
45
|
+
};
|
|
46
|
+
const steppedRung = (theme, base, step) => {
|
|
47
|
+
const dir = isDarkCanvas(theme.colors.backgroundColor.main) ? -100 : 100;
|
|
48
|
+
return Math.min(900, Math.max(50, base + dir * step));
|
|
49
|
+
};
|
|
30
50
|
const darkerFill = (theme, colorScheme, step) => {
|
|
31
|
-
|
|
32
|
-
|
|
51
|
+
var _a;
|
|
52
|
+
const scale = theme.colors[colorScheme];
|
|
53
|
+
const base = solidRung(theme, colorScheme);
|
|
54
|
+
if (base === 500) {
|
|
55
|
+
const mode = isDarkCanvas(theme.colors.backgroundColor.main) ? "dark" : "light";
|
|
56
|
+
return scale[FILL_STEP_RUNGS[mode][step]];
|
|
57
|
+
}
|
|
58
|
+
return (_a = scale[steppedRung(theme, base, step === 0 ? 1 : 2)]) !== null && _a !== void 0 ? _a : scale[base];
|
|
33
59
|
};
|
|
34
60
|
/** Label for the solid variant's filled bg — derived from THAT fill, since hover/active swap it. */
|
|
35
61
|
const labelFor = (theme, fill) => onFilled(fill, theme.colors.white, theme.colors.black);
|
|
@@ -46,7 +72,7 @@ export const Button = {
|
|
|
46
72
|
}),
|
|
47
73
|
variants: {
|
|
48
74
|
solid: ({ theme, colorScheme = "primary" }) => {
|
|
49
|
-
const fill = theme.colors[colorScheme][
|
|
75
|
+
const fill = theme.colors[colorScheme][solidRung(theme, colorScheme)];
|
|
50
76
|
const hoverFill = darkerFill(theme, colorScheme, 0);
|
|
51
77
|
const activeFill = darkerFill(theme, colorScheme, 1);
|
|
52
78
|
const hoverLabel = labelFor(theme, hoverFill);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixelize-design-library",
|
|
3
|
-
"version": "2.4.2-beta.
|
|
3
|
+
"version": "2.4.2-beta.23",
|
|
4
4
|
"description": "React component library for Pixelize apps: themeable Chakra-based components, design tokens and light/dark brand theming.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -31,9 +31,13 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@chakra-ui/react": "^2.8.2",
|
|
35
|
+
"@emotion/react": "^11.11.4",
|
|
36
|
+
"@emotion/styled": "^11.11.5",
|
|
34
37
|
"@fontsource-variable/inter": "^5.2.8",
|
|
35
38
|
"@hello-pangea/dnd": "^18.0.1",
|
|
36
39
|
"date-fns": "^3.6.0",
|
|
40
|
+
"framer-motion": "^10.18.0",
|
|
37
41
|
"jodit-react": "^5.2.38",
|
|
38
42
|
"lucide-react": "^0.487.0",
|
|
39
43
|
"react-apexcharts": "^1.4.1",
|
|
@@ -160,8 +164,6 @@
|
|
|
160
164
|
"webpack": "^5.91.0"
|
|
161
165
|
},
|
|
162
166
|
"peerDependencies": {
|
|
163
|
-
"@chakra-ui/react": "^2.8.2",
|
|
164
|
-
"framer-motion": "^10.18.0",
|
|
165
167
|
"react": "^18.3.1",
|
|
166
168
|
"react-dom": "^18.3.1"
|
|
167
169
|
},
|