diff --git a/docs/components/AtlantisThemeContext/AtlantisThemeContext.stories.mdx b/docs/components/AtlantisThemeContext/AtlantisThemeContext.stories.mdx index ec7ee330c2..4b7f3f7f8a 100644 --- a/docs/components/AtlantisThemeContext/AtlantisThemeContext.stories.mdx +++ b/docs/components/AtlantisThemeContext/AtlantisThemeContext.stories.mdx @@ -13,7 +13,23 @@ tokens. ## Design & usage guidelines -### Using the AtlantisThemeContextProvider +Both the web and mobile components have the exact same API, except for one +minor difference in how you update the theme. + +Each platform provides a `useAtlantisTheme` hook that you may use to access the +`theme` and `tokens` in your components. + +On mobile, this hook also returns a `setTheme` function which you'll use to +update the theme for the nearest `AtlantisThemeContextProvider` ancestor. +Typically there will only be a single provider at the root, controlling the +theme for the entire app. + +On web, you'll need to import the `updateTheme` function and call it with the +new theme. This is a separate function because it synchronizes the theme update +across all providers under various React trees. Synchronizing across providers +is necessary for cases where an island-based architecture is used. + +### Usage for web ```tsx import { @@ -41,7 +57,7 @@ function ThemedComponent() { }} > - The current theme is: {theme}. + The current theme is: {theme}. The javascript tokens can be accessed via the tokens object. @@ -61,6 +77,50 @@ function ThemedComponent() { } ``` +### Usage for mobile + +```tsx +import { AtlantisThemeContextProvider, useAtlantisTheme } from "@jobber/components/AtlantisThemeContext"; + +function App() { + return ( + + + + ); +} + +function ThemedComponent() { + const { theme, tokens, setTheme } = useAtlantisTheme(); + return ( + + + + The current theme is: {theme}. + + The javascript tokens can be accessed via the tokens object. + + The theme can be changed using `setTheme` +