diff options
Diffstat (limited to 'src/webview/darkmode.ts')
-rw-r--r-- | src/webview/darkmode.ts | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/webview/darkmode.ts b/src/webview/darkmode.ts index 7b9407049..a0699bdb7 100644 --- a/src/webview/darkmode.ts +++ b/src/webview/darkmode.ts | |||
@@ -9,10 +9,17 @@ const ID = [...Array.from({ length: 20 })] | |||
9 | .map(() => chars[Math.trunc(Math.random() * chars.length)]) | 9 | .map(() => chars[Math.trunc(Math.random() * chars.length)]) |
10 | .join(''); | 10 | .join(''); |
11 | 11 | ||
12 | function darkModeFilePath(recipePath: string) { | ||
13 | return join(recipePath, 'darkmode.css'); | ||
14 | } | ||
15 | |||
16 | export function darkModeStyleExists(recipePath: string) { | ||
17 | return pathExistsSync(darkModeFilePath(recipePath)); | ||
18 | } | ||
19 | |||
12 | export function injectDarkModeStyle(recipePath: string) { | 20 | export function injectDarkModeStyle(recipePath: string) { |
13 | const darkModeStyle = join(recipePath, 'darkmode.css'); | 21 | if (darkModeStyleExists(recipePath)) { |
14 | if (pathExistsSync(darkModeStyle)) { | 22 | const data = readFileSync(darkModeFilePath(recipePath)); |
15 | const data = readFileSync(darkModeStyle); | ||
16 | const styles = document.createElement('style'); | 23 | const styles = document.createElement('style'); |
17 | styles.id = ID; | 24 | styles.id = ID; |
18 | styles.innerHTML = data.toString(); | 25 | styles.innerHTML = data.toString(); |