UNPKG

@rxap/ngx-theme

Version:

This package provides an Angular theme service that allows you to manage and customize the look and feel of your application. It includes features such as dark mode support, theme density control, typography settings, and color palette management. The ser

67 lines (66 loc) 2.76 kB
import { MediaMatcher } from '@angular/cdk/layout'; import { WritableSignal } from '@angular/core'; import { ConfigService } from '@rxap/config'; import { PubSubService } from '@rxap/ngx-pub-sub'; import { ThemeDensity } from '@rxap/utilities'; import { Subscription } from 'rxjs'; import { ColorPalette } from './compute-color-palette'; import { ThemeModeService } from './theme-mode.service'; import * as i0 from "@angular/core"; export interface ColorPaletteConfigWithName extends ColorPaletteConfig { name?: string; } export interface ThemeConfig { primaryColor?: ColorPaletteConfigWithName; accentColor?: ColorPaletteConfigWithName; warnColor?: ColorPaletteConfigWithName; density?: ThemeDensity; typography?: string; } export interface ColorPaletteConfig { algorithm?: string; base?: string; color?: Partial<ColorPalette>; } export declare class ThemeService { private readonly mediaMatcher; readonly config: ConfigService<any>; readonly pubSub: PubSubService; readonly themeModeService: ThemeModeService; readonly darkMode: import("@angular/core").Signal<boolean>; readonly themeName: WritableSignal<string>; readonly density: WritableSignal<ThemeDensity>; readonly typography: WritableSignal<string>; protected syncSubscription?: Subscription; constructor(mediaMatcher: MediaMatcher); restore(): void; protected restoreFromPubSub(): void; private get themeNameLocalStorageKey(); private get densityLocalStorageKey(); private get typographyLocalStorageKey(); restoreThemeName(): string | null; restoreTypography(): string | null; restoreDensity(): ThemeDensity | null; toggleDarkTheme(): void; setDarkTheme(darkMode: boolean, silent?: boolean, publish?: boolean): void; setDensity(density: ThemeDensity, silent?: boolean, publish?: boolean): void; setTypography(typography: string, silent?: boolean, publish?: boolean): void; setTheme(themeName: string, silent?: boolean, publish?: boolean): void; applyDensity(density: ThemeDensity): void; applyTypography(typography: string): void; applyTheme(themeName: string): void; getDensity(): ThemeDensity; getTypography(): string; getTheme(): string; getAvailableColorPalettes(): string[] | null; getAvailableThemes(): string[] | null; getAvailableTypographies(): string[] | null; getColorPalette(colorPaletteName: string): Partial<ColorPalette>; private coerceColorPalette; private getThemeConfig; private setCssColorVariables; private clearCssColorVariables; private resetToDefaultTheme; static ɵfac: i0.ɵɵFactoryDeclaration<ThemeService, never>; static ɵprov: i0.ɵɵInjectableDeclaration<ThemeService>; }