Skip to documentation
Design system / Sources & standards
Current repository source
useViewportNoticeFrame.ts
src/components/navigation/useViewportNoticeFrame.ts
This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.
"use client";
import { useLayoutEffect, useRef } from "react";
/** Measure flow content, including wrapping and mutation feedback, before paint. */
export function useViewportNoticeFrame() {
const frame = useRef<HTMLDivElement>(null);
const notice = useRef<HTMLDivElement>(null);
useLayoutEffect(() => {
const owner = frame.current;
const content = notice.current;
if (!owner || !content) return;
const measure = () => owner.style.setProperty("--viewport-bottom-clearance", `${content.getBoundingClientRect().height}px`);
measure();
const observer = new ResizeObserver(measure);
observer.observe(content);
return () => {
observer.disconnect();
owner.style.removeProperty("--viewport-bottom-clearance");
};
}, []);
return { frame, notice };
}
All sources and standards