Deploy
This commit is contained in:
@@ -0,0 +1,139 @@
|
||||
'use client'
|
||||
|
||||
import { useEmDashContent } from '@/hooks/useEmDashContent'
|
||||
import Image from 'next/image'
|
||||
import Button from '@/components/ui/Button'
|
||||
import Badge from '@/components/ui/Badge'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
interface Countdown {
|
||||
days: number
|
||||
hours: number
|
||||
minutes: number
|
||||
seconds: number
|
||||
}
|
||||
|
||||
function CountdownTimer({ target }: { target: string }) {
|
||||
const [timeLeft, setTimeLeft] = useState<Countdown>({ days: 0, hours: 0, minutes: 0, seconds: 0 })
|
||||
|
||||
useEffect(() => {
|
||||
const update = () => {
|
||||
const diff = new Date(target).getTime() - Date.now()
|
||||
if (diff <= 0) {
|
||||
setTimeLeft({ days: 0, hours: 0, minutes: 0, seconds: 0 })
|
||||
return
|
||||
}
|
||||
const days = Math.floor(diff / 86400000)
|
||||
const hours = Math.floor((diff % 86400000) / 3600000)
|
||||
const minutes = Math.floor((diff % 3600000) / 60000)
|
||||
const seconds = Math.floor((diff % 60000) / 1000)
|
||||
setTimeLeft({ days, hours, minutes, seconds })
|
||||
}
|
||||
update()
|
||||
const interval = setInterval(update, 1000)
|
||||
return () => clearInterval(interval)
|
||||
}, [target])
|
||||
|
||||
return (
|
||||
<div className="flex gap-3 text-lg font-mono">
|
||||
<div className="flex flex-col items-center bg-[#18181b] text-white px-3 py-1 rounded">
|
||||
<span className="text-2xl font-black">{String(timeLeft.days).padStart(2, '0')}</span>
|
||||
<span className="text-[10px] uppercase tracking-wider">Days</span>
|
||||
</div>
|
||||
<div className="flex flex-col items-center bg-[#18181b] text-white px-3 py-1 rounded">
|
||||
<span className="text-2xl font-black">{String(timeLeft.hours).padStart(2, '0')}</span>
|
||||
<span className="text-[10px] uppercase tracking-wider">Hrs</span>
|
||||
</div>
|
||||
<div className="flex flex-col items-center bg-[#18181b] text-white px-3 py-1 rounded">
|
||||
<span className="text-2xl font-black">{String(timeLeft.minutes).padStart(2, '0')}</span>
|
||||
<span className="text-[10px] uppercase tracking-wider">Min</span>
|
||||
</div>
|
||||
<div className="flex flex-col items-center bg-[#18181b] text-white px-3 py-1 rounded">
|
||||
<span className="text-2xl font-black">{String(timeLeft.seconds).padStart(2, '0')}</span>
|
||||
<span className="text-[10px] uppercase tracking-wider">Sec</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function ExclusiveDropSection() {
|
||||
const { items, loading } = useEmDashContent('specials')
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex justify-center py-16">
|
||||
<div className="w-8 h-8 rounded-full border-2 border-current border-t-transparent animate-spin" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (items.length === 0) return null
|
||||
|
||||
return (
|
||||
<section
|
||||
id="drops"
|
||||
data-vula-section="exclusivedrop"
|
||||
data-vula-cms="specials"
|
||||
className="bg-white py-20"
|
||||
>
|
||||
<div className="container mx-auto px-4">
|
||||
<div className="flex items-center gap-3 mb-8">
|
||||
<h2 className="text-4xl font-black text-[#18181b] uppercase tracking-tight">
|
||||
Exclusive Drops
|
||||
</h2>
|
||||
<Badge className="bg-[#18181b] text-white text-xs px-2 py-0.5">Limited</Badge>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||||
{items.map((item) => {
|
||||
const d = item.data as {
|
||||
title?: string
|
||||
description?: string
|
||||
price?: number
|
||||
available_until?: string
|
||||
image?: string
|
||||
}
|
||||
return (
|
||||
<div
|
||||
key={item.id}
|
||||
className="group bg-neutral-50 border border-neutral-200 rounded-xl overflow-hidden hover:shadow-[var(--shadow-lifted)] hover:-translate-y-0.5 transition-all duration-200 ease-out"
|
||||
>
|
||||
<div className="aspect-square relative overflow-hidden">
|
||||
{d.image && (
|
||||
<Image
|
||||
src={d.image}
|
||||
alt={d.title ?? ''}
|
||||
fill
|
||||
sizes="(max-width: 768px) 100vw, 33vw"
|
||||
className="object-cover transition-transform duration-500 ease-out group-hover:scale-105"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="p-6">
|
||||
{d.title && (
|
||||
<h3 className="text-xl font-black text-[#18181b] mb-1">{d.title}</h3>
|
||||
)}
|
||||
{d.description && (
|
||||
<p className="text-sm text-neutral-600 mb-4">{d.description}</p>
|
||||
)}
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
{d.price && (
|
||||
<span className="text-2xl font-black text-[#18181b]">
|
||||
R{(d.price / 100).toFixed(2)}
|
||||
</span>
|
||||
)}
|
||||
{d.available_until && (
|
||||
<CountdownTimer target={d.available_until} />
|
||||
)}
|
||||
</div>
|
||||
<Button variant="default" className="w-full bg-[#18181b] hover:bg-neutral-800">
|
||||
Shop Drop
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user