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)
| 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. */ |
| 122 | function 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 |
no test coverage detected