Skip to content
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 #58

Merged
merged 3 commits into from
Dec 4, 2018
Merged

Conversation

arcticicestudio
Copy link
Contributor

Associated epic: #51
Resolves #57

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
Both the context consumer and provider components have been implemented
in the `Root` core container component . The consumer is exported which
can then be imported in any component to consume the provided values.

References:
  (1) #36

Associated epic: GH-51
GH-57
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
@codecov
Copy link

codecov bot commented Dec 4, 2018

Codecov Report

Merging #58 into develop will decrease coverage by 17.66%.
The diff coverage is 62.06%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop   #58       +/-   ##
=========================================
- Coverage    91.66%   74%   -17.67%     
=========================================
  Files           14    15        +1     
  Lines           24    50       +26     
  Branches         1     9        +8     
=========================================
+ Hits            22    37       +15     
- Misses           2    10        +8     
- Partials         0     3        +3
Flag Coverage Δ
#unit 74% <62.06%> (-17.67%) ⬇️
Impacted Files Coverage Δ
src/utils/sessionCache.js 60% <60%> (ø)
src/components/containers/core/Root/Root.jsx 65% <63.15%> (-35%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85498ca...bb6c044. Read the comment docs.

@arcticicestudio arcticicestudio merged commit 86edb92 into develop Dec 4, 2018
@arcticicestudio arcticicestudio deleted the feature/gh-57-theme-mode-context branch December 4, 2018 11:03
@arcticicestudio arcticicestudio removed their assignment Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants