ghost-keychain/packages/extension-ui/src/components/themes.ts
Jaco ca595cdfab
2024 (#1302)
* 2024

* 2024
2024-01-08 15:05:09 +02:00

21 lines
521 B
TypeScript

// Copyright 2019-2024 @polkadot/extension-ui authors & contributors
// SPDX-License-Identifier: Apache-2.0
export declare type Theme = 'light' | 'dark';
export const themes = ['light', 'dark'] as const;
export function chooseTheme (): Theme {
const preferredTheme = localStorage.getItem('theme');
if (preferredTheme) {
return preferredTheme === 'dark'
? 'dark'
: 'light';
}
return window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches
? 'light'
: 'dark';
}