-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
feat: allow using 'localStorage' and 'sessionStorage' for storing the theme #293
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
As said above, there might also be an other way to approach this: Supporting the above mentioned three storage-solution will increase the bundle-size. However, it might also be of interest to allow for async-storage solutions, which would require even more changes under-the-hood and compared to the above mentioned three storage solutions, will not be trivial. Imagine the following API: Creating a theme-provider using browser storageconst { useTheme, ThemeProvider } = createThemeProvider({
// Based on the attribute passed to the factory-method, we could return a theme-provider that contains only the required code for the chosen storage method.
storage: < one of 'localStorage' | 'sessionStorage' | 'cookie' >
storageKey: <key-to-use>
}) Creating a theme-provider for another storage solutionconst { useTheme, ThemeProvider } = createThemeProvider({
storage: 'custom'
get: async (): Promise<string> => {…}
set: async (theme: string): Promise<Void> => {...}
}) Basically with this approach, we would create a optmised ThemeProvider based on the users need. I would find this approach quite interesting, perhaps even a nice addition to the v1 release. |
1b0d85b
to
45d88a7
Compare
45d88a7
to
80bad5e
Compare
….4-and-up docs: update docs on how to use with tailwindcss >3.4.1
chore: use corepack instead of pnpm setup action in ci
This PR aims to provide support for both 'localStorage' and 'sessionStorage'
Depending on how we implement this, it can either be shipped in a minor release or if we go for a more optimised solution within a major-release as it would be a breaking change in the ThemeProvider API.
I will elaborate this below after defining the 'non-breaking-change' variant first.
## Backwards-compatible implementation
LocalStorage / SessionStorage
Tasks
Closes #72
Based on #291