@jobber/components-native 0.114.7 → 0.114.9
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/dist/package.json +3 -3
- package/dist/src/AtlantisThemeContext/AtlantisThemeContext.js +7 -2
- package/dist/src/AtlantisThemeContext/AtlantisThemeContext.test.js +9 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/AtlantisThemeContext/AtlantisThemeContext.guide.md +11 -0
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +24 -1
- package/src/AtlantisThemeContext/AtlantisThemeContext.tsx +14 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.9",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/runtime": "^7.29.2",
|
|
75
75
|
"@gorhom/bottom-sheet": "^5.2.8",
|
|
76
|
-
"@jobber/design": "0.117.
|
|
76
|
+
"@jobber/design": "0.117.1",
|
|
77
77
|
"@jobber/hooks": "2.21.1",
|
|
78
78
|
"@react-native-community/datetimepicker": "^8.4.5",
|
|
79
79
|
"@react-native/babel-preset": "^0.82.1",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"react-native-screens": ">=4.18.0",
|
|
124
124
|
"react-native-svg": ">=12.0.0"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "03a318392b77ae6bb66564ec8bc82416f0cb8da7"
|
|
127
127
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { androidTokens, darkTokens, iosTokens } from "@jobber/design";
|
|
2
2
|
import React, { createContext, useCallback, useContext, useState } from "react";
|
|
3
|
-
import
|
|
3
|
+
import mergeWith from "lodash/mergeWith";
|
|
4
4
|
import { Platform, useColorScheme } from "react-native";
|
|
5
5
|
const lightTokens = Platform.select({
|
|
6
6
|
ios: () => iosTokens,
|
|
7
7
|
android: () => androidTokens,
|
|
8
8
|
default: () => androidTokens,
|
|
9
9
|
})();
|
|
10
|
-
const completeDarkTokens =
|
|
10
|
+
const completeDarkTokens = mergeWith({}, lightTokens, darkTokens, (platformValue, darkValue) => {
|
|
11
|
+
const platformValueIsObject = typeof platformValue === "object" && platformValue !== null;
|
|
12
|
+
const darkValueIsObject = typeof darkValue === "object" && darkValue !== null;
|
|
13
|
+
if (platformValueIsObject && !darkValueIsObject)
|
|
14
|
+
return platformValue;
|
|
15
|
+
});
|
|
11
16
|
const defaultAtlantisThemeContextValue = {
|
|
12
17
|
theme: "light",
|
|
13
18
|
effectiveTheme: "light",
|
|
@@ -21,7 +21,7 @@ jest.mock("react-native", () => {
|
|
|
21
21
|
});
|
|
22
22
|
return actual;
|
|
23
23
|
});
|
|
24
|
-
const expectedDarkTokens = merge({}, iosTokens, darkTokens);
|
|
24
|
+
const expectedDarkTokens = Object.assign(Object.assign({}, merge({}, iosTokens, darkTokens)), { "shadow-low": iosTokens["shadow-low"], "shadow-base": iosTokens["shadow-base"], "shadow-high": iosTokens["shadow-high"] });
|
|
25
25
|
const expectedLightTokens = iosTokens;
|
|
26
26
|
const mockUseColorScheme = useColorScheme;
|
|
27
27
|
function Wrapper({ children, theme, onThemeChange, dangerouslyOverrideTheme, }) {
|
|
@@ -56,6 +56,14 @@ describe("ThemeContext", () => {
|
|
|
56
56
|
expect(result.current.effectiveTheme).toBe("light");
|
|
57
57
|
expect(result.current.tokens).toEqual(expectedLightTokens);
|
|
58
58
|
}));
|
|
59
|
+
it.each(["shadow-low", "shadow-base", "shadow-high"])("keeps the platform-native %s token in dark mode", (shadowToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const { result } = renderHook(useAtlantisTheme, {
|
|
61
|
+
wrapper: (props) => (React.createElement(Wrapper, Object.assign({}, props))),
|
|
62
|
+
});
|
|
63
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () { return result.current.setTheme("dark"); }));
|
|
64
|
+
expect(result.current.tokens[shadowToken]).toEqual(iosTokens[shadowToken]);
|
|
65
|
+
expect(typeof result.current.tokens[shadowToken]).toBe("object");
|
|
66
|
+
}));
|
|
59
67
|
it("resolves the system theme from the OS color scheme", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
68
|
mockUseColorScheme.mockReturnValue("dark");
|
|
61
69
|
const { result, rerender } = renderHook(useAtlantisTheme, {
|