Compare commits
2 Commits
eecaeb13e8
...
refactor/h
| Author | SHA1 | Date | |
|---|---|---|---|
| 72f13c7c2e | |||
| f9104c2580 |
@ -5,19 +5,19 @@ import { Button } from "@/shared/libs/shadcn/ui/button";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Autoplay, Navigation, Pagination } from "swiper/modules";
|
||||
import { Swiper, SwiperSlide } from "swiper/react";
|
||||
import { Icon } from "@iconify/react";
|
||||
|
||||
export interface HeroSwiperProps {
|
||||
data: {
|
||||
id: string;
|
||||
isClickable: boolean;
|
||||
title: string;
|
||||
tags: string[];
|
||||
description: string;
|
||||
buttonContent: string;
|
||||
buttonLink: string;
|
||||
slug: string;
|
||||
imageUrl: string;
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
synopsis: string;
|
||||
genres: {
|
||||
slug: string;
|
||||
name: string;
|
||||
}[];
|
||||
}[];
|
||||
}
|
||||
|
||||
@ -34,16 +34,13 @@ const HeroSwiper = (props: HeroSwiperProps) => {
|
||||
autoplay={{ delay: 5000, disableOnInteraction: false }}
|
||||
modules={[Autoplay, Pagination, Navigation]}
|
||||
>
|
||||
{props.data.map((slide) =>
|
||||
slide.imageUrl ? (
|
||||
// Slide with image background
|
||||
{props.data.map((slide) => (
|
||||
<SwiperSlide key={slide.id} className="relative overflow-hidden">
|
||||
<img
|
||||
src={slide.imageUrl}
|
||||
alt={slide.title}
|
||||
className="absolute top-0 left-0 z-0 object-cover w-full h-full opacity-80"
|
||||
/>
|
||||
{slide.title && slide.description && (
|
||||
<div
|
||||
className="absolute top-0 left-0 z-10 h-full w-full py-16 px-20"
|
||||
style={{
|
||||
@ -55,61 +52,36 @@ const HeroSwiper = (props: HeroSwiperProps) => {
|
||||
{slide.title}
|
||||
</h1>
|
||||
<div className="mt-4 flex gap-1.5">
|
||||
{slide.tags.map((tag) => (
|
||||
{slide.genres.map((genre) => (
|
||||
<Badge
|
||||
className="bg-neutral-200 text-neutral-800"
|
||||
key={tag}
|
||||
key={genre.slug}
|
||||
>
|
||||
{tag}
|
||||
{genre.name}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-4 font-medium text-base max-w-[40vw] line-clamp-6">
|
||||
{slide.description}
|
||||
{slide.synopsis}
|
||||
</p>
|
||||
{slide.isClickable && (
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={() => router.push(slide.buttonLink)}
|
||||
className="mt-6"
|
||||
onClick={() => router.push(`/media/${slide.slug}`)}
|
||||
className="mt-6 h-12 rounded-xl flex gap-2 px-4 hover:bg-neutral-950 group"
|
||||
>
|
||||
{slide.buttonContent}
|
||||
</Button>
|
||||
)}
|
||||
<div className="bg-neutral-950 p-2 rounded-full group-hover:bg-primary">
|
||||
<Icon
|
||||
icon="solar:play-bold"
|
||||
className="text-primary group-hover:text-neutral-950"
|
||||
/>
|
||||
</div>
|
||||
<span className="font-semibold text-neutral-950 group-hover:text-primary">
|
||||
Watch Now
|
||||
</span>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</SwiperSlide>
|
||||
) : (
|
||||
// Fallback for slides without image
|
||||
<SwiperSlide
|
||||
key={slide.id}
|
||||
className="relative overflow-hidden bg-neutral-800 flex flex-col items-center text-center pt-18"
|
||||
>
|
||||
<h1 className="text-6xl font-semibold tracking-tight">
|
||||
{slide.title}
|
||||
</h1>
|
||||
<div className="mt-4 flex justify-center gap-1.5">
|
||||
{slide.tags.map((tag) => (
|
||||
<Badge className="bg-neutral-200 text-neutral-800" key={tag}>
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
<p className="mt-4 font-medium text-base max-w-[40vw] mx-auto">
|
||||
{slide.description}
|
||||
</p>
|
||||
{slide.isClickable && (
|
||||
<Button
|
||||
size="lg"
|
||||
onClick={() => router.push(slide.buttonLink)}
|
||||
className="mt-6"
|
||||
>
|
||||
{slide.buttonContent}
|
||||
</Button>
|
||||
)}
|
||||
</SwiperSlide>
|
||||
),
|
||||
)}
|
||||
</Swiper>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user