@jobber/components-native 0.76.0 → 0.77.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/dist/package.json +2 -2
- package/dist/src/AtlantisThemeContext/AtlantisThemeContext.js +32 -0
- package/dist/src/AtlantisThemeContext/index.js +1 -0
- package/dist/src/AtlantisThemeContext/types.js +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/utils/design/index.js +5 -0
- package/dist/src/utils/meta/meta.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisThemeContext/AtlantisThemeContext.d.ts +3 -0
- package/dist/types/src/AtlantisThemeContext/index.d.ts +2 -0
- package/dist/types/src/AtlantisThemeContext/types.d.ts +27 -0
- package/dist/types/src/Button/Button.d.ts +1 -1
- package/dist/types/src/Text/Text.d.ts +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/utils/design/index.d.ts +5 -0
- package/package.json +2 -2
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +106 -0
- package/src/AtlantisThemeContext/AtlantisThemeContext.tsx +56 -0
- package/src/AtlantisThemeContext/index.ts +9 -0
- package/src/AtlantisThemeContext/types.ts +33 -0
- package/src/Button/Button.tsx +1 -1
- package/src/Text/Text.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/utils/design/index.ts +5 -0
- package/src/utils/meta/meta.json +1 -0
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"react-native-safe-area-context": "^4.5.2",
|
|
81
81
|
"react-native-svg": ">=12.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "ddce093f19e0b03e0d33b7706842dc94b6c65739"
|
|
84
84
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { androidTokens, darkTokens, iosTokens } from "@jobber/design";
|
|
2
|
+
import React, { createContext, useContext, useState } from "react";
|
|
3
|
+
import merge from "lodash/merge";
|
|
4
|
+
import { Platform } from "react-native";
|
|
5
|
+
const lightTokens = Platform.select({
|
|
6
|
+
ios: () => iosTokens,
|
|
7
|
+
android: () => androidTokens,
|
|
8
|
+
default: () => androidTokens,
|
|
9
|
+
})();
|
|
10
|
+
const completeDarkTokens = merge({}, lightTokens, darkTokens);
|
|
11
|
+
const AtlantisThemeContext = createContext({
|
|
12
|
+
theme: "light",
|
|
13
|
+
tokens: lightTokens,
|
|
14
|
+
setTheme: () => {
|
|
15
|
+
console.error("useAtlantisTheme accessed outside of AtlantisThemeContextProvider");
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
export function AtlantisThemeContextProvider({ children, dangerouslyOverrideTheme, }) {
|
|
19
|
+
// TODO: check last saved theme from local/device storage
|
|
20
|
+
const initialTheme = "light";
|
|
21
|
+
const [globalTheme, setGlobalTheme] = useState(initialTheme);
|
|
22
|
+
const currentTheme = dangerouslyOverrideTheme !== null && dangerouslyOverrideTheme !== void 0 ? dangerouslyOverrideTheme : globalTheme;
|
|
23
|
+
const currentTokens = currentTheme === "dark" ? completeDarkTokens : lightTokens;
|
|
24
|
+
return (React.createElement(AtlantisThemeContext.Provider, { value: {
|
|
25
|
+
theme: currentTheme,
|
|
26
|
+
tokens: currentTokens,
|
|
27
|
+
setTheme: setGlobalTheme,
|
|
28
|
+
} }, children));
|
|
29
|
+
}
|
|
30
|
+
export function useAtlantisTheme() {
|
|
31
|
+
return useContext(AtlantisThemeContext);
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AtlantisThemeContextProvider, useAtlantisTheme, } from "./AtlantisThemeContext";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./ActionItem";
|
|
|
2
2
|
export * from "./ActionLabel";
|
|
3
3
|
export * from "./ActivityIndicator";
|
|
4
4
|
export * from "./AtlantisContext";
|
|
5
|
+
export * from "./AtlantisThemeContext";
|
|
5
6
|
export * from "./AutoLink";
|
|
6
7
|
export * from "./Banner";
|
|
7
8
|
export * from "./BottomSheet";
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
2
|
import { androidTokens, iosTokens } from "@jobber/design";
|
|
3
|
+
/**
|
|
4
|
+
* These design tokens don't react to theme changes. Only use these if you need to access
|
|
5
|
+
* tokens that are not affected by the current theme, otherwise you should be using our
|
|
6
|
+
* useAtlantisTheme() hook to access the current theme's tokens.
|
|
7
|
+
*/
|
|
3
8
|
export const tokens = Platform.select({
|
|
4
9
|
ios: () => iosTokens,
|
|
5
10
|
android: () => androidTokens,
|