feat: massive front-end overhaul and initial github release

This commit is contained in:
Simeon Radivoev 2026-02-08 21:18:10 +02:00
parent a2b40e38bf
commit d5a0e70580
Signed by: simeonradivoev
GPG key ID: 7611A451D2A5D37A
303 changed files with 19840 additions and 676 deletions

View file

@ -0,0 +1,58 @@
import { doesFocusableExist, getCurrentFocusKey } from "@noriginmedia/norigin-spatial-navigation";
import { RefObject, useEffect } from "react";
export function selfFocusSmart (shouldFocus: boolean, focusSelf: () => void)
{
if (shouldFocus && (!getCurrentFocusKey() || !doesFocusableExist(getCurrentFocusKey())))
{
console.log("Self Focus");
focusSelf();
}
}
export type ScrollSaveParams = {
id: string;
ref: RefObject<HTMLElement>;
storage?: "session" | "local";
shouldSave?: boolean;
};
export function useScrollSave (data: ScrollSaveParams)
{
useEffect(() =>
{
const storage = data.storage === "local" ? localStorage : sessionStorage;
const key = `scroll-${data.id}`;
const element = data.ref.current;
if (element)
{
if (storage.getItem(key))
{
const scrollData = JSON.parse(storage.getItem(key)!);
element.scrollLeft = scrollData.x;
element.scrollTop = scrollData.y;
}
}
function scrollHandler (e: Event)
{
if (!data.shouldSave || data.shouldSave === true)
{
const currentTarget = e.currentTarget as HTMLElement;
storage.setItem(
key,
JSON.stringify({
x: currentTarget.scrollLeft,
y: currentTarget.scrollTop,
}),
);
}
}
element?.addEventListener("scrollend", scrollHandler);
return () => element?.removeEventListener("scrollend", scrollHandler);
}, [data.id, data.ref.current, data.storage]);
return { ref: data.ref };
}