feat: add settings menu
All checks were successful
Deploy to VPS (dist) / deploy (push) Successful in 1m40s

This commit is contained in:
Hewston Fox
2026-03-22 04:08:56 +02:00
parent 2a1115b66f
commit 5e9acffa09
89 changed files with 3412 additions and 216 deletions

View File

@@ -0,0 +1,57 @@
import { createContext, useCallback, useContext, useRef, useState } from "react";
import type { ReactNode } from "react";
type LiftContextValue = {
liftedIds: Set<string>;
alwaysLiftedIds: Set<string>;
setLiftedIds: (ids: string[]) => void;
registerAlways: (id: string) => void;
unregisterAlways: (id: string) => void;
portalContainer: HTMLElement | null;
setPortalContainer: (el: HTMLElement | null) => void;
};
const LiftContext = createContext<LiftContextValue | null>(null);
export function useLift(): LiftContextValue {
const ctx = useContext(LiftContext);
if (!ctx) throw new Error("useLift must be used within LiftProvider");
return ctx;
}
export function LiftProvider({ children }: { children: ReactNode }) {
const [liftedIds, setLiftedIdsRaw] = useState<Set<string>>(new Set());
const [alwaysLiftedIds, setAlwaysLiftedIds] = useState<Set<string>>(new Set());
const [portalContainer, setPortalContainer] = useState<HTMLElement | null>(null);
const alwaysRef = useRef<Set<string>>(new Set());
const setLiftedIds = useCallback((ids: string[]) => {
setLiftedIdsRaw(new Set(ids));
}, []);
const registerAlways = useCallback((id: string) => {
alwaysRef.current.add(id);
setAlwaysLiftedIds(new Set(alwaysRef.current));
}, []);
const unregisterAlways = useCallback((id: string) => {
alwaysRef.current.delete(id);
setAlwaysLiftedIds(new Set(alwaysRef.current));
}, []);
return (
<LiftContext
value={{
liftedIds,
alwaysLiftedIds,
setLiftedIds,
registerAlways,
unregisterAlways,
portalContainer,
setPortalContainer,
}}
>
{children}
</LiftContext>
);
}