Skip to content

Commit

Permalink
Fix theme handling when high contrast is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
xanderfrangos committed Dec 18, 2024
1 parent a374f25 commit efacc6f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/css/vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
--slider-track-color-focus: rgba(0, 0, 0, 0.65);


@media screen and (prefers-color-scheme: dark) {
body[data-theme="dark"] {
--tray-background-base: #1f1f1f;
--tray-background-transparent: rgba(41, 41, 41, 0.95);
--tray-background-blur: rgba(41, 41, 41, 0);
Expand Down Expand Up @@ -110,8 +110,8 @@ body[data-transparent="true"][data-acrylic="true"][data-use-native-animation="tr
}
}

@media screen and (prefers-color-scheme: dark) {
body[data-colored-taskbar="true"] {
html body[data-theme="dark"] {
&[data-colored-taskbar="true"] {
.window-base {
--tray-background: var(--system-accent-dark) !important;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ html body[data-is-win11="true"], html body[data-is-win11="true"] {

--mica-base-color: #f1f1f1;

@media screen and (prefers-color-scheme: dark) {
&[data-theme="dark"] {

--page-background: #202020 !important;
--page-section-bg: #ffffff0a;
Expand Down
2 changes: 2 additions & 0 deletions src/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ function processSettings(newSettings = {}, sendUpdate = true) {

if (settings.theme) {
nativeTheme.themeSource = determineTheme(settings.theme)
sendToAllWindows('theme-settings', lastTheme)
}

updateStartupOption((settings.openAtLogin || false))
Expand Down Expand Up @@ -803,6 +804,7 @@ function processSettings(newSettings = {}, sendUpdate = true) {
settings.isWin11 = isReallyWin11
}
newSettings.useAcrylic = settings.useAcrylic
sendToAllWindows('theme-settings', lastTheme)
doRestartPanel = true
}

Expand Down
2 changes: 2 additions & 0 deletions src/panel-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,15 @@ ipc.on('theme-settings', (event, theme) => {
try {
window.theme = (theme.SystemUsesLightTheme == 0 ? "dark" : "light")
window.document.body.dataset["systemTheme"] = (theme.SystemUsesLightTheme == 0 ? "dark" : "light")
window.document.body.dataset["theme"] = (settings.theme == "dark" || settings.theme == "light" ? settings.theme : window.theme)
window.document.body.dataset["transparent"] = (theme.EnableTransparency == 0 || theme.UseAcrylic == 0 ? "false" : "true")
window.document.body.dataset["acrylic"] = (theme.UseAcrylic == 0 || settings?.isWin11 ? "false" : "true")
window.document.body.dataset["coloredTaskbar"] = (theme.ColorPrevalence == 0 ? "false" : "true")
window.document.body.dataset["useNativeAnimation"] = (settings.useNativeAnimation == false ? "false" : "true")
isTransparent = theme.EnableTransparency
} catch (e) {
window.document.body.dataset["systemTheme"] = "default"
window.document.body.dataset["theme"] = "dark"
window.document.body.dataset["transparent"] = "false"
window.document.body.dataset["acrylic"] = "false"
window.document.body.dataset["coloredTaskbar"] = "false"
Expand Down
3 changes: 3 additions & 0 deletions src/settings-preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ ipc.on('localization-updated', (event, localization) => {

const processTheme = (event, theme) => {
try {
window.theme = (theme.SystemUsesLightTheme == 0 ? "dark" : "light")
window.document.body.dataset["systemTheme"] = (theme.SystemUsesLightTheme == 0 ? "dark" : "light")
window.document.body.dataset["theme"] = (settings.theme == "dark" || settings.theme == "light" ? settings.theme : window.theme)
window.document.body.dataset["transparent"] = (theme.EnableTransparency == 0 || theme.UseAcrylic == 0 ? "false" : "true")
window.document.body.dataset["acrylic"] = (theme.UseAcrylic == 0 ? "false" : "true")

Expand All @@ -196,6 +198,7 @@ const processTheme = (event, theme) => {
window.document.body.dataset["coloredTaskbar"] = (theme.ColorPrevalence == 0 ? "false" : "true")
} catch (e) {
window.document.body.dataset["systemTheme"] = "default"
window.document.body.dataset["theme"] = "dark"
window.document.body.dataset["transparent"] = "false"
window.document.body.dataset["acrylic"] = false
window.document.body.dataset["coloredTaskbar"] = "false"
Expand Down

0 comments on commit efacc6f

Please sign in to comment.