More theme stuff

This commit is contained in:
Gregory Schier
2024-05-24 17:36:48 -07:00
parent 11814b56f1
commit f3024a259e
17 changed files with 142 additions and 68 deletions
+18
View File
@@ -0,0 +1,18 @@
import { useEffect, useState } from 'react';
import {
type Appearance,
getPreferredAppearance,
subscribeToPreferredAppearanceChange,
} from '../lib/theme/window';
export function usePreferredAppearance() {
const [preferredAppearance, setPreferredAppearance] = useState<Appearance>();
// Set appearance when preferred theme changes
useEffect(() => {
getPreferredAppearance().then(setPreferredAppearance);
return subscribeToPreferredAppearanceChange(setPreferredAppearance);
}, []);
return preferredAppearance;
}