This commit is contained in:
Vula Builder
2026-08-03 11:42:11 +00:00
parent e2516f3789
commit 230e5de9ca
@@ -0,0 +1,90 @@
'use client'
import Image from 'next/image'
import { useMemo, useState } from 'react'
import { useVulaContent } from '@/hooks/useVulaContent'
import Badge from '@/components/ui/Badge'
import { Card, CardContent } from '@/components/ui/Card'
interface GalleryData {
title?: string
description?: string
image?: string | null
}
function getCategory(title = '') {
const t = title.toLowerCase()
if (t.includes('braid')) return 'Braids'
if (t.includes("colour") || t.includes("color") || t.includes("balayage") || t.includes("highlight")) return 'Colour'
if (t.includes("nail") || t.includes("mani") || t.includes('pedi')) return 'Nails'
if (t.includes("keratin") || t.includes("treatment")) return 'Treatments'
if (t.includes("cut") || t.includes("trim")) return 'Cuts'
return 'More'
}
export default function SalonGallerySection() {
const { items, loading } = useVulaContent('gallery')
const [activeFilter, setActiveFilter] = useState('All')
const categories = useMemo(() => {
const set = new Set(items.map((item) => getCategory((item.data as GalleryData).title)))
return ['All', ...Array.from(set)]
}, [items])
const filteredItems = useMemo(() => {
if (activeFilter === 'All') return items
return items.filter((item) => getCategory((item.data as GalleryData).title) === activeFilter)
}, [items, activeFilter])
if (loading) return (
<div className="flex justify-center py-16">
<div className="w-8 h-8 rounded-full border-2 border-[#0077BE] border-t-transparent animate-spin" />
</div>
)
if (items.length === 0) return null
return (
<section id="salon-gallery" data-vula-section="salon-gallery" data-vula-cms="gallery" className="py-20 bg-white">
<div className="mx-auto max-w-7xl px-4">
<div className="max-w-2xl mb-10">
<p className="text-sm font-medium text-[#00A8CC] mb-2">From the Fourways studio floor</p>
<h2 className="text-3xl font-bold text-[#1A2B3C]">Recent braids, colour and nail artistry</h2>
<p className="mt-3 text-[#1A2B3C]/70">A quick look at transformations our clients took home this season.</p>
</div>
<div className="flex flex-wrap gap-2 mb-8">
{categories.map((cat) => (
<button
key={cat}
onClick={() => setActiveFilter(cat)}
className={`rounded-full px-4 py-2 text-sm font-medium border transition-all duration-200 ease-out ${activeFilter === cat ? 'bg-[#0077BE] border-[#0077BE] text-white' : 'bg-white border-[#d4dadd] text-[#1A2B3C] hover:border-[#0077BE] hover:text-[#0077BE]'}`}
>
{cat}
</button>
))}
</div>
<div className="grid gap-6 md:grid-cols-2 lg:grid-cols-3">
{filteredItems.map((item) => {
const d = item.data as GalleryData
return (
<Card key={item.id} className="rounded-xl overflow-hidden bg-white shadow-md flex flex-col md:flex-row">
<div className="relative h-48 w-full md:w-1/3 md:min-h-full flex-shrink-0 overflow-hidden">
{d.image ? (
<Image src={d.image} alt={d.title ?? 'Salon result'} fill sizes="(max-width: 768px) 100vw, 33vw" className="object-cover" />
) : (
<div className="h-full w-full bg-[#00A8CC]/20" />
)}
</div>
<CardContent className="flex-1 p-5">
<Badge variant="outline">{getCategory(d.title)}</Badge>
<h3 className="mt-2 font-bold text-[#1A2B3C]">{d.title}</h3>
{d.description && <p className="mt-1 text-sm text-[#1A2B3C]/70">{d.description}</p>}
</CardContent>
</Card>
)
})}
</div>
</div>
</section>
)
}