Hello guys, I have a problem... I have created an Electron app with two windows (Home and Settings) on the Home Window I have a button where I can change the theme(Dark/Light), I do this with css variables and a little Javascript script (In the html file the class define the theme). My question is how I can apply my theme also on my settings window ? (Does I need to do a link between the two files ?) I tried many things but without success :/
I post the main code to help you to understand my problem:
Html:
<html lang="en" class="theme-dark" id="fortheme">
Css:
.theme-light {
--color-primary: #dedad4;
--color-secondary: #d7d3cb;
--color-border: #c1beb9;
--color-accent1: #d52015;
--color-accent2: #2196f3;
--color-accent3: #4caf50;
--font-color: #070b0b;
}
.theme-dark {
--color-primary: #21252b;
--color-secondary: #282c34;
--color-border: #3e4146;
--color-accent1: #d52015;
--color-accent2: #2196f3;
--color-accent3: #4caf50;
--font-color: #f8f4f4;
}
Javascript:
//Change pictures (picture of the button) and theme
$('#light-btn').on({
'click': function () {
image = $("#light-image")
if (image.attr("src") == "Images/Sun.png") {
image.attr("src", "Images/Dark.png")
setTheme('theme-light');
$("img").css({ filter: "invert(100%)" })
} else {
image.attr("src", "Images/Sun.png")
setTheme('theme-dark');
$("img").css({ filter: "invert(0%)" })
}
}
});
Screenshot of the app to help you to understand:
Light mode: (the settings window don't have theme applyed)
Thanks a lot for your help !