MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / applyExportTheme

Function applyExportTheme

apps/desktop/src/renderer/export-window.tsx:122–145  ·  view source on GitHub ↗

Resolve the export theme synchronously. For the default (pref off) and for * built-in themes this is the final answer; for a custom theme it sets the id * and a best-guess mode now, and `applyCustomExportTheme` injects the CSS and * refines the mode once the theme list loads. Mirrors App.tsx's

(prefs: ExportPrefs)

Source from the content-addressed store, hash-verified

120 * and a best-guess mode now, and `applyCustomExportTheme` injects the CSS and
121 * refines the mode once the theme list loads. Mirrors App.tsx's theme effect. */
122function applyExportTheme(prefs: ExportPrefs): void {
123 const html = document.documentElement
124 if (!prefs.pdfExportUseTheme) {
125 applyLightExportTheme()
126 return
127 }
128 const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
129 if (isCustomThemeId(prefs.themeId)) {
130 const wantDark = prefs.themeMode === 'auto' ? prefersDark : prefs.themeMode === 'dark'
131 const mode = resolveCustomThemeMode(undefined, wantDark)
132 html.dataset.theme = prefs.themeId
133 html.dataset.themeMode = mode
134 html.style.colorScheme = mode
135 return
136 }
137 const id =
138 prefs.themeMode === 'auto'
139 ? resolveAuto(prefs.themeFamily, prefersDark, prefs.themeId)
140 : prefs.themeId
141 const mode = findTheme(id).mode
142 html.dataset.theme = id
143 html.dataset.themeMode = mode
144 html.style.colorScheme = mode
145}
146
147/** Inject a custom theme's CSS and finalize its mode. Falls back to the clean
148 * light export if the theme can't be loaded, so a broken or missing custom

Callers 1

applyExportPrefsFunction · 0.85

Calls 5

isCustomThemeIdFunction · 0.90
resolveCustomThemeModeFunction · 0.90
resolveAutoFunction · 0.90
findThemeFunction · 0.90
applyLightExportThemeFunction · 0.85

Tested by

no test coverage detected