@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.76.1-JOB-116234-314c5ff.22+314c5ff4",
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": "314c5ff4e8322594d2fc7ffce54a204f4a6731cb"
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
- // TODO: check last saved theme from local/device storage
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 [globalTheme, setGlobalTheme] = useState(initialTheme);
22
- const currentTheme = dangerouslyOverrideTheme !== null && dangerouslyOverrideTheme !== void 0 ? dangerouslyOverrideTheme : globalTheme;
23
- const currentTokens = currentTheme === "dark" ? completeDarkTokens : lightTokens;
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: currentTheme,
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
- * @deprecated Use useCommonInputStyles instead
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
- * 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
+ // 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,
@@ -8,7 +8,6 @@
8
8
  "AtlantisContext.Provider",
9
9
  "AtlantisFormContext.Consumer",
10
10
  "AtlantisFormContext.Provider",
11
- "AtlantisThemeContextProvider",
12
11
  "AutoLink",
13
12
  "Banner",
14
13
  "BottomSheet",