perf(useUIController): hoist page/panel transition objects to module scope (P2-32)

Stable refs across renders eliminate unnecessary motion prop diffing.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 22:56:14 -04:00
1 parent ca936aabe6
commit 1b76a51894
1 file changed
+6 -3
+6 -3
View File
@@ -46,11 +46,14 @@ const paletteOnlyNavDefs: NavItemDef[] = [
{ id: "knowledge", labelKey: "nav.knowledge", icon: BookOpen },
];
const NO_MOTION = { duration: 0 } as const;
const PAGE_TRANSITION = { duration: 0.32, ease: [0.16, 1, 0.3, 1] as const } as const;
const PANEL_TRANSITION = { duration: 0.28, ease: [0.16, 1, 0.3, 1] as const } as const;
export function useUIController() {
const reducedMotion = useReducedMotion();
const noMotion = { duration: 0 };
const pageTransition = reducedMotion ? noMotion : { duration: 0.32, ease: [0.16, 1, 0.3, 1] as const };
const panelTransition = reducedMotion ? noMotion : { duration: 0.28, ease: [0.16, 1, 0.3, 1] as const };
const pageTransition = reducedMotion ? NO_MOTION : PAGE_TRANSITION;
const panelTransition = reducedMotion ? NO_MOTION : PANEL_TRANSITION;
const locale = useAppStore((s) => s.locale);
const t = useMemo(() => createTranslator(locale), [locale]);