@multiplatform.one/theme 7.84.0 → 7.84.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/theme",
|
|
3
|
-
"version": "7.84.
|
|
3
|
+
"version": "7.84.1",
|
|
4
4
|
"description": "Tamagui theme system for multiplatform.one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multiplatform",
|
|
@@ -115,8 +115,8 @@
|
|
|
115
115
|
"access": "public"
|
|
116
116
|
},
|
|
117
117
|
"dependencies": {
|
|
118
|
-
"@multiplatform.one/platform": "^7.84.
|
|
119
|
-
"@multiplatform.one/store": "^7.84.
|
|
118
|
+
"@multiplatform.one/platform": "^7.84.1",
|
|
119
|
+
"@multiplatform.one/store": "^7.84.1",
|
|
120
120
|
"@tamagui/animations-react-native": "2.7.6",
|
|
121
121
|
"@tamagui/colors": "2.7.6",
|
|
122
122
|
"@tamagui/config": "2.7.6",
|
|
@@ -132,20 +132,20 @@
|
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
134
|
"@expo/prebuild-config": "55.0.18",
|
|
135
|
-
"@multiplatform.one/config": "7.84.
|
|
136
|
-
"@multiplatform.one/test-utils": "7.84.
|
|
135
|
+
"@multiplatform.one/config": "7.84.1",
|
|
136
|
+
"@multiplatform.one/test-utils": "7.84.1",
|
|
137
137
|
"@tamagui/animations-css": "2.7.6",
|
|
138
138
|
"@tamagui/animations-reanimated": "2.7.6",
|
|
139
139
|
"@tamagui/build": "2.7.6",
|
|
140
140
|
"@tamagui/font-inter": "2.7.6",
|
|
141
141
|
"@testing-library/react": "^16.3.3",
|
|
142
142
|
"@vitejs/plugin-react": "^6.1.2",
|
|
143
|
-
"@vitest/coverage-v8": "^4.1.
|
|
143
|
+
"@vitest/coverage-v8": "^4.1.12",
|
|
144
144
|
"react": "19.2.5",
|
|
145
145
|
"react-dom": "19.2.5",
|
|
146
146
|
"tamagui": "2.7.6",
|
|
147
147
|
"typescript": "~5.9.3",
|
|
148
|
-
"vitest": "^4.1.
|
|
148
|
+
"vitest": "^4.1.12"
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"@tamagui/animations-css": "^2.0.0-rc",
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
2
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
3
|
+
import { semanticGroups } from "../colorRules";
|
|
4
|
+
import { defaultKnobs } from "../knobs";
|
|
5
|
+
import { ColorLineVisualizer } from "./ColorLineVisualizer";
|
|
6
|
+
import { cellSize } from "./vizConstants";
|
|
7
|
+
|
|
8
|
+
const ramp = (hue: number) =>
|
|
9
|
+
Array.from({ length: 12 }, (_, i) => `hsl(${hue}, 60%, ${90 - i * 6}%)`);
|
|
10
|
+
|
|
11
|
+
function normalized(color: string) {
|
|
12
|
+
const probe = document.createElement("div");
|
|
13
|
+
probe.style.background = color;
|
|
14
|
+
return probe.style.background;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function stepCells() {
|
|
18
|
+
return Array.from({ length: 12 }, (_, i) => screen.getAllByTitle(`$color${i + 1}`));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
afterEach(() => {
|
|
22
|
+
cleanup();
|
|
23
|
+
document.documentElement.removeAttribute("style");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("ColorLineVisualizer", () => {
|
|
27
|
+
it("paints the twelve steps of the given ramp in order, numbered 1 to 12", () => {
|
|
28
|
+
const colors = ramp(210);
|
|
29
|
+
render(<ColorLineVisualizer knobs={defaultKnobs} isDark={false} themeColors={colors} />);
|
|
30
|
+
expect(screen.getByText("Theme")).toBeTruthy();
|
|
31
|
+
stepCells().forEach(([cell], i) => {
|
|
32
|
+
expect(cell.textContent).toBe(String(i + 1));
|
|
33
|
+
expect(cell.style.background).toBe(normalized(colors[i]));
|
|
34
|
+
expect(cell.style.width).toBe(`${cellSize}px`);
|
|
35
|
+
expect(cell.style.height).toBe(`${cellSize}px`);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("brackets every semantic group over the steps it spans", () => {
|
|
40
|
+
render(<ColorLineVisualizer knobs={defaultKnobs} isDark={false} themeColors={ramp(30)} />);
|
|
41
|
+
for (const group of semanticGroups) {
|
|
42
|
+
const bracket = screen.getByText(group.label).parentElement as HTMLElement;
|
|
43
|
+
expect(bracket.style.left).toBe(`${(group.from - 1) * cellSize}px`);
|
|
44
|
+
expect(bracket.style.width).toBe(`${(group.to - group.from + 1) * cellSize}px`);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("adds a half-height opposite row and an accent section only for full ramps", () => {
|
|
49
|
+
const { rerender } = render(
|
|
50
|
+
<ColorLineVisualizer
|
|
51
|
+
knobs={defaultKnobs}
|
|
52
|
+
isDark={false}
|
|
53
|
+
themeColors={ramp(210)}
|
|
54
|
+
oppositeThemeColors={ramp(200).slice(0, 11)}
|
|
55
|
+
accentColors={ramp(120).slice(0, 4)}
|
|
56
|
+
/>,
|
|
57
|
+
);
|
|
58
|
+
expect(stepCells().every((cells) => cells.length === 1)).toBe(true);
|
|
59
|
+
expect(screen.queryByText("accent")).toBeNull();
|
|
60
|
+
|
|
61
|
+
const opposite = ramp(200);
|
|
62
|
+
const accent = ramp(120);
|
|
63
|
+
rerender(
|
|
64
|
+
<ColorLineVisualizer
|
|
65
|
+
knobs={defaultKnobs}
|
|
66
|
+
isDark={false}
|
|
67
|
+
themeColors={ramp(210)}
|
|
68
|
+
oppositeThemeColors={opposite}
|
|
69
|
+
accentColors={accent}
|
|
70
|
+
oppositeAccentColors={ramp(100)}
|
|
71
|
+
/>,
|
|
72
|
+
);
|
|
73
|
+
expect(screen.getByText("accent")).toBeTruthy();
|
|
74
|
+
const cells = stepCells();
|
|
75
|
+
expect(cells.every((rows) => rows.length === 4)).toBe(true);
|
|
76
|
+
const [, oppositeRow, accentRow, oppositeAccentRow] = cells[0];
|
|
77
|
+
expect(oppositeRow.style.height).toBe(`${Math.round(cellSize / 2)}px`);
|
|
78
|
+
expect(oppositeRow.style.background).toBe(normalized(opposite[0]));
|
|
79
|
+
expect(accentRow.style.height).toBe(`${cellSize}px`);
|
|
80
|
+
expect(accentRow.style.background).toBe(normalized(accent[0]));
|
|
81
|
+
expect(oppositeAccentRow.style.height).toBe(`${Math.round(cellSize / 2)}px`);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("reads the page's --color1..12 when no ramp is passed", () => {
|
|
85
|
+
const colors = ramp(330);
|
|
86
|
+
colors.forEach((color, i) =>
|
|
87
|
+
document.documentElement.style.setProperty(`--color${i + 1}`, color),
|
|
88
|
+
);
|
|
89
|
+
render(<ColorLineVisualizer knobs={defaultKnobs} isDark={false} />);
|
|
90
|
+
stepCells().forEach(([cell], i) => {
|
|
91
|
+
expect(cell.style.background).toBe(normalized(colors[i]));
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("draws its card in the scheme it is told", () => {
|
|
96
|
+
const { container, rerender } = render(
|
|
97
|
+
<ColorLineVisualizer knobs={defaultKnobs} isDark={false} themeColors={ramp(0)} />,
|
|
98
|
+
);
|
|
99
|
+
const light = (container.firstElementChild as HTMLElement).style.background;
|
|
100
|
+
rerender(<ColorLineVisualizer knobs={defaultKnobs} isDark themeColors={ramp(0)} />);
|
|
101
|
+
const dark = (container.firstElementChild as HTMLElement).style.background;
|
|
102
|
+
expect(light).not.toBe(dark);
|
|
103
|
+
});
|
|
104
|
+
});
|