Autodetect default theme based on user’s device preferences #8
Labels
No Milestone
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: phundrak/nord-for-org#8
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
It is possible to perform media queries in Dart in order to retrieve some information such as the user’s device preferences as to which theme to use, dark or light.
Documentation about this can be found in the W3C level 5 draft here. In Javascript, it is possible to send a media query with
.matchMedia('(prefers-color-scheme: dark)')
in order to detect if the user prefers a dark theme. The possible values are:no-preference
light
dark
In Dart, it is also possible to perform media queries with
dart:html
’swindow
and itsstyleMedia
member, which has the methodmatchMedium
.It should be easy to add in the initializing Dart code a couple of lines that look for the user’s preferences and set the default theme accordingly.