Theme-ui: Option to disable LocalStorage usage

Created on 21 Feb 2020  路  3Comments  路  Source: system-ui/theme-ui

Is your feature request related to a problem? Please describe.
The colorModes API writes theme-ui-color-mode: "default" to localStorage when not being used, this seems to be unnecessary and _slightly_ aggressive behaviour.

Describe the solution you'd like
When not in use colorModes should not write to localStorage.

Additionally provide an option to disable localStorage usage for colorModes.

Describe alternatives you've considered
None.

Additional context
Based on issues https://github.com/system-ui/theme-ui/issues/512 and https://github.com/system-ui/theme-ui/issues/553 it seems like localStorage is not a requirement for Theme UI to function correctly.

If this is acceptable I'm happy to make a PR.

Most helpful comment

+1 for this since localStorage keeping track of a color mode is really problematic for our use-case of migrating slices of our app to theme-ui.

When you have a nested <ThemeProvider mode="something">, it will override the theme-ui-color-mode value, and make for some pretty wonky stuff happening if you end up on another page that has a different color mode.

All 3 comments

This would be a nice feature to be able to turn off. I spun up my app on a new domain and it took me a while to figure out why all my colors were all wonky.

+1 for this since localStorage keeping track of a color mode is really problematic for our use-case of migrating slices of our app to theme-ui.

When you have a nested <ThemeProvider mode="something">, it will override the theme-ui-color-mode value, and make for some pretty wonky stuff happening if you end up on another page that has a different color mode.

I completely forgot about this but just saw it pop up as an autocomplete option with Typescript haha 馃槃

Thanks a bunch @eschaefer for getting this in!

Was this page helpful?
0 / 5 - 0 ratings