-
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
add browser dark/light theme detection #7830
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There is a little problem with all dark themes and the HelloThere page, which should be fixed in a different PR. |
Thanks @pmario. This does seem like a reasonable low level primitive for us to provide. I think there might well be other events on the "window" object that we might want to expose in the same way (see MDN docs), notably However, before merging I'd prefer to wait until we have a coherent overall view for the automation of dark mode handling. It may be that the best way forward is a more radical overhaul of our handling of palettes, which I am certainly open to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pmario I noticed some minor docs style issues
I think there is are 3rd party plugins at the moment, which implement manual dark/light "toggle button". But that's about it. The auto-switching is not possible atm, because TW core does not support it. So it's a chicken/egg problem. If we do not implement something like this PR - nothing will happen. The views about how the configuration UX should look like are diametrically opposed depending on the author, as we could see with our discussion with my first attempt.
I did ask for community help with the palette colours over at Talk. There may be some other occasions, which I cannot find atm. -- Nobody did do anything. I do have slightly improved versions of most palettes at the palette-manager edtion. But they are not finished yet.
Does this mean, you'll want to wait merging this PR until this happens? |
Thank you @pmario I would like to defer this until we've been able to give more consideration to the user interface. |
Can auto-switching like VSCode happend in this PR? @pmario seems preview site is not created so I can't test it easily. I recently find that if you want auto-switching, you shouldn't save Also there is a https://github.com/linonetwo/tiddlywiki-switch-theme-user-script as workaround before this is merged, I will integrate it into TidGi APP too, until we have this core feature. |
@linonetwo There is a preview version available now. |
I'm not sure about this. I usually set the default light or dark theme once in a lifetime. So there will be some backups, when the user is experimenting with the new feature. But later on, I do not see why there should be additional switches at all. IMO it's the same thing as if users set the If the number of backups is a problem, IMO the backup strategy has to be changed. Changing the Just my thoughts. |
Ok, I accept that I'm currently omit it in wiki templates. And only keep the theme switch config. |
But you are using
instead of config tiddler. Can you make it config, and create a control panel for it? I think most of users need this, and most of them don't know "wikiscript". Why not use action like https://github.com/tiddly-gittly/Modern.TiddlyDev/blob/6a694373f51e6950826f7d839dbfd8403df38567/wiki/tiddlers/%24__Modern.TiddlyDev_Startup.tid#L13
that will use config from control panel. |
@Jermolene -- I did just update the OP #7830 (comment) with the latest info. Talk discussion is at: https://talk.tiddlywiki.org/t/light-dark-palette-switching-one-more-time/8960 |
The new UI is elegant, can't wait to use it! Thank you @pmario
@Jermolene Now there is a user interface, what do you think? |
Hello @pmario - with these changes, is it possible to detect the light/dark mode in a startup action, too? Edit: forget my question XD ... it's easily doable, I know |
Hi @pmario I tried a simple test with the preview release of opening the page and then using my OS controls to switch to dark mode. The "save" button turned red, indicating that a tiddler has changed. I do not think that that is acceptable. If the user has elected to track the OS dark/light mode then a change in the mode should not make the wiki dirty. |
From my point of view. This PR does exactly, what it is supposed to accomplish.
I did include 2 interactive examples, that should make it easy for users to test the new behaviour. That's it: Examples You are right, there may be a problem with the examples, but IMO that's a problem, which cannot be resolved with this PR. IMO it's a "read only mode" core problem. This PR has 3 modes.
For case 3, there is no mechanism in the tiddlywiki core atm, which allows us to block dirty mode on changes to the $:/palette tiddler. This is a general problem if someone changes anything at tiddlywiki.com, which sets the dirty state. If we do not want that, we need a new function in the core, which imo is not in the scope of this PR. If we would add |
@Jermolene, There is a new Preview version, which has 2 interactive examples now. |
@Jermolene .. As I wrote, I think changing the So the question is: Can we create a new configuration, that allows us to avoid dirty tracking, but still be able to save tiddlers with the next save action or throw away the setting if it is not saved. eg: $:/config/IgnoreDirty ... which would allow a "titlelist" or a "filter" What do you think? |
Hi @pmario the UI I would expect would look like this:
This arrangement would allow users to choose whether or not their wiki is affected by system dark mode changes. If it is not, they can manually set It would, though, require us to change palette handling in a way that it will not be backwards compatible. The easiest approach might be to use the prefixes
|
Why not make a Vanilla-dark palette, instead of make vanilla palette have (I usually switch between |
We could have separate Vanilla-Dark and Vanilla-Light, and switch between them, but we want to retain compatibility with one basic feature: existing colour palette choosers should still work by changing
It sounds like you'd make a custom palette that inherited from both |
I think, I can live with a "meta palette" configuration as you suggested. A possible "autoswitcher" chooses from the configuration shown below, but additionally of The following usecase needs to be possible: From 6am-11am a palette-6-11 should be active. from 11:01am to 16pm palette-11-16 should be active ... and so on. So I would rename import-dark and import-light to palette-dark and palette-light and the "palette-selector" knows about these fields. The active palette selector could be a "filter-cascade", so we basically can use any field-name to reference a palette to be active. -- The last filter could use the existing $:/palette tiddler for backwards compatibility reasons. I personally do not want to use dark-palettes, but I would like to switch between 2 or 3 different light ones, based on time-of-day.
I'm completely against the mechanism to have 2 values per mode in 1 palette. I think palettes should be combinable in every possible way. Not everyone wants to switch between light / dark even if the browser says it should be dark. |
@Jermolene -- I think this PR will give users and plugin-authors good flexibility and it is simple.
The configuration is in ControlPanel -> Appearence -> Palette, where it belongs.
$:/tags/DarkLightChangeActions
$:/tags/DarkLightChangeActions
will be executedThese changes are compatible with my PaletteManager preview function and the TiddlyTools PaletteManager (not shown in the screencast below)