ThemeService
Class | Source Code
Provides means by which to register themes, change the active theme, and listen to when the theme changes. Also includes helper methods for dealing with themes and colors.
Constructors
Section titled “Constructors”new ThemeService()
Section titled “new ThemeService()”Properties
Section titled “Properties”static parchment: Theme
Section titled “static parchment: Theme”A lighter theme with an off-white background, deep chocolates for text, beautiful blue buttons, and lovely lavender accents.
static onChangeTheme: Event
Section titled “static onChangeTheme: Event”Event for when the current theme changes or is modified.
static light: Theme
Section titled “static light: Theme”A classic light theme, featuring blue buttons and aqua accents.
static defaultTheme: Theme
Section titled “static defaultTheme: Theme”A default theme you can use to get going. This theme is NOT in the set of registered themes, but will be used to set the theme CSS variables by default. Same as ThemeService.dark.
static dark: Theme
Section titled “static dark: Theme”A dark theme that primarily uses shades of gray with pops of soft blue for buttons and an aqua for accent.
Accessors
Section titled “Accessors”static themes: Theme[]
Section titled “static themes: Theme[]”static currentTheme: Theme
Section titled “static currentTheme: Theme”Methods
Section titled “Methods”updateTheme(themeName: string, newThemeData: Partial<Omit<Theme, “name”>>): void
Section titled “updateTheme(themeName: string, newThemeData: Partial<Omit<Theme, “name”>>): void”Updates the specified theme, modifying its registered data.
registerTheme(theme: Theme, autoSetCurrent: boolean): void
Section titled “registerTheme(theme: Theme, autoSetCurrent: boolean): void”Registers the specified theme with the service, allowing the theme to be used as the current theme. If the theme shares a name with an already-registered theme, nothing happens.
lighten(hexColor: string, amount: number): string
Section titled “lighten(hexColor: string, amount: number): string”Lightens a hex color.
Returns
Section titled “Returns”The lightened color.
darken(hexColor: string, amount: number): string
Section titled “darken(hexColor: string, amount: number): string”Darkens a hex color.
Returns
Section titled “Returns”The darkened color.
changeTheme(themeName: string): void
Section titled “changeTheme(themeName: string): void”Changes the theme to the specified one if the specified theme has been registered with the service. If the specified
theme is found, the current theme is updated and the onChangeTheme event is invoked.