Skip to content

Commit

Permalink
Switching between themes in now real-time fast
Browse files Browse the repository at this point in the history
  • Loading branch information
klaudiosinani committed Sep 17, 2017
1 parent f3dd0b2 commit 151fa38
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,26 @@ ipc.on('exit-focus-mode', () => {
document.querySelector('#gwt-debug-NoteAttributes-doneButton').click();
});

function untoggleTheme(themeName, activateFunction) {
// Deactivate theme status if it is not already deactivated
switch (config.get(themeName)) {
case true:
config.set(themeName, false);
activateFunction();
break;

default:
break;
}
}

function darkMode() {
document.documentElement.classList.toggle('dark-mode', config.get('darkMode'));
}

function untoggleDark() {
// Untoggle the dark theme
config.set('darkMode', false);
darkMode();
untoggleTheme('darkMode', darkMode);
}

ipc.on('toggle-dark-mode', () => {
Expand All @@ -83,8 +95,7 @@ function blackMode() {

function untoggleBlack() {
// Untoggle the black theme
config.set('blackMode', false);
blackMode();
untoggleTheme('blackMode', blackMode);
}

ipc.on('toggle-black-mode', () => {
Expand All @@ -103,8 +114,7 @@ function sepiaMode() {

function untoggleSepia() {
// Untoggle the sepia theme
config.set('sepiaMode', false);
sepiaMode();
untoggleTheme('sepiaMode', sepiaMode);
}

ipc.on('toggle-sepia-mode', () => {
Expand All @@ -127,8 +137,7 @@ function vibrantMode() {

function untoggleVibrant() {
// Untoggle the vibrant theme
config.set('vibrantMode', false);
vibrantMode();
untoggleTheme('vibrantMode', vibrantMode);
}

ipc.on('toggle-vibrant-mode', () => {
Expand All @@ -151,8 +160,7 @@ function vibrantDarkMode() {

function untoggleDarkVibrant() {
// Untoggle the dark vibrant theme
config.set('vibrantDarkMode', false);
vibrantDarkMode();
untoggleTheme('vibrantDarkMode', vibrantDarkMode);
}

ipc.on('toggle-vibrant-dark-mode', () => {
Expand Down

0 comments on commit 151fa38

Please sign in to comment.