import classNames from "classnames"; import { useEffect, useState } from "react"; import { Link, To, useNavigate } from "react-router-dom"; import { NoUserAvatar, UserAvatar } from "@/components/Avatar"; import { IconPatch } from "@/components/buttons/IconPatch"; import { Icons } from "@/components/Icon"; import { LinksDropdown } from "@/components/LinksDropdown"; import { useNotifications } from "@/components/overlays/notificationsModal"; import { Lightbar } from "@/components/utils/Lightbar"; import { useAuth } from "@/hooks/auth/useAuth"; import { BlurEllipsis } from "@/pages/layouts/SubPageLayout"; import { conf } from "@/setup/config"; import { useBannerSize } from "@/stores/banner"; import { usePreferencesStore } from "@/stores/preferences"; import { BrandPill } from "./BrandPill"; export interface NavigationProps { bg?: boolean; noLightbar?: boolean; doBackground?: boolean; clearBackground?: boolean; } export function Navigation(props: NavigationProps) { const bannerHeight = useBannerSize(); const navigate = useNavigate(); const { loggedIn } = useAuth(); const [scrollPosition, setScrollPosition] = useState(0); const { openNotifications, getUnreadCount } = useNotifications(); useEffect(() => { const handleScroll = () => { setScrollPosition(window.scrollY); }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const handleClick = (path: To) => { window.scrollTo(0, 0); navigate(path); }; // Calculate mask length based on scroll position const getMaskLength = () => { // When at top (0), use longer mask (200px) // When scrolled down (300px+), use shorter mask (100px) const maxScroll = 300; const minLength = 100; const maxLength = 180; const scrollFactor = Math.min(scrollPosition, maxScroll) / maxScroll; return minLength + (maxLength - minLength) * (1 - scrollFactor); }; const enableLowPerformanceMode = usePreferencesStore( (s) => s.enableLowPerformanceMode, ); return ( <> {/* lightbar */} {!props.noLightbar ? (
) : null} {/* backgrounds - these are seperate because of z-index issues */}
{props.doBackground ? (
) : null}
{/* content */}
{loggedIn ? : }
); }