fix:banner

This commit is contained in:
Rama Priyanto 2025-02-05 16:42:48 +07:00
parent eb1bd6903f
commit 18d3603734
5 changed files with 62 additions and 7 deletions

View File

@ -1,21 +1,76 @@
"use client";
import { useTranslations } from "next-intl"; import { useTranslations } from "next-intl";
import React from "react"; import Image from "next/image";
import React, { useEffect, useState } from "react";
import { ChevronLeftIcon, ChevronRightIcon } from "../icons";
const images = [
"/landing-1.jpg",
"/landing-2.jpg",
"/landing-3.jpg",
"/landing-4.jpg",
];
export default function BannerHumas() { export default function BannerHumas() {
const t = useTranslations("Banner"); const t = useTranslations("Banner");
const [currentIndex, setCurrentIndex] = useState(0);
const [resetTimer, setResetTimer] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % images.length);
}, 25000);
return () => clearInterval(interval);
}, [resetTimer]);
const nextImage = () => {
setCurrentIndex((prevIndex) => (prevIndex + 1) % images.length);
setResetTimer((prev) => prev + 1);
};
const prevImage = () => {
setCurrentIndex(
(prevIndex) => (prevIndex - 1 + images.length) % images.length
);
setResetTimer((prev) => prev + 1);
};
return ( return (
<div className="h-fit relative text-white lg:mt-[-130px]"> <div className="h-fit relative text-gray-300 dark:text-white lg:mt-[-130px] overflow-hidden">
<img <div
src="headerbanner1.png" className="flex w-full h-[78vh] lg:h-[95vh] transition-transform duration-700 ease-in-out"
alt="humasbanner" style={{ transform: `translateX(-${currentIndex * 100}%)` }}
className="w-full relative h-[78vh] lg:h-[95vh] object-cover" >
/> {images.map((img, index) => (
<div key={index} className="w-full shrink-0">
<Image
src={img}
width={1440}
height={1080}
alt={`humasbanner-${index}`}
className="w-full h-full object-cover opacity-[100] dark:opacity-70"
/>
</div>
))}
</div>
<div className="absolute lg:mt-[50px] top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center w-full lg:w-[75%]"> <div className="absolute lg:mt-[50px] top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center w-full lg:w-[75%]">
<p className="text-[30px] lg:text-[42px] lg:leading-10 font-bold pb-1 md:pb-5"> <p className="text-[30px] lg:text-[42px] lg:leading-10 font-bold pb-1 md:pb-5">
{t("jumbotron")} {t("jumbotron")}
</p> </p>
<p className="text-xs md:text-medium">{`"${t("phrase")}"`}</p> <p className="text-xs md:text-medium">{`"${t("phrase")}"`}</p>
</div> </div>
<button
onClick={prevImage}
className="absolute left-4 top-1/2 transform -translate-y-1/2 bg-black/50 text-white px-2 py-2 rounded-full hover:bg-black/70 transition"
>
<ChevronLeftIcon />
</button>
<button
onClick={nextImage}
className="absolute right-4 top-1/2 transform -translate-y-1/2 bg-black/50 text-white px-2 py-2 rounded-full hover:bg-black/70 transition"
>
<ChevronRightIcon />
</button>
</div> </div>
); );
} }

BIN
public/landing-1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 MiB

BIN
public/landing-2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 MiB

BIN
public/landing-3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 MiB

BIN
public/landing-4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 MiB