-
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
Introduce new MediaQueryTrackerMechanism, and use it for dark mode #8555
base: master
Are you sure you want to change the base?
Conversation
Confirmed: Jermolene has already signed the Contributor License Agreement (see contributing.md) |
return tiddlers; | ||
}; | ||
infoTiddlerFields.push.apply(infoTiddlerFields,getResultTiddlers()); | ||
mqList.addListener(function(event) { |
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.
IMO .addListener()
was deprecated. See: https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/addListener. It should be mqList.addEventListener("change", function(event){
now
@@ -0,0 +1,5 @@ | |||
title: $:/core/wiki/config/MediaQueryTrackers/DarkLightSwitch |
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.
IMO the name should be DarkModePreferred
instead of switch. The state itself does not switch anything. It only tells us about the browser or os preferred setting
@@ -19,6 +19,8 @@ System tiddlers in the namespace `$:/info/` are used to expose information about | |||
|[[$:/info/browser/language]] |<<.from-version "5.1.20">> Language as reported by browser (note that some browsers report two character codes such as `en` while others report full codes such as `en-GB`) | | |||
|[[$:/info/browser/screen/width]] |Screen width in pixels | | |||
|[[$:/info/browser/screen/height]] |Screen height in pixels | | |||
|[[$:/info/browser/darkmode]] |<<.from-version "5.3.6">> Is dark mode enabled? ("yes" or "no") | |
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.
IMO it may be Is dark mode preferred
This PR introduces a new general purpose mechanism that allows any custom CSS media query to be bound to an info tiddler so that the current state of the query is reflected in the value of the tiddler. The value is updated dynamically.
The use of the info mechanism means that these tiddlers are dynamically created as shadow tiddlers within the
$:/temp/info
plugin, and so do not appear in tiddler lists.The mechanism is used to implement the existing dark mode tiddler with the following configuration:
Note the use of
info-tiddler-alt
to specify a redundant secondary info tiddler. This is used by the dark mode tracker to maintain compatibility while changing the info tiddler title for consistency.This PR was prompted by @pmario's work on dark mode switching in #7830 and is intended to allow us to implement actions for dark/light mode changes in a more extensible and generic way. The plan is to integrate this PR with the filtered actions work in #7999.