Skip to content

Commit a11eb45

Browse files
committed
detect dark theme via css variable
1 parent a666829 commit a11eb45

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

web_src/js/utils.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,9 @@ export function isObject(obj) {
2626

2727
// returns whether a dark theme is enabled
2828
export function isDarkTheme() {
29-
if (document.documentElement.classList.contains('theme-auto')) {
30-
return window.matchMedia('(prefers-color-scheme: dark)').matches;
31-
}
32-
if (document.documentElement.classList.contains('theme-arc-green')) {
33-
return true;
34-
}
35-
return false;
29+
const isDarkTheme = window.getComputedStyle(document.documentElement)
30+
.getPropertyValue('--is-dark-theme').trim().toLowerCase();
31+
return isDarkTheme === 'true';
3632
}
3733

3834
// removes duplicate elements in an array

web_src/less/themes/theme-arc-green.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "../chroma/dark.less";
22

33
:root {
4+
--is-dark-theme: true;
45
--color-primary: #87ab63;
56
--color-primary-dark-1: #93b373;
67
--color-primary-dark-2: #9fbc82;

0 commit comments

Comments
 (0)