import { AnimatePresence, motion, useScroll, useTransform } from 'framer-motion' import { ChevronLeft } from 'lucide-react' import { useRouter } from 'next/compat/router' import Link from 'next/link' import { forwardRef, useRef } from 'react' import { useParams } from 'common' import { INTEGRATIONS } from 'components/interfaces/Integrations/Landing/Integrations.constants' import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext' import { Badge, cn } from 'ui' interface HeaderProps { scroll: ReturnType } export const Header = forwardRef(({ scroll }, ref) => { const router = useRouter() const { id } = useParams() // Get project context const { project } = useProjectContext() // Find the integration details based on ID const integration = INTEGRATIONS.find((i) => i.id === id) // Check if we're on the main integrations page const isIntegrationsHome = !id const layoutTransition = { duration: 0.15 } const headerRef = useRef(null) // Input range: The scrollY range for triggering the animation (e.g., 0 to 200px of scroll) const scrollRange = [40, headerRef.current?.offsetHeight ?? 128] // Output range: The Y position range for the icon (e.g., 0 to 150px movement) const iconYRange = [0, headerRef.current?.offsetHeight ? headerRef.current.offsetHeight / 2 : 64] // Change 150 to set the end Y position of the icon // Output range: The size range for the icon container const sizeRange = [32, 20] // From 24px (scrolled) to 32px (top) // Output range: The padding range for the image const iconPaddingRange = [3, 1.5] // From 1.5px (scrolled) to 4px (top) // Map scrollY to the icon's Y position const iconY = useTransform(scroll?.scrollY!, scrollRange, iconYRange) const iconSize = useTransform(scroll?.scrollY!, scrollRange, sizeRange) const iconPadding = useTransform(scroll?.scrollY!, scrollRange, iconPaddingRange) if (!router?.isReady) { return null } return ( <> {/* Main header content */}
{/* Container with animated padding */} {/* Navigation link back to integrations landing */}
{/* Back arrow */} {!isIntegrationsHome && ( )} {/* Two separate spans with the same key */} {isIntegrationsHome ? ( Integrations ) : ( Integrations )}
{/* Integration details section - only shown when viewing a specific integration */} {!isIntegrationsHome && integration && ( {/* Integration icon */} {integration.icon({ style: { padding: iconPadding.get(), }, })} {/* Integration name and description */}
{integration.name} {integration.status && ( {integration.status} )}

{integration.description}

)}
) }) Header.displayName = 'Header'