mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:19:43 +08:00
- Settings → General gains a classic/modern layout choice; classic is a frozen snapshot of dev's sidebar and learning dashboard, modern keeps iterating. Variants differ only through slots, tokens and per-variant CSS on <html data-ui-layout>; the preference lives in localStorage. - Modern chrome: warm neutral tokens, WorkspaceMenu header, ⌘K command palette and keyboard shortcuts, PageBar location strip, swipeable PartnerRoster. - Remove dead HomeShortcuts, WorkspaceSwitcher and the inline sidebar search query chain.
32 lines
974 B
TypeScript
32 lines
974 B
TypeScript
"use client";
|
|
|
|
import { useSyncExternalStore } from "react";
|
|
import {
|
|
DEFAULT_UI_LAYOUT,
|
|
UI_LAYOUT_EVENT,
|
|
UI_LAYOUT_STORAGE_KEY,
|
|
applyUiLayoutToDocument,
|
|
readStoredUiLayout,
|
|
type UiLayout,
|
|
} from "@/lib/ui-layout";
|
|
|
|
function subscribe(onChange: () => void): () => void {
|
|
const onStorage = (event: StorageEvent) => {
|
|
if (event.key !== UI_LAYOUT_STORAGE_KEY) return;
|
|
// Another tab switched; keep this tab's <html> tokens in step.
|
|
applyUiLayoutToDocument(readStoredUiLayout());
|
|
onChange();
|
|
};
|
|
window.addEventListener(UI_LAYOUT_EVENT, onChange);
|
|
window.addEventListener("storage", onStorage);
|
|
return () => {
|
|
window.removeEventListener(UI_LAYOUT_EVENT, onChange);
|
|
window.removeEventListener("storage", onStorage);
|
|
};
|
|
}
|
|
|
|
/** The active UI layout. SSR and hydration render the default, then adopt. */
|
|
export function useUiLayout(): UiLayout {
|
|
return useSyncExternalStore(subscribe, readStoredUiLayout, () => DEFAULT_UI_LAYOUT);
|
|
}
|