전 저장소 리팩터링과 SSOT 정비
This commit is contained in:
parent
14ecbd4e7d
commit
3dfddcac6f
173 changed files with 19679 additions and 6952 deletions
17
apps/web/src/lib/useTheme.ts
Normal file
17
apps/web/src/lib/useTheme.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { useCallback, useSyncExternalStore } from "react";
|
||||
import {
|
||||
applyTheme,
|
||||
readAppliedTheme,
|
||||
subscribeTheme,
|
||||
type AppTheme,
|
||||
} from "./theme";
|
||||
|
||||
/**
|
||||
* 전역 테마 hook. Topbar와 Settings가 같은 external store를 구독한다.
|
||||
* 반환 형태는 기존 Settings 계약([dark, setDark])을 유지한다.
|
||||
*/
|
||||
export function useTheme(): [boolean, (next: boolean) => void] {
|
||||
const theme = useSyncExternalStore(subscribeTheme, readAppliedTheme, (): AppTheme => "dark");
|
||||
const setDark = useCallback((next: boolean) => applyTheme(next ? "dark" : "light"), []);
|
||||
return [theme === "dark", setDark];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue