-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Theme Mode Context #57
Milestone
Comments
arcticicestudio
added a commit
that referenced
this issue
Dec 4, 2018
To persist the current active theme mode when changing the route (which unmounts the `Root` component and therefore resets the state), the value will be written to the browser's session storage (1). The storage type has been preferred over the local storage (2) since this would persist the active theme mode even when the user closes the tab, but the desired behavior is to optimize the site for the "bright snow flurry" aura theme mode. To simplify the read- and write handling as well as prevent possible errors due to wrong storage keys, two utility functions have been implemented: - `readSessionCache(key : string)` - Reads the value of the given key from the session storage (if available). - `writeSessionCache(key : string, value : any)` - Writes the given key-value pair to the session storage (if available). References: (1) https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage (2) https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage Associated epic: GH-51 GH-57
arcticicestudio
added a commit
that referenced
this issue
Dec 4, 2018
The `Root` component has been changed from a SFC to a class component to store the currently active state and handle the theme mode toggle logic through a function. It also migrated the currently used simple "styled-component" theme (1) (provided through the `<ThemeProvider` component) to the styled-theming theme (2) that provides the initially implemented theme (GH-53). References: (1) https://www.styled-components.com/docs/advanced#theming (2) https://github.com/styled-components/styled-theming Associated epic: GH-51 GH-57
Merged
13 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue handles the implementation of the
React.Context
provider and consumer for the global theme modes. It will provide the name of the currently active theme and a function to toggle the active theme.Context Provider & Consumer
Both the context consumer and provider components will be implemented in the
Root
core container component. The consumer will be exported which can then be imported in any component to consume the provided values.The
Root
component will be changed from a SFC to a class component to store the currently active state and handle the theme mode toggle logic through a function. It will also migrate the currently used simple styled-component theme (provided through the<ThemeProvider
component) to the styled-theming theme that provides the initially implemented theme (#53).Session Storage
To persist the current active theme mode when changing the route (which unmounts the
Root
component and therefore resets the state), the value will be written to the browser's session storage. The storage type has been preferred over the local storage since this would persist the active theme mode even when the user closes the tab, but the desired behavior is to optimize the site for the “bright snow flurry” aura theme mode.To simplify the read- and write handling as well as prevent possible errors due to wrong storage keys, two utility functions will be implemented:
readSessionCache(key : string)
andwriteSessionCache(key : string, value : any)
.Tasks
readSessionCache
andwriteSessionCache
utility functions.Root
core container as class-based component.state
.state
with the theme mode stored in the session storage on component instantiation.theme
to theGlobalStyle
component for global theme styles.The text was updated successfully, but these errors were encountered: