add colorScheme.isDark()
This commit is contained in:
parent
bef70f6db3
commit
1364d3a8ba
|
@ -34,13 +34,12 @@ const colorScheme = (() => {
|
||||||
onChange(listener) {
|
onChange(listener) {
|
||||||
changeListeners.add(listener);
|
changeListeners.add(listener);
|
||||||
},
|
},
|
||||||
/** @param {StyleObj | 'darkUI'} val - the string is used by the built-in dark themer */
|
isDark: () => isDarkNow,
|
||||||
shouldIncludeStyle(val) {
|
/** @param {StyleObj} _ */
|
||||||
return val === 'darkUI'
|
shouldIncludeStyle({preferScheme: ps}) {
|
||||||
? isDarkNow
|
return prefs.get(kSTATE) === 'never' ||
|
||||||
: prefs.get(kSTATE) === 'never' ||
|
!SCHEMES.includes(ps) ||
|
||||||
!SCHEMES.includes(val = val.preferScheme) ||
|
isDarkNow === (ps === 'dark');
|
||||||
isDarkNow === (val === 'dark');
|
|
||||||
},
|
},
|
||||||
updateSystemPreferDark(val) {
|
updateSystemPreferDark(val) {
|
||||||
update('system', val);
|
update('system', val);
|
||||||
|
|
|
@ -11,11 +11,10 @@
|
||||||
* and not even a problem in the most popular case of using system dark/light mode.
|
* and not even a problem in the most popular case of using system dark/light mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
API.colorScheme.shouldIncludeStyle('darkUI').then(val => {
|
API.colorScheme.isDark().then(isDark => {
|
||||||
const ON = 'screen';
|
const ON = 'screen';
|
||||||
const OFF = 'not all';
|
const OFF = 'not all';
|
||||||
const map = {[ON]: true, [OFF]: false};
|
const map = {[ON]: true, [OFF]: false};
|
||||||
let isDark = val;
|
|
||||||
toggleDarkStyles();
|
toggleDarkStyles();
|
||||||
msg.onExtension(e => {
|
msg.onExtension(e => {
|
||||||
if (e.method === 'colorScheme') {
|
if (e.method === 'colorScheme') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user