Initial commit

This commit is contained in:
Basiclean committed 2026-05-02 10:41:00 +02:00
commit bcca176137
88 files changed
+8725

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
"use client";
import { useLayoutEffect } from "react";
type Mode = "scroll" | "offset";
export function useHeightVar(
ref: React.RefObject<HTMLElement | null>,
cssVarName: string,
mode: Mode = "scroll",
trigger?: unknown,
) {
useLayoutEffect(() => {
const el = ref.current;
if (!el) return;
const measure = () => {
const h = mode === "scroll" ? el.scrollHeight : el.offsetHeight;
el.style.setProperty(cssVarName, `${h}px`);
};
measure();
const ro = new ResizeObserver(measure);
ro.observe(el);
return () => ro.disconnect();
}, [ref, cssVarName, mode, trigger]);
}