2024-03-17 17:32:23 -05:00
|
|
|
import React, { useEffect, useState } from 'react';
|
2024-09-09 17:35:00 -05:00
|
|
|
import useWindowWidth from '@/hooks/useWindowWidth';
|
2024-03-17 17:32:23 -05:00
|
|
|
import Image from 'next/image';
|
|
|
|
|
|
|
|
const HeroBanner = () => {
|
|
|
|
const options = ['Bitcoin', 'Lightning', 'Nostr'];
|
|
|
|
const [currentOption, setCurrentOption] = useState(0);
|
2024-03-18 19:32:43 -05:00
|
|
|
const [isFlipping, setIsFlipping] = useState(false);
|
2024-03-17 17:32:23 -05:00
|
|
|
|
2024-09-09 17:35:00 -05:00
|
|
|
const windowWidth = useWindowWidth();
|
|
|
|
|
2024-03-19 17:47:16 -05:00
|
|
|
const getColorClass = (option) => {
|
|
|
|
switch (option) {
|
|
|
|
case 'Bitcoin': return 'text-orange-400';
|
|
|
|
case 'Lightning': return 'text-blue-500';
|
|
|
|
case 'Nostr': return 'text-purple-400';
|
|
|
|
default: return 'text-white';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-03-17 17:32:23 -05:00
|
|
|
useEffect(() => {
|
|
|
|
const interval = setInterval(() => {
|
2024-03-18 19:32:43 -05:00
|
|
|
setIsFlipping(true);
|
2024-03-17 17:32:23 -05:00
|
|
|
setTimeout(() => {
|
|
|
|
setCurrentOption((prevOption) => (prevOption + 1) % options.length);
|
2024-03-18 19:32:43 -05:00
|
|
|
setTimeout(() => {
|
|
|
|
setIsFlipping(false);
|
|
|
|
}, 400); // Start preparing to flip back a bit before the halfway point
|
|
|
|
}, 400); // Update slightly before the midpoint for smoother transition
|
|
|
|
}, 2500); // Increased to provide a slight pause between animations for readability
|
2024-03-19 17:47:16 -05:00
|
|
|
|
2024-03-17 17:32:23 -05:00
|
|
|
return () => clearInterval(interval);
|
2024-03-19 17:47:16 -05:00
|
|
|
}, []);
|
2024-03-17 17:32:23 -05:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="relative flex justify-center items-center">
|
2024-09-09 17:35:00 -05:00
|
|
|
{windowWidth && (
|
|
|
|
<Image
|
|
|
|
src="/images/plebdevs-banner.png"
|
|
|
|
alt="Banner"
|
|
|
|
width={windowWidth <= 1920 ? 1920 : windowWidth}
|
|
|
|
height={1080}
|
|
|
|
quality={100}
|
|
|
|
className='opacity-70'
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
<div className="w-[75vw] sm:w-[65vw] md:w-[45vw] lg:w-[45vw] xl:w-[37vw] absolute text-center text-white text-xl h-full flex flex-col justify-evenly">
|
2024-09-09 15:44:18 -05:00
|
|
|
<p className='text-2xl md:text-4xl lg:text-5xl xl:text-5xl'>Learn how to code</p>
|
|
|
|
<p className='text-2xl md:text-4xl lg:text-5xl xl:text-5xl'>
|
2024-03-17 17:32:23 -05:00
|
|
|
Build{' '}
|
2024-04-22 11:59:20 -05:00
|
|
|
<span className={`inline-block w-[50%] ${isFlipping ? 'flip-enter-active' : ''} ${getColorClass(options[currentOption])}`}>
|
2024-03-17 17:32:23 -05:00
|
|
|
{options[currentOption]}
|
|
|
|
</span>
|
2024-04-22 11:59:20 -05:00
|
|
|
{' '}Apps
|
2024-03-17 17:32:23 -05:00
|
|
|
</p>
|
2024-09-09 15:44:18 -05:00
|
|
|
<p className='text-2xl md:text-4xl lg:text-5xl xl:text-5xl'>Become a developer</p>
|
2024-03-17 17:32:23 -05:00
|
|
|
</div>
|
2024-03-19 17:47:16 -05:00
|
|
|
|
2024-03-17 17:32:23 -05:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default HeroBanner;
|