11import React from "react" ;
22import { ScrollArea } from "@/components/ui/scroll-area" ;
3+ import { cn } from "@/lib/utils" ;
34
45interface FooterLayoutWidgetProps {
56 slots ?: {
@@ -9,6 +10,30 @@ interface FooterLayoutWidgetProps {
910}
1011
1112export const FooterLayoutWidget : React . FC < FooterLayoutWidgetProps > = ( { slots } ) => {
13+ const [ hasMoreContent , setHasMoreContent ] = React . useState ( false ) ;
14+ const scrollRef = React . useRef < HTMLDivElement > ( null ) ;
15+
16+ React . useEffect ( ( ) => {
17+ const viewport = scrollRef . current ?. querySelector ( "[data-radix-scroll-area-viewport]" ) ;
18+ if ( ! viewport ) return ;
19+
20+ const handleScroll = ( ) => {
21+ const { scrollTop, scrollHeight, clientHeight } = viewport ;
22+ setHasMoreContent ( scrollTop < scrollHeight - clientHeight - 1 ) ;
23+ } ;
24+
25+ handleScroll ( ) ;
26+
27+ viewport . addEventListener ( "scroll" , handleScroll ) ;
28+ const resizeObserver = new ResizeObserver ( handleScroll ) ;
29+ resizeObserver . observe ( viewport ) ;
30+
31+ return ( ) => {
32+ viewport . removeEventListener ( "scroll" , handleScroll ) ;
33+ resizeObserver . disconnect ( ) ;
34+ } ;
35+ } , [ ] ) ;
36+
1237 if ( ! slots ?. Footer || ! slots ?. Content ) {
1338 return (
1439 < div className = "text-red-500" >
@@ -19,12 +44,17 @@ export const FooterLayoutWidget: React.FC<FooterLayoutWidgetProps> = ({ slots })
1944
2045 return (
2146 < div className = "h-full flex flex-col relative remove-parent-padding" >
22- < div className = "flex-1 min-h-0 overflow-hidden" >
47+ < div ref = { scrollRef } className = "flex-1 min-h-0 overflow-hidden" >
2348 < ScrollArea className = "h-full" >
2449 < div className = "p-4" > { slots . Content } </ div >
2550 </ ScrollArea >
2651 </ div >
27- < div className = "flex-none w-full bg-background" >
52+ < div
53+ className = { cn (
54+ "flex-none w-full bg-background transition-shadow" ,
55+ hasMoreContent && "shadow-[0_-2px_4px_rgba(0,0,0,0.1)]" ,
56+ ) }
57+ >
2858 < div className = "border-t" > </ div >
2959 < div className = "p-4" > { slots . Footer } </ div >
3060 </ div >
0 commit comments