@@ -4,61 +4,107 @@ import { useState } from "react"
44import { ChevronLeft , ChevronRight } from "lucide-react"
55import { PhoneFrame } from "@/components/ui-prompts/phone-frame"
66import { Button } from "@/components/ui/button"
7+ import { useIsMobile } from "@/hooks/use-mobile"
78
89interface ScreenshotGalleryProps {
910 screenshots : string [ ]
1011 title : string
12+ /** On mobile, the video is shown as the first carousel item */
13+ videoUrl ?: string | null
1114}
1215
1316export function ScreenshotGallery ( {
1417 screenshots,
1518 title,
19+ videoUrl,
1620} : ScreenshotGalleryProps ) {
1721 const [ activeIndex , setActiveIndex ] = useState ( 0 )
22+ const isMobile = useIsMobile ( )
23+
24+ // Only include video in carousel on mobile
25+ const includeVideo = isMobile && ! ! videoUrl
26+ const totalItems = includeVideo ? screenshots . length + 1 : screenshots . length
27+ const isVideoSlot = includeVideo && activeIndex === 0
28+ const screenshotIndex = includeVideo ? activeIndex - 1 : activeIndex
1829
1930 return (
2031 < div className = "flex flex-col items-center gap-4" >
21- { /* Main Phone Frame */ }
22- < PhoneFrame
23- src = { screenshots [ activeIndex ] }
24- alt = { `${ title } - Screenshot ${ activeIndex + 1 } ` }
25- className = "max-w-[280px] w-full"
26- />
32+ { /* Main display */ }
33+ { isVideoSlot ? (
34+ < div className = "max-w-[280px] w-full flex justify-center" >
35+ < video
36+ src = { videoUrl ! }
37+ autoPlay
38+ loop
39+ muted
40+ playsInline
41+ controls
42+ className = "max-w-[280px] w-full rounded-[2rem] border-[3px] border-neutral-700 bg-black object-cover"
43+ style = { { aspectRatio : "9 / 19.5" } }
44+ />
45+ </ div >
46+ ) : (
47+ < PhoneFrame
48+ src = { screenshots [ includeVideo ? screenshotIndex : activeIndex ] }
49+ alt = { `${ title } - Screenshot ${ ( includeVideo ? screenshotIndex : activeIndex ) + 1 } ` }
50+ className = "max-w-[280px] w-full"
51+ />
52+ ) }
2753
2854 { /* Thumbnail Strip */ }
29- { screenshots . length > 1 && (
55+ { totalItems > 1 && (
3056 < div className = "flex items-center gap-2" >
3157 < Button
3258 variant = "ghost"
3359 size = "icon"
3460 className = "h-8 w-8 text-muted-foreground hover:text-foreground"
3561 onClick = { ( ) =>
3662 setActiveIndex ( ( prev ) =>
37- prev === 0 ? screenshots . length - 1 : prev - 1
63+ prev === 0 ? totalItems - 1 : prev - 1
3864 )
3965 }
4066 >
4167 < ChevronLeft className = "h-4 w-4" />
4268 </ Button >
4369
4470 < div className = "flex items-center gap-2 overflow-x-auto" >
45- { screenshots . map ( ( src , index ) => (
71+ { /* Mobile-only video thumbnail */ }
72+ { includeVideo && (
4673 < button
47- key = { index }
48- onClick = { ( ) => setActiveIndex ( index ) }
74+ onClick = { ( ) => setActiveIndex ( 0 ) }
4975 className = { `flex-shrink-0 w-12 h-24 rounded-lg overflow-hidden border-2 transition-colors ${
50- index === activeIndex
76+ activeIndex === 0
5177 ? "border-foreground"
5278 : "border-border hover:border-primary/50"
5379 } `}
5480 >
55- < img
56- src = { src }
57- alt = { ` ${ title } - Thumbnail ${ index + 1 } ` }
81+ < video
82+ src = { videoUrl ! }
83+ muted
5884 className = "w-full h-full object-cover"
5985 />
6086 </ button >
61- ) ) }
87+ ) }
88+ { screenshots . map ( ( src , index ) => {
89+ const itemIndex = includeVideo ? index + 1 : index
90+ return (
91+ < button
92+ key = { index }
93+ onClick = { ( ) => setActiveIndex ( itemIndex ) }
94+ className = { `flex-shrink-0 w-12 h-24 rounded-lg overflow-hidden border-2 transition-colors ${
95+ itemIndex === activeIndex
96+ ? "border-foreground"
97+ : "border-border hover:border-primary/50"
98+ } `}
99+ >
100+ < img
101+ src = { src }
102+ alt = { `${ title } - Thumbnail ${ index + 1 } ` }
103+ className = "w-full h-full object-cover"
104+ />
105+ </ button >
106+ )
107+ } ) }
62108 </ div >
63109
64110 < Button
@@ -67,7 +113,7 @@ export function ScreenshotGallery({
67113 className = "h-8 w-8 text-muted-foreground hover:text-foreground"
68114 onClick = { ( ) =>
69115 setActiveIndex ( ( prev ) =>
70- prev === screenshots . length - 1 ? 0 : prev + 1
116+ prev === totalItems - 1 ? 0 : prev + 1
71117 )
72118 }
73119 >
0 commit comments