Skip to content

Commit 080ea7e

Browse files
committed
Core: App - add darkThemeChange event + app.darkTheme boolean prop
1 parent c34f636 commit 080ea7e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/core/components/app/app-class.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,12 @@ class Framework7 extends Framework7Class {
105105
const html = document.querySelector('html');
106106
if (media === DARK) {
107107
html.classList.add('theme-dark');
108+
app.darkTheme = true;
109+
app.emit('darkThemeChange', true);
108110
} else if (media === LIGHT) {
109111
html.classList.remove('theme-dark');
112+
app.darkTheme = false;
113+
app.emit('darkThemeChange', false);
110114
}
111115
};
112116

@@ -158,8 +162,12 @@ class Framework7 extends Framework7Class {
158162
}
159163
if (app.mq.dark && app.mq.dark.matches) {
160164
html.classList.add('theme-dark');
165+
app.darkTheme = true;
166+
app.emit('darkThemeChange', true);
161167
} else if (app.mq.light && app.mq.light.matches) {
162168
html.classList.remove('theme-dark');
169+
app.darkTheme = false;
170+
app.emit('darkThemeChange', false);
163171
}
164172
}
165173

0 commit comments

Comments
 (0)