import type { JSX } from 'react' import type { MaxWidth } from '..' import { useIsMounted } from '@crypto-dex-sdk/hooks' import { ListboxButton, Transition } from '@headlessui/react' import { ArrowTopRightOnSquareIcon, EllipsisHorizontalIcon } from '@heroicons/react/24/outline' import { Trans } from '@lingui/macro' import useScrollPosition from '@react-hook/window-scroll' import React from 'react' import { classNames, Container, IconButton, Link, Select, Typography, useBreakpoint, ZenlinkIcon, } from '..' export enum AppType { Root = 'Explore Apps', Swap = 'Swap', Pool = 'Pool', Eden = 'Eden', Gauge = 'Gauge', Referrals = 'Referrals', Analytics = 'Analytics', Legacy = 'Old App', } export interface HeaderProps extends React.HTMLProps { nav?: JSX.Element withScrollBackground?: boolean apptype: AppType maxWidth?: MaxWidth bgColor?: string } export function Header({ children, className, nav, withScrollBackground = false, bgColor = 'bg-white dark:bg-slate-900', maxWidth = 'full', ...props }: HeaderProps): JSX.Element { const isMounted = useIsMounted() const scrollY = useScrollPosition() const { isMd } = useBreakpoint('md') // Show when: // 1. We scroll down for 45px // 2. When body has a negative top set for body lock for Dialogs on small screens const showBackground = (scrollY > 45 && withScrollBackground && isMounted) || (typeof window !== 'undefined' && !isMd ? Number(document.body.style.top.slice(0, -2)) < 0 && withScrollBackground : false) return (
{nav}
{children}
) } export default Header