From 59b676895d81059c2173a6e52cdf01b9c55574ed Mon Sep 17 00:00:00 2001 From: Justin Walrath Date: Mon, 12 May 2025 13:14:29 -0400 Subject: [PATCH] Add podcast card is now a button at the bottom of the page --- src/app/[stream]/podcasts/addPodcastCard.tsx | 28 +++++++++++++++++--- src/app/[stream]/podcasts/podcastList.tsx | 2 +- src/app/layout/main.tsx | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) 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 (
- + + +
); } \ No newline at end of file diff --git a/src/app/[stream]/podcasts/podcastList.tsx b/src/app/[stream]/podcasts/podcastList.tsx index 9705650..6dad439 100644 --- a/src/app/[stream]/podcasts/podcastList.tsx +++ b/src/app/[stream]/podcasts/podcastList.tsx @@ -16,7 +16,7 @@ export default function PodcastList({ stream }: PodcastListProps) { fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/${stream}/podcasts`) .then((res) => res.json()) .then((data) => setPodcastData(data)); - }, []); + }, [stream]); return (
diff --git a/src/app/layout/main.tsx b/src/app/layout/main.tsx index d29de85..afe50db 100644 --- a/src/app/layout/main.tsx +++ b/src/app/layout/main.tsx @@ -21,7 +21,7 @@ export default function Main({ children }: MainProps) {
{children}
-