UNPKG

@dvcol/common-utils

Version:

Typescript library for common utility functions and constants

28 lines (26 loc) 1 kB
/** * Returns true if window prefers-color-scheme is dark */ declare const isDarkTheme: () => boolean; /** * Returns true if window prefers-color-scheme is light */ declare const isLightTheme: () => boolean; /** * Watch the theme change and call the callback * @param callback callback to call when the theme changes * @param watched theme to watch (default: dark) */ declare const watchTheme: (callback: (theme: 'light' | 'dark', event: MediaQueryListEvent) => void, watched?: 'light' | 'dark') => () => void; /** * Disposable version of watchTheme (compatible with ts5.x using Symbol.dispose) * * @param callback callback to call when the theme changes * @param watched theme to watch (default: dark) * * @see watchTheme */ declare const watchDarkThemeDisposable: (callback: (theme: 'light' | 'dark', event: MediaQueryListEvent) => void, watched?: 'light' | 'dark') => { [Symbol.dispose]: () => void; }; export { isDarkTheme, isLightTheme, watchDarkThemeDisposable, watchTheme };