import { useCallback, useLayoutEffect, useState } from "react"; import { Dialog } from "@headlessui/react"; import { faXmark } from "@fortawesome/pro-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { TOP_BAR_HEIGHT } from "~/constants"; export const SidePanelInner = ({ title, children, closeCallback, }: { title?: string; children: React.ReactNode; closeCallback: () => void; }) => { const [height, setHeight] = useState(0); const handleWindowResize = useCallback(() => { if (window) { setHeight(Math.ceil((window.innerHeight * 3) / 4) - TOP_BAR_HEIGHT); } return 0; }, []); useLayoutEffect(() => { handleWindowResize(); window.addEventListener("resize", handleWindowResize); return () => { window.removeEventListener("resize", handleWindowResize); }; }, [handleWindowResize]); return (