More theme stuff

This commit is contained in:
Gregory Schier
2024-05-24 17:36:48 -07:00
parent 3e8c01f436
commit 696e72323b
17 changed files with 142 additions and 68 deletions

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;
}