diff --git a/src/app/[stream]/podcasts/addPodcastCard.tsx b/src/app/[stream]/podcasts/addPodcastCard.tsx index de64e14..8812e60 100644 --- a/src/app/[stream]/podcasts/addPodcastCard.tsx +++ b/src/app/[stream]/podcasts/addPodcastCard.tsx @@ -1,18 +1,40 @@ +"use client"; + import { useRouter } from 'next/navigation'; +import { useState, useEffect } from 'react'; export default function AddPodcastCard({ stream }: { stream?: string | string[] }) { - const router = useRouter(); + const router = useRouter(), + defaultBottomOffset = 16, + [bottomOffset, setBottomOffset] = useState(defaultBottomOffset); const handleClick = () => { router.push(`${process.env.NEXT_PUBLIC_API_BASE_URL}/${stream}/publish`); }; + useEffect(() => { + const handleScroll = () => { + const footer = document.querySelector('footer'); + if (!footer) return; + + const footerRect = footer.getBoundingClientRect(), + viewportHeight = window.innerHeight, + footerVisibleHeight = Math.max(0, viewportHeight - footerRect.top); + + setBottomOffset(footerVisibleHeight + 16); + }; + + window.addEventListener('scroll', handleScroll); + return () => window.removeEventListener('scroll', handleScroll); + }, []); + return (