2025-01-02 12:47:39 +00:00
|
|
|
'use client';
|
|
|
|
|
import Image from 'next/image';
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import SlotCounter from 'react-slot-counter';
|
|
|
|
|
import { useMediaQuery } from 'usehooks-ts';
|
2024-12-25 13:46:20 +00:00
|
|
|
|
2024-12-27 15:23:39 +00:00
|
|
|
interface LotterySlotCounterProps {
|
|
|
|
|
numberString: string;
|
|
|
|
|
isAnimating: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-02 12:47:39 +00:00
|
|
|
const LotterySlotCounter = ({ numberString, isAnimating }: LotterySlotCounterProps) => {
|
2024-12-25 13:46:20 +00:00
|
|
|
const [formattedNumber, setFormattedNumber] = useState(numberString);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-01-02 12:47:39 +00:00
|
|
|
const formatted = numberString.replace(/-/g, ',');
|
2024-12-25 13:46:20 +00:00
|
|
|
setFormattedNumber(formatted);
|
|
|
|
|
}, [numberString]);
|
|
|
|
|
|
2025-01-02 12:47:39 +00:00
|
|
|
const tablet = useMediaQuery('(max-width: 769px)');
|
|
|
|
|
const mobile = useMediaQuery('(max-width: 426px)');
|
2024-12-29 18:02:23 +00:00
|
|
|
|
2024-12-25 13:46:20 +00:00
|
|
|
return (
|
|
|
|
|
<div className="relative w-fit">
|
2024-12-29 18:02:23 +00:00
|
|
|
{mobile ? (
|
|
|
|
|
<Image
|
|
|
|
|
src="/roller-triangle-sm.svg"
|
|
|
|
|
alt="roller-triangle"
|
|
|
|
|
width={24}
|
|
|
|
|
height={24}
|
|
|
|
|
className="absolute left-0 top-1/2 -translate-y-1/2 -translate-x-1/2 z-20"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<Image
|
|
|
|
|
src="/roller-triangle.svg"
|
|
|
|
|
alt="roller-triangle"
|
|
|
|
|
width={48}
|
|
|
|
|
height={48}
|
|
|
|
|
className="absolute left-0 top-1/2 -translate-y-1/2 -translate-x-1/2 z-20"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{mobile ? (
|
|
|
|
|
<Image
|
|
|
|
|
src="/roller-triangle-sm.svg"
|
|
|
|
|
alt="roller-triangle"
|
|
|
|
|
width={24}
|
|
|
|
|
height={24}
|
|
|
|
|
className="absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-20 rotate-180"
|
|
|
|
|
/>
|
|
|
|
|
) : (
|
|
|
|
|
<Image
|
|
|
|
|
src="/roller-triangle.svg"
|
|
|
|
|
alt="roller-triangle"
|
|
|
|
|
width={48}
|
|
|
|
|
height={48}
|
|
|
|
|
className="absolute right-0 top-1/2 -translate-y-1/2 translate-x-1/2 z-20 rotate-180"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2024-12-25 13:46:20 +00:00
|
|
|
<div
|
2024-12-30 09:02:49 +00:00
|
|
|
className="flex items-center h-fit md:max-w-[1132px] sm:max-w-[640px] max-w-[324px] w-full justify-center text-white md:py-4 md:px-6 rounded-full overflow-y-hidden overflow-x-visible relative border-4 border-lightPrimary"
|
2024-12-25 13:46:20 +00:00
|
|
|
style={{
|
|
|
|
|
background:
|
2025-01-02 12:47:39 +00:00
|
|
|
'linear-gradient(180deg, #454673 0%, #575992 10.5%, #575992 90%, #454673 100%)',
|
|
|
|
|
boxShadow: '0px 4px 4px 0px #00000040',
|
|
|
|
|
}}>
|
2024-12-25 13:46:20 +00:00
|
|
|
{/* Highlight */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute top-[50%] -translate-y-1/2 left-0 w-full h-full"
|
|
|
|
|
style={{
|
|
|
|
|
background:
|
2025-01-02 12:47:39 +00:00
|
|
|
'linear-gradient(180deg, rgba(87, 89, 146, 0) 0%, #7274AB 50%, rgba(87, 89, 146, 0) 100%)',
|
|
|
|
|
}}></div>
|
2024-12-25 13:46:20 +00:00
|
|
|
|
|
|
|
|
<div className="z-10">
|
|
|
|
|
<SlotCounter
|
|
|
|
|
value={formattedNumber}
|
2025-01-02 12:47:39 +00:00
|
|
|
startValue={formattedNumber}
|
2024-12-25 13:46:20 +00:00
|
|
|
charClassName="rolling-number"
|
|
|
|
|
separatorClassName="slot-seperator"
|
|
|
|
|
duration={2}
|
|
|
|
|
speed={2}
|
|
|
|
|
startFromLastDigit
|
|
|
|
|
delay={2}
|
2025-01-02 12:47:39 +00:00
|
|
|
animateUnchanged={false}
|
|
|
|
|
autoAnimationStart={false}
|
2024-12-25 13:46:20 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default LotterySlotCounter;
|