aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/darkmode.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-11-22 14:14:25 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-11-22 14:14:25 +0100
commit46b8c8c4b3a5b80e0187b284abc84566a7e784db (patch)
tree7fd378bcdd18e78c42dfeb61a15f89fd10106046 /src/webview/darkmode.js
parentADD features loading spinner (diff)
parentfeat(App): Add option to enable dark mode for supported services (diff)
downloadferdium-app-46b8c8c4b3a5b80e0187b284abc84566a7e784db.tar.gz
ferdium-app-46b8c8c4b3a5b80e0187b284abc84566a7e784db.tar.zst
ferdium-app-46b8c8c4b3a5b80e0187b284abc84566a7e784db.zip
Merge branch 'develop' into feature/features-api
Diffstat (limited to 'src/webview/darkmode.js')
-rw-r--r--src/webview/darkmode.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webview/darkmode.js b/src/webview/darkmode.js
new file mode 100644
index 000000000..9830ef33c
--- /dev/null
+++ b/src/webview/darkmode.js
@@ -0,0 +1,28 @@
1import path from 'path';
2import fs from 'fs-extra';
3
4const ID = 'franz-theme-dark-mode';
5
6export function injectDarkModeStyle(recipePath) {
7 const darkModeStyle = path.join(recipePath, 'darkmode.css');
8 if (fs.pathExistsSync(darkModeStyle)) {
9 const data = fs.readFileSync(darkModeStyle);
10 const styles = document.createElement('style');
11 styles.id = ID;
12 styles.innerHTML = data.toString();
13
14 document.querySelector('head').appendChild(styles);
15 }
16}
17
18export function removeDarkModeStyle() {
19 const style = document.querySelector(`#${ID}`);
20
21 if (style) {
22 style.remove();
23 }
24}
25
26export function isDarkModeStyleInjected() {
27 return !!document.querySelector(`#${ID}`);
28}