[techdocs/cli] Use light theme if it's not dark, to avoid breaking the theme selector on other values in local storage

Fixes #12995

Signed-off-by: Axel Hecht <axel@pike.org>
This commit is contained in:
Axel Hecht
2022-08-11 17:40:04 +02:00
parent 49c01cdd33
commit 05fc47c525
2 changed files with 6 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'techdocs-cli-embedded-app': patch
---
Theme selector in `npx @techdocs/cli serve` would break if localstorage had a non-light-or-dark value for theme.
@@ -55,7 +55,7 @@ export const TechDocsThemeToggle = () => {
const appThemeApi = useApi(appThemeApiRef);
const classes = useStyles();
const [theme, setTheme] = useState<Themes>(
(appThemeApi.getActiveThemeId() as Themes) || Themes.LIGHT,
appThemeApi.getActiveThemeId() === Themes.DARK ? Themes.DARK : Themes.LIGHT,
);
const themes = {