fix(TypeScript): Fix getTheme function logic
@@ -10,15 +10,13 @@ export type ThemeNames = Themes[keyof Themes]
export const themePath = 'dist/themes'
-const themeNameGuard = (s: string): s is keyof Themes =>
- s.toLowerCase() in themes
+const themeNameGuard = (s: string): s is keyof Themes => s in themes
/**
* Given a string, will attempt to return a matching Thema theme, falling back to Stencila in case none is found
* @param {string} name Name of the theme to look for
*/
export const getTheme = (name?: string): ThemeNames => {
- return name !== undefined && themeNameGuard(name)
- ? themes[name]
- : themes.stencila
+ const theme = name === undefined ? '' : name.toLowerCase().trim()
+ return themeNameGuard(theme) ? themes[theme] : themes.stencila
}
