-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Option to use sessionStorage instead of localStorage #72
Comments
My thoughts on: #71 (comment) Don't you think having a generic option might be a bit over engineered for the common use cases? I thought of the following implementation would solve #72 quiet nicely.
In regards to a 'generic' custom solution :
interface ExternalThemeStorage extends EventTarget { // EventTarget could be an overkill tbh
get: () => Promise<string | null>
set: (value: string) => Promise<void>
delete: () => Promise<void>
} An object implementing this interface could then be passed to the customStorage property to be used inside the ThemeProvider. I think allowing the user to combine both the storage property and customStorage property could be very useful, |
I don't want to be picky, it is a very nice integration. But... I am looking to store the theme info in Redux and have the provider read directly from Redux store instead. |
Have you made any progress on that? |
Hey, any news on this? Having the theme in a session storage if you need this option, sounds like a good use case to me. |
@ciruz a pr for this is open and waiting for pacos review. |
Hello! I noticed after adding this to my project that because it uses
localStorage
, the theme always persists between sessions.When someone visits my site, I'd prefer to have it get the default theme first (i.e.
system
), if for example the system theme has changed from their previous session because they're visiting at a different time of day.I've implemented this in #71. Please let me know what you think!
The text was updated successfully, but these errors were encountered: