mirror of
https://github.com/zen-browser/desktop.git
synced 2026-01-07 13:53:19 +00:00
feat: Add three command bar actions for switching the Light/Dark Mode, p=#11122
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import { XPCOMUtils } from 'resource://gre/modules/XPCOMUtils.sys.mjs';
|
||||
|
||||
const lazy = {};
|
||||
|
||||
XPCOMUtils.defineLazyPreferenceGetter(lazy, 'currentTheme', 'zen.view.window.scheme', 2);
|
||||
|
||||
function isNotEmptyTab(window) {
|
||||
return !window.gBrowser.selectedTab.hasAttribute('zen-empty-tab');
|
||||
}
|
||||
@@ -153,6 +159,30 @@ const globalActionsTemplate = [
|
||||
command: 'Tools:Addons',
|
||||
icon: 'chrome://browser/skin/zen-icons/extension.svg',
|
||||
},
|
||||
{
|
||||
label: 'Switch to Automatic Appearance',
|
||||
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 2),
|
||||
icon: 'chrome://browser/skin/zen-icons/sparkles.svg',
|
||||
isAvailable: () => {
|
||||
return lazy.currentTheme !== 2;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Switch to Light Mode',
|
||||
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 1),
|
||||
icon: 'chrome://browser/skin/zen-icons/face-sun.svg',
|
||||
isAvailable: () => {
|
||||
return lazy.currentTheme !== 1;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Switch to Dark Mode',
|
||||
command: () => Services.prefs.setIntPref('zen.view.window.scheme', 0),
|
||||
icon: 'chrome://browser/skin/zen-icons/moon-stars.svg',
|
||||
isAvailable: () => {
|
||||
return lazy.currentTheme !== 0;
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const globalActions = globalActionsTemplate.map((action) => ({
|
||||
|
||||
Reference in New Issue
Block a user