import Header from "@Front/Components/DesignSystem/Header"; import Version from "@Front/Components/DesignSystem/Version"; import classNames from "classnames"; import Image, { StaticImageData } from "next/image"; import React, { ReactNode, useEffect, useRef } from "react"; import classes from "./classes.module.scss"; import { useWindowSize } from "@uidotdev/usehooks"; type IProps = { title: string; children?: ReactNode; /** * @description scroll top with number or disabled with null */ scrollTop?: number | null; image: StaticImageData; type?: "background" | "image"; showHeader?: boolean; }; export default function DefaultDoubleSidePage(props: IProps) { const { title, children, scrollTop = 0, image, type = "background", showHeader = false } = props; useEffect(() => { window.document.title = title; if (scrollTop !== null) { window.scrollTo(0, scrollTop); } }, [scrollTop, title]); useEffect(() => { // make second element ref height same as first element ref height const resizeObserver = new ResizeObserver(() => { if (secondElementRef.current && firstElementRef.current) { console.log("Recalculate"); if (secondElementRef.current.clientHeight !== 0) { secondElementRef.current.style.height = `0px`; } secondElementRef.current.style.height = `${firstElementRef.current.clientHeight}px`; } }); if (firstElementRef.current) { resizeObserver.observe(firstElementRef.current); } return () => resizeObserver.disconnect(); }, []); const firstElementRef = useRef(null); const secondElementRef = useRef(null); return (
{children}
{type === "image" && (
{"right
)} {type === "background" && (
{"right
)}
); }