mirror of
https://github.com/trafficlunar/tomodachi-share.git
synced 2026-06-28 14:44:15 +00:00
fix: account for header height in dialogs
This commit is contained in:
parent
ce7a57baef
commit
efda1acdc1
7 changed files with 29 additions and 7 deletions
|
|
@ -1,8 +1,30 @@
|
|||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { ProgressProvider } from "@bprogress/next/app";
|
||||
|
||||
export default function Providers({ children }: { children: React.ReactNode }) {
|
||||
// Calculate header height
|
||||
useEffect(() => {
|
||||
const header = document.querySelector("header");
|
||||
if (!header) return;
|
||||
|
||||
const updateHeaderHeight = () => {
|
||||
document.documentElement.style.setProperty("--header-height", `${header.offsetHeight}px`);
|
||||
};
|
||||
|
||||
const resizeObserver = new ResizeObserver(updateHeaderHeight);
|
||||
resizeObserver.observe(header);
|
||||
window.addEventListener("resize", updateHeaderHeight);
|
||||
|
||||
updateHeaderHeight();
|
||||
|
||||
return () => {
|
||||
resizeObserver.disconnect();
|
||||
window.removeEventListener("resize", updateHeaderHeight);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ProgressProvider height="4px" color="var(--color-amber-500)" options={{ showSpinner: false }} shallowRouting>
|
||||
{children}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue