feat: Add the option to toggle the dark/light color-scheme (#7662)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sivin Varghese
2023-08-04 00:51:45 +05:30
committed by GitHub
parent 69d46f278a
commit 10d6e9551d
10 changed files with 202 additions and 28 deletions

View File

@@ -0,0 +1,17 @@
import { LocalStorage } from 'shared/helpers/localStorage';
import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage';
export const setColorTheme = isOSOnDarkMode => {
const selectedColorScheme =
LocalStorage.get(LOCAL_STORAGE_KEYS.COLOR_SCHEME) || 'auto';
if (
(selectedColorScheme === 'auto' && isOSOnDarkMode) ||
selectedColorScheme === 'dark'
) {
document.body.classList.add('dark');
document.documentElement.setAttribute('style', 'color-scheme: dark;');
} else {
document.body.classList.remove('dark');
document.documentElement.setAttribute('style', 'color-scheme: light;');
}
};