-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: Persist theme configuration across sessions using local storage #6804
base: master
Are you sure you want to change the base?
Feat: Persist theme configuration across sessions using local storage #6804
Conversation
…fig in local storage
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
Just a heads up it used to work this way and PrimeTek intentionally removed it: #2671 |
@melloware, thank you for the heads up. I missed it. Based on the revert message, I assume it was reverted because we need to call local storage from page components when they are fully loaded by the client, not from the root But this is only if I'm not mistaken in my conclusion. I don't see any hydration issues or warnings with this implementation right now, so maybe this will be okay too. Waiting for a review from the team 👀 |
Up to you! |
We are currently working on the new versions of PrimeReact and the PrimeReact Showcase. While we appreciate your suggested change, we have decided not to merge it at this time. However, we liked your approach and will consider this change for our new showcase. We hope you understand our decision, and we appreciate your continued support. @khris-prog |
Sure! Not problem at all. I hope this was at least helpful for inspiration🙂 |
Related to a discussion I created recently #2222
Description:
The main idea of this PR is to centralize theme configuration changes in one place. I created
AppConfigContext
component to keep all theme settings, such as theme, dark mode, input style, etc., in one place. It uses theuseLocalStorage
hook for managing state and storing settings in local storage to make them available across sessions.To ensure that the brand theme is used for the main landing page, I've chosen to keep two theme values in the state:
primeTheme
andappTheme
.Here is a demo:
primereact.demo.mp4
Changes:
AppConfigContext
component with a provider to maintain state and change handlers, and the correspondinguseAppConfig
hookNote:
Since this is related to the website and from my perspective this is a routine task, I decided to help by providing a pull request for my feature request. It will be totally fine if you decide to decline it.