-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Automatic light/dark palette switching through matchMedia Listener and toggle Button #5085
Conversation
Here's a DEMO: |
Here's the same DEMO but the framed engine does no more extract the background-colors from the $:/palette... background-colors for the iframe and the domNode are set by the vanilla/base stylesheet: |
Hi @BurningTreeC Both manual and automatic switch dark/light works. For UI I may suggest
I will suggest to use better icons for day/night for page controls. Tested: Windows 10, Edge 86, Chrome 86, FF 82. |
Hi @kookma and thanks for testing! Currently the palette chosen for If someone provides me two better icons for dark/light I will add them. I'm not an icon-designer at all... The idea for automatic day/night switch has come up in the google groups, I've seen that... But I don't know how to implement that correctly in this scenario. Maybe I get an idea |
Is it possible to use free open source icons for example from: https://icones.js.org/ But I am not sure if the policy of TW allow to use such icons.
I am not sure if the bimlas code for automatic calculating day/night time is useful here or not. Please have a look at |
I also announced this PR in the Google group in hope of other people come for testing or helping (Sorry if I did not informed you in advance to do so) |
An updated DEMO with a very rudimentary UI in ControlPanel -> palette: |
@BurningTreeC |
@kookma , the same DEMO with your icons: |
@ The UI is at the bottom of palettes page and a little difficult to find! What do you think if a dedicated tab is used for setting dark mode! But lets wait to see what other says! The icons are good thank you! but it seems they are a little smaller and their lines are thinner than other core icon ! I will work to see if I can improve them. |
It is indeed important that the weights of the core icons match consistently. I'll try to work up a couple of icons we can use. |
That's great. Thank you @Jermolene! |
For me demo_4 switches back to light mode, whenever I reload the tab to reproduce:
|
@pmario - Demo 4 sets Light Mode on startup if |
Having the button gives this flexibility to switch dark/light whenever you like! I personably think have it enabled! |
Hi @kookma @BurningTreeC I was envisaging a set of three icons that would function as radio buttons:
Does that align with your implementation? |
Hi @Jermolene, the light /dark button is currently just a toggle button between light and dark palettes and is disabled when AutoDarkMode is yes. But we can make it three - state which seems to be a better idea |
Hi @BurningTreeC were you thinking of a single button that cycles through the three states? That might be confusing. An alternative would be to show a single icon in the side bar that would be either the dark or light icon to indicate the current status. Clicking the icon would bring up a dropdown menu with three items dark/light/auto, each accompanied by the appropriate icon, and a tick applied to the current setting. We might also provide the three individual icons as optional page control buttons/menu bar items, so that people who want single click access to one of the modes can enable those buttons. |
yes I was thinking about that, but you may be right that it's a bit confusing
That sounds like a much better idea
Ok, yes that sounds appropriate |
Hi @Jermolene |
Hi @BurningTreeC thank you for all your work on this. I think it will be a popular feature, and it's worth our attention. However, I now have some concerns about the our approach. The idea of having a separate palette setting for dark vs. light mode seems reasonable, but it does have a few consequences that are becoming clearer:
So, I'm tentatively thinking that we should maybe move to a mode where palettes themselves have to be upgraded to support dark vs. light mode. We might have a prefix (like We'd just have Given an ecosystem of skilfully made palettes, that might all works quite well, but in the meantime we might need to help the transition with eg. tools to merge two palettes, making one the dark palette and one the light palette. |
Another thought: it would be useful to be able to make icons that changed appearance according to dark mode vs. light mode. The easiest way to do that would be to include classes That implies that we would have a |
@Jermolene @BurningTreeC I would suggest that we not rush to get this into 5.1.23 so that we can give it proper consideration. |
@Jermolene, thanks for your detailed answer on this :) As @saqimtiaz suggests, we should postpone this to after 5.1.23 so that we have time to rethink the approach |
5.1.23 already is a huge release |
I think that's sensible. Having got the $:/info tiddler in means that others will be able to experiment in the meantime. |
Hi @BurningTreeC just to add that I came across the |
This is a draft PR that should fix #5023
It sets
$:/state/dark-mode
to true or false at startup and adds an event listener for when the media-query forprefers-color-scheme: dark
changes.It requires
$:/config/AutoDarkMode
to be set toyes
so that the page switches to whatever palette is stored in$:/config/Palette/DarkMode
when the OS' dark-mode setting changesIt also adds a toggle button that toggles between the palette in
$:/palette
and the one in$:/config/Palette/DarkMode
There's no UI yet, but I'm working on that