@multiplatform.one/theme 7.2.0 → 7.2.2
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.2.
|
|
3
|
+
"version": "7.2.2",
|
|
4
4
|
"description": "Tamagui theme system for multiplatform.one",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multiplatform",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@tamagui/toast": "2.7.6",
|
|
54
54
|
"@tamagui/web": "2.7.6",
|
|
55
55
|
"react-cookie": "^8.1.2",
|
|
56
|
-
"@multiplatform.one/platform": "7.2.
|
|
57
|
-
"@multiplatform.one/store": "7.2.
|
|
56
|
+
"@multiplatform.one/platform": "7.2.2",
|
|
57
|
+
"@multiplatform.one/store": "7.2.2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@tamagui/animations-css": "2.7.6",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"tamagui": "2.7.6",
|
|
70
70
|
"typescript": "~5.9.3",
|
|
71
71
|
"vitest": "^4.1.5",
|
|
72
|
-
"@multiplatform.one/config": "7.2.
|
|
73
|
-
"@multiplatform.one/test-utils": "7.2.
|
|
72
|
+
"@multiplatform.one/config": "7.2.2",
|
|
73
|
+
"@multiplatform.one/test-utils": "7.2.2"
|
|
74
74
|
},
|
|
75
75
|
"peerDependencies": {
|
|
76
76
|
"@tamagui/animations-css": "^2.0.0-rc",
|
|
@@ -2,6 +2,7 @@ import { ToastProvider } from "@tamagui/toast";
|
|
|
2
2
|
import { useContext, useMemo } from "react";
|
|
3
3
|
import { type CreateTamaguiProps, TamaguiProvider, type TamaguiProviderProps } from "tamagui";
|
|
4
4
|
import type { PropsWithChildren } from "react";
|
|
5
|
+
import { FontKnobStyles } from "./FontKnobStyles";
|
|
5
6
|
import { PresetContext, type PresetContextValue } from "./PresetContext";
|
|
6
7
|
import { defaultPreset } from "./presets";
|
|
7
8
|
import { useTheme } from "./useTheme";
|
|
@@ -57,9 +58,16 @@ function KnobBridge({ children }: PropsWithChildren) {
|
|
|
57
58
|
[knobs],
|
|
58
59
|
);
|
|
59
60
|
|
|
61
|
+
const tree = (
|
|
62
|
+
<>
|
|
63
|
+
<FontKnobStyles />
|
|
64
|
+
{children}
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
|
|
60
68
|
if (existingCtx) {
|
|
61
|
-
return
|
|
69
|
+
return tree;
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
return <PresetContext.Provider value={presetCtxValue}>{
|
|
72
|
+
return <PresetContext.Provider value={presetCtxValue}>{tree}</PresetContext.Provider>;
|
|
65
73
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
describe("ThemeProvider knob injectors", () => {
|
|
9
|
+
it("mounts FontKnobStyles inside KnobBridge so shipped apps inherit heading/body fonts", () => {
|
|
10
|
+
const src = readFileSync(join(here, "theme.tsx"), "utf8");
|
|
11
|
+
expect(src).toMatch(/import \{ FontKnobStyles \} from "\.\/FontKnobStyles"/);
|
|
12
|
+
expect(src).toContain("<FontKnobStyles");
|
|
13
|
+
expect(src).toContain("function KnobBridge");
|
|
14
|
+
const bridge = src.slice(src.indexOf("function KnobBridge"));
|
|
15
|
+
expect(bridge).toContain("<FontKnobStyles");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("does not invent a second knob store — cookies still feed PresetContext", () => {
|
|
19
|
+
const src = readFileSync(join(here, "theme.tsx"), "utf8");
|
|
20
|
+
expect(src).toContain("readPresetCookie");
|
|
21
|
+
expect(src).toContain("readOverridesCookie");
|
|
22
|
+
expect(src).toContain("PresetContext.Provider");
|
|
23
|
+
});
|
|
24
|
+
});
|
package/src/theme/theme.tsx
CHANGED
|
@@ -5,6 +5,7 @@ import { type CreateTamaguiProps, TamaguiProvider, type TamaguiProviderProps } f
|
|
|
5
5
|
import type { PropsWithChildren } from "react";
|
|
6
6
|
import { animationDurations } from "./animations/css";
|
|
7
7
|
import { getCookieWatchList, readOverridesCookie, readPresetCookie } from "./cookies";
|
|
8
|
+
import { FontKnobStyles } from "./FontKnobStyles";
|
|
8
9
|
import { PresetContext, type PresetContextValue } from "./PresetContext";
|
|
9
10
|
import { defaultPreset } from "./presets";
|
|
10
11
|
import { getPreset } from "./shared";
|
|
@@ -155,6 +156,10 @@ export function ThemeProvider<T extends CreateTamaguiProps>({
|
|
|
155
156
|
*
|
|
156
157
|
* If an ancestor PresetContext already exists (e.g. from a Storybook decorator),
|
|
157
158
|
* the bridge is a pass-through to avoid overriding it.
|
|
159
|
+
*
|
|
160
|
+
* FontKnobStyles mounts here (not only in Storybook CreatePreview) so
|
|
161
|
+
* headingFont/bodyFont restyle every shipped app that uses ThemeProvider.
|
|
162
|
+
* Hairline and corner-smoothing already self-mount on module load.
|
|
158
163
|
*/
|
|
159
164
|
function KnobBridge({ children }: PropsWithChildren) {
|
|
160
165
|
const existingCtx = useContext(PresetContext);
|
|
@@ -182,9 +187,18 @@ function KnobBridge({ children }: PropsWithChildren) {
|
|
|
182
187
|
document.documentElement.style.setProperty("--mp-transition", `${durationMs}ms`);
|
|
183
188
|
}, [animationValue]);
|
|
184
189
|
|
|
190
|
+
// Inside the provider (or the Storybook ancestor context) so the
|
|
191
|
+
// heading/body CSS vars follow the same cookie path as useResolvedKnobs.
|
|
192
|
+
const tree = (
|
|
193
|
+
<>
|
|
194
|
+
<FontKnobStyles />
|
|
195
|
+
{children}
|
|
196
|
+
</>
|
|
197
|
+
);
|
|
198
|
+
|
|
185
199
|
if (existingCtx) {
|
|
186
|
-
return
|
|
200
|
+
return tree;
|
|
187
201
|
}
|
|
188
202
|
|
|
189
|
-
return <PresetContext.Provider value={presetCtxValue}>{
|
|
203
|
+
return <PresetContext.Provider value={presetCtxValue}>{tree}</PresetContext.Provider>;
|
|
190
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,kBAAkB,EAAmB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/theme/theme.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,kBAAkB,EAAmB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAkB5D;AAMD,MAAM,WAAW,kBAAkB,CACjC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,CACjD,SAAQ,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,cAAc,CAAC,CAAC;IAChF,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,UAAU,CAAC,cAAc,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KAChE,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,kBAAkB,EAAE,EAC1D,QAAQ,EACR,MAAM,EACN,WAAqB,EACrB,GAAG,YAAY,EAChB,EAAE,kBAAkB,CAAC,CAAC,CAAC,2CAiFvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.native.d.ts","sourceRoot":"","sources":["../../src/theme/theme.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAmB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"theme.native.d.ts","sourceRoot":"","sources":["../../src/theme/theme.native.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,kBAAkB,EAAmB,KAAK,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC9F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAU/C,MAAM,WAAW,kBAAkB,CACjC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,CACjD,SAAQ,iBAAiB,CAAC,IAAI,CAAC,oBAAoB,EAAE,QAAQ,GAAG,cAAc,CAAC,CAAC;IAChF,MAAM,CAAC,EAAE;QACP,OAAO,EAAE,UAAU,CAAC,cAAc,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KAChE,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CAChC;AAMD,wBAAgB,aAAa,CAAC,CAAC,SAAS,kBAAkB,EAAE,EAC1D,QAAQ,EACR,MAAM,EACN,WAAqB,EACrB,GAAG,YAAY,EAChB,EAAE,kBAAkB,CAAC,CAAC,CAAC,2CAevB"}
|