@jobber/components-native 0.76.1-JOB-116234-314c5ff.22 → 0.76.1-JOB-116234-d279b0f.20
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 +21 -10
- package/dist/src/Typography/Typography.style.js +8 -1
- package/dist/src/utils/design/index.js +2 -5
- package/dist/src/utils/meta/meta.json +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisThemeContext/types.d.ts +3 -6
- package/dist/types/src/Button/Button.d.ts +1 -1
- package/dist/types/src/Text/Text.d.ts +1 -1
- package/dist/types/src/Typography/Typography.style.d.ts +8 -1
- package/dist/types/src/utils/design/index.d.ts +0 -5
- package/package.json +2 -2
- package/src/AtlantisThemeContext/AtlantisThemeContext.tsx +54 -12
- package/src/AtlantisThemeContext/types.ts +3 -7
- package/src/Button/Button.tsx +1 -1
- package/src/Text/Text.tsx +1 -1
- package/src/Typography/Typography.style.ts +8 -1
- package/src/utils/design/index.ts +2 -5
- package/src/utils/meta/meta.json +0 -1
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +0 -106
- package/src/AtlantisThemeContext/buildThemedStyles.test.tsx +0 -83
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.76.1-JOB-116234-
|
|
3
|
+
"version": "0.76.1-JOB-116234-d279b0f.20+d279b0fd",
|
|
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": "d279b0fddc435572c48dff35f02db80ee4ca3ee7"
|
|
84
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { androidTokens, darkTokens, iosTokens } from "@jobber/design";
|
|
2
|
-
import React, { createContext, useContext, useState } from "react";
|
|
2
|
+
import React, { createContext, useContext, useState, } from "react";
|
|
3
3
|
import merge from "lodash/merge";
|
|
4
4
|
import { Platform } from "react-native";
|
|
5
5
|
const lightTokens = Platform.select({
|
|
@@ -11,20 +11,31 @@ const completeDarkTokens = merge({}, lightTokens, darkTokens);
|
|
|
11
11
|
const AtlantisThemeContext = createContext({
|
|
12
12
|
theme: "light",
|
|
13
13
|
tokens: lightTokens,
|
|
14
|
-
setTheme: () => {
|
|
15
|
-
console.error("useAtlantisTheme accessed outside of AtlantisThemeContextProvider");
|
|
16
|
-
},
|
|
17
14
|
});
|
|
18
15
|
export function AtlantisThemeContextProvider({ children, dangerouslyOverrideTheme, }) {
|
|
19
|
-
|
|
16
|
+
if (dangerouslyOverrideTheme) {
|
|
17
|
+
return (React.createElement(InternalStaticThemeProvider, { dangerouslyOverrideTheme: dangerouslyOverrideTheme }, children));
|
|
18
|
+
}
|
|
19
|
+
return (React.createElement(InternalDynamicThemeProvider, null, children));
|
|
20
|
+
}
|
|
21
|
+
function InternalDynamicThemeProvider({ children }) {
|
|
22
|
+
// TODO: check initial theme from local/device storage?
|
|
23
|
+
// const initialTheme: Theme = (globalThis.document.documentElement.dataset.theme as Theme) ?? "light";
|
|
20
24
|
const initialTheme = "light";
|
|
21
|
-
const [
|
|
22
|
-
const
|
|
23
|
-
|
|
25
|
+
const [internalTheme] = useState(initialTheme);
|
|
26
|
+
const currentTokens = internalTheme === "dark" ? completeDarkTokens : lightTokens;
|
|
27
|
+
// TODO: listen for global theme update -> setInternalTheme
|
|
28
|
+
// See web's AtlantisThemeContext for an example of how it does this.
|
|
29
|
+
return (React.createElement(AtlantisThemeContext.Provider, { value: {
|
|
30
|
+
theme: internalTheme,
|
|
31
|
+
tokens: currentTokens,
|
|
32
|
+
} }, children));
|
|
33
|
+
}
|
|
34
|
+
function InternalStaticThemeProvider({ dangerouslyOverrideTheme, children, }) {
|
|
35
|
+
const currentTokens = dangerouslyOverrideTheme === "dark" ? completeDarkTokens : lightTokens;
|
|
24
36
|
return (React.createElement(AtlantisThemeContext.Provider, { value: {
|
|
25
|
-
theme:
|
|
37
|
+
theme: dangerouslyOverrideTheme,
|
|
26
38
|
tokens: currentTokens,
|
|
27
|
-
setTheme: setGlobalTheme,
|
|
28
39
|
} }, children));
|
|
29
40
|
}
|
|
30
41
|
export function useAtlantisTheme() {
|
|
@@ -354,7 +354,14 @@ export const createTypographyTokens = (tokens) => (Object.assign(Object.assign({
|
|
|
354
354
|
textDecorationLine: "line-through",
|
|
355
355
|
} }));
|
|
356
356
|
/**
|
|
357
|
-
*
|
|
357
|
+
* `StyleSheet` for Typography.tsx.
|
|
358
|
+
*
|
|
359
|
+
* If you find yourself needing to use what's inside this object on files other
|
|
360
|
+
* than `<Typography />`, please import from `@jobber/components-native` instead.
|
|
361
|
+
*
|
|
362
|
+
* ```
|
|
363
|
+
* import { typographyStyles } from "@jobber/components-native"
|
|
364
|
+
* ```
|
|
358
365
|
*/
|
|
359
366
|
export const typographyStyles = StyleSheet.create(createTypographyTokens(staticTokens));
|
|
360
367
|
export const useTypographyStyles = buildThemedStyles(createTypographyTokens);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { Platform } from "react-native";
|
|
2
2
|
import { androidTokens, iosTokens } from "@jobber/design";
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
// TODO: remove all references to const in JM and Atlantis. Replace with useAtlantisTheme.
|
|
4
|
+
// Rename to `nonThemedTokens` in the meantime?
|
|
8
5
|
export const tokens = Platform.select({
|
|
9
6
|
ios: () => iosTokens,
|
|
10
7
|
android: () => androidTokens,
|