Path: blob/main/components/donate/DonateWrapper.tsx
1006 views
import classNames from "classnames"1import Head from "next/head"2import Image from "next/image"3import { useLayoutEffect, useState } from "react"45import { Theme } from "../../donate/types"6import { isInIframe } from "../../donate/utils"78import heroDesktopImage from "../../public/illustrations/default_hero_desktop.png"9import heroMobileImage from "../../public/illustrations/default_hero_mobile.png"1011interface DonateWrapperProps {12children: React.ReactNode13className?: string14theme: Theme15belowModal?: React.ReactNode16}1718export function DonateWrapper({19children,20className,21theme = "auto",22belowModal,23}: DonateWrapperProps) {24// This is done this way to avoid hydration errors.25// See: https://nextjs.org/docs/messages/react-hydration-error26const [isClient, setIsClient] = useState(false)27useLayoutEffect(() => {28setIsClient(isInIframe())29}, [])3031if (isClient) {32return (33<div34className={classNames(35"bg-white dark:bg-black min-h-screen flex flex-col",36theme,37className38)}39>40{children}41</div>42)43}4445return (46<main47className={classNames(48theme,49"min-h-screen dark:bg-black overflow-hidden relative px-4"50)}51>52<div53className={classNames(54"w-full max-w-md mx-auto mt-20 flex flex-col relative z-10",55"bg-white dark:bg-black text-black dark:text-white dark:border dark:border-gray-0 rounded-lg overflow-hidden drop-shadow-lg",56className57)}58>59{children}60</div>61{belowModal}6263<div className="fixed top-0 left-0">64<Image65src={heroDesktopImage}66alt=""67role="presentation"68className="hidden xl:block"69objectFit="cover"70objectPosition="center bottom"71placeholder="empty"72/>73<Image74src={heroMobileImage}75alt=""76role="presentation"77className="block xl:hidden"78objectFit="cover"79objectPosition="center bottom"80placeholder="empty"81/>82</div>8384<Head>85<title>Donate - Mastodon</title>86</Head>87</main>88)89}909192