This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TypeScript): Generate TS declarations & export theme names
- Loading branch information
1 parent
817d2c8
commit be71bd0
Showing
4 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
export const themes = { | ||
eLife: 'themes/eLife', | ||
nature: 'themes/nature', | ||
plos: 'themes/plos', | ||
stencila: 'themes/stencila' | ||
elife: 'eLife' as const, | ||
nature: 'nature' as const, | ||
plos: 'plos' as const, | ||
stencila: 'stencila' as const | ||
} | ||
|
||
type Themes = typeof themes | ||
export type ThemeNames = Themes[keyof Themes] | ||
|
||
export const themePath = 'dist/themes' | ||
|
||
const themeNameGuard = (s: string): s is keyof Themes => | ||
s.toLowerCase() 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters