spacedrive/interface/hooks/useIsDark.ts
Ericson "Fogo" Soares e693c7a542
[ENG-381] Update context menufs actions to support multiple source (#927)
* Generalizing filesystem jobs to accept multiple files at once

* Some small changes and fixing front

* Enable rename route to replicate Finder's behavior

* Assign tag to multiple objects at once

* Remove from recents accepting multiple files

* Fixing some warnings

* Adding multiple files feature to Open and Open With

* Conditional stuff for macos

* Generating commands.ts and other minor warnings

* Rust fmt

* TS typecheck

* Rust format and TS typecheck

* Requested changes

* Requested changes

---------

Co-authored-by: Utku <74243531+utkubakir@users.noreply.github.com>
2023-06-14 23:00:28 +00:00

26 lines
690 B
TypeScript

import { useEffect, useState } from 'react';
import { useThemeStore } from '@sd/client';
//this hook is being used for some ui elements & icons that need to be inverted
export function useIsDark(): boolean {
const themeStore = useThemeStore();
const [isDark, setIsDark] = useState(themeStore.theme === 'dark');
useEffect(() => {
if (themeStore.syncThemeWithSystem) {
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
setIsDark(true);
} else setIsDark(false);
} else {
if (themeStore.theme === 'dark') {
setIsDark(true);
} else if (themeStore.theme === 'vanilla') {
setIsDark(false);
}
}
}, [setIsDark, themeStore]);
return isDark;
}