-
-
Notifications
You must be signed in to change notification settings - Fork 368
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: theme switcher #299
base: release/v0.7.0
Are you sure you want to change the base?
feat: theme switcher #299
Conversation
Hey, thanks for contributing! I try very hard not to introduce backwards-incompatible changes for the config such as this one and I think there's a way to avoid doing that here. In addition, I believe it would be more practical if rather than enforcing
The config for all of that may look something along the lines of: theme:
background-color: 255 14 6
primary-color: 156 50 65
negative-color: 342 65 65
light-theme-preset: my-custom-light-theme
dark-theme-preset: my-custom-dark-theme
presets:
my-custom-dark-theme:
background-color: 225 14 15
primary-color: 157 47 65
contrast-multiplier: 1.1
my-custom-light-theme:
light: true
background-color: 0 0 95
primary-color: 0 0 10
negative-color: 0 90 50 Where:
Implementation-wise, selecting a theme would just set a cookie with either:
Some potentially nasty-looking CSS wizardry might be needed to get all of that overriding behavior working properly, along with being able to change themes on the fly without a page reload. I've put a little bit of work into implementing this idea but am currently trying to finish things around the v0.7.0 release so haven't made further progress. I'll get back to it once that's out. |
Hello, Thanks for the feedback. I didn't have in mine that you don't want backwards-incompatible changes. |
c3f0b5d
to
814071a
Compare
814071a
to
62e9c32
Compare
This PR is now ready (according your feedback). The only thing missing is [light, dark]-theme-preset. I think it's quite useless.
I found a trick (here). I simply add a css class to each preset with the different variables for that preset. When I change the theme in the webpage I add the css class (corresponding to the selected theme) to the tag and the vars are automatically applied. |
Thanks for making those changes! I'll get back to this PR in a couple of weeks once v0.7.0 is out. |
Hello,
I was thinking that the ability to change themes was missing. So I implemented this feature.
We can define 2 themes: light and dark.
The theme changes automatically depending on the device theme (it's also possible to disable this behaviour using the
sync-device-theme: false
configuration).Here's an example configuration for a light & dark theme with the theme synchronised with the device theme :
There's also a button at the top left of the page to change the theme directly from the app.
![Capture d’écran 2025-01-05 à 01 31 43](https://private-user-images.githubusercontent.com/50453254/400171592-2c98ae35-3f75-4232-8063-5f424e55df4d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjY5NjgsIm5iZiI6MTczOTQyNjY2OCwicGF0aCI6Ii81MDQ1MzI1NC80MDAxNzE1OTItMmM5OGFlMzUtM2Y3NS00MjMyLTgwNjMtNWY0MjRlNTVkZjRkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA2MDQyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0ZWZiYWUxNzM3ZTI0NWE1NjVhOTcyZjM1ZTkwNGQyOWJiYjBlODk5NmQ2NzY5YjU0NDBmNzBhY2JhMDY2MTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.FhICcGdVJLLukL3NfNxwf8QsL2jUzbI8vWJVfTNQNhA)
![Capture d’écran 2025-01-05 à 01 32 02](https://private-user-images.githubusercontent.com/50453254/400171603-351730a4-dcad-4c06-ad6f-b5ed25a3f4a1.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjY5NjgsIm5iZiI6MTczOTQyNjY2OCwicGF0aCI6Ii81MDQ1MzI1NC80MDAxNzE2MDMtMzUxNzMwYTQtZGNhZC00YzA2LWFkNmYtYjVlZDI1YTNmNGExLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA2MDQyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTIxYzE2NDE2OTMwN2FlMWNmMDhhNmFmMTEwMzc5Y2Q0MjVlYjgyYzdjYmYxMzQ4ZDdhZTVhYTBjZTg3ZWE3N2UmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.sa7d_IfIPKfHr-nq2VtPnWOoYvQFwF8BXn1XABwNzMQ)
Don't hesitate to let me know if I need to change anything or be clearer in the documentation.