diff --git a/src/components/SectionVideos.tsx b/src/components/SectionVideos.tsx new file mode 100644 index 0000000..301bcef --- /dev/null +++ b/src/components/SectionVideos.tsx @@ -0,0 +1,150 @@ +"use client"; + +import Heading from "@/shared/Heading"; +import NcPlayIcon from "@/shared/NcPlayIcon"; +import NcPlayIcon2 from "@/shared/NcPlayIcon2"; +import Image from "next/image"; +import React, { FC, useState } from "react"; + +export interface VideoType { + id: string; + title: string; + thumbnail: string; +} + +export interface SectionVideosProps { + videos?: VideoType[]; + className?: string; +} + +const VIDEOS_DEMO: VideoType[] = [ + { + id: "Ao7e4iisKMs", + title: "Magical Scotland - 4K Scenic Relaxation Film with Calming Music", + thumbnail: + "https://images.pexels.com/photos/131423/pexels-photo-131423.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", + }, + { + id: "a5V6gdu5ih8", + title: "Magical Scotland - 4K Scenic Relaxation Film with Calming Music", + thumbnail: + "https://images.pexels.com/photos/186077/pexels-photo-186077.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", + }, + { + id: "MuB7HHeuNbc", + title: "Magical Scotland - 4K Scenic Relaxation Film with Calming Music", + thumbnail: + "https://images.pexels.com/photos/1660995/pexels-photo-1660995.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", + }, + { + id: "eEaZvEZye84", + title: "Magical Scotland - 4K Scenic Relaxation Film with Calming Music", + thumbnail: + "https://images.pexels.com/photos/4983184/pexels-photo-4983184.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", + }, + { + id: "EuDJZDaSP0Q", + title: "Magical Scotland - 4K Scenic Relaxation Film with Calming Music", + thumbnail: + "https://images.pexels.com/photos/2549018/pexels-photo-2549018.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260", + }, +]; + +const SectionVideos: FC = ({ + videos = VIDEOS_DEMO, + className = "", +}) => { + const [isPlay, setIsPlay] = useState(false); + const [currentVideo, setCurrentVideo] = useState(0); + + const renderMainVideo = () => { + const video: VideoType = videos[currentVideo]; + return ( +
+ {isPlay ? ( + + ) : ( + <> +
setIsPlay(true)} + className="cursor-pointer absolute inset-0 flex items-center justify-center z-10" + > + +
+ + {video.title} + + )} +
+ ); + }; + + const renderSubVideo = (video: VideoType, index: number) => { + if (index === currentVideo) return null; + return ( +
{ + setCurrentVideo(index); + !isPlay && setIsPlay(true); + }} + title={video.title} + key={String(index)} + > +
+ +
+ {video.title} +
+ ); + }; + + return ( +
+ + 🎬 The Videos + + +
+
+
+ {renderMainVideo()} +
+
+ {videos.map(renderSubVideo)} +
+
+
+ ); +}; + +export default SectionVideos;