PratikWebsite / components /Varieties /VarietiesSection.tsx
Keep-Triangle's picture
Upload 35 files
5d33320 verified
Raw History Blame Contribute Delete
11 kB
import React, { useState, useRef } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { SPICE_VARIANTS } from '../../data/mockData';
import { SpiceData } from '../../types';
import { MapPin, ArrowDown } from 'lucide-react';
import { useSectionAudio } from '../../hooks/useSectionAudio';
import { SOUNDS } from '../../context/AudioContext';
const HeatMeter: React.FC<{ index: number; color: string }> = ({ index, color }) => {
return (
<div className="flex flex-col gap-1 w-full">
<div className="flex justify-between text-[10px] uppercase tracking-wider text-gray-400 font-medium mb-1">
<span>Intensity</span>
<span>{index}/10</span>
</div>
<div className="h-1.5 w-full bg-white/10 rounded-full overflow-hidden">
<motion.div
className="h-full rounded-full relative"
style={{ backgroundColor: color, width: `${index * 10}%` }}
initial={{ width: 0 }}
whileInView={{ width: `${index * 10}%` }}
transition={{ duration: 1.5, ease: "circOut" }}
>
<motion.div
className="absolute inset-0 bg-white/30"
animate={{ x: ['-100%', '100%'] }}
transition={{ repeat: Infinity, duration: 2.2, ease: "linear" }}
/>
</motion.div>
</div>
</div>
);
};
const VarietiesSection: React.FC = () => {
const [visibleCount, setVisibleCount] = useState(3);
const containerRef = useRef<HTMLElement>(null);
// Audio Trigger: Play subtle crunch/texture sound for varieties
useSectionAudio(containerRef, SOUNDS.CRUNCH);
const handleLoadMore = () => {
setVisibleCount(prev => Math.min(prev + 3, SPICE_VARIANTS.length));
};
const isAllVisible = visibleCount >= SPICE_VARIANTS.length;
return (
<section id="varieties" ref={containerRef} className="relative py-28 md:py-32 bg-transparent overflow-hidden">
<div className="relative z-10 max-w-7xl mx-auto px-6 md:px-12">
{/* Section Header */}
<div className="flex flex-col md:flex-row md:items-end justify-between mb-20 gap-8">
<div>
<motion.h2
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true }}
className="font-serif text-4xl md:text-6xl text-white mb-4"
>
The Collection
</motion.h2>
<motion.p
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{ delay: 0.1 }}
viewport={{ once: true }}
className="font-sans text-gray-400 text-lg max-w-md"
>
Curated varieties for specific industrial and culinary applications. Precision-graded for heat and color.
</motion.p>
</div>
</div>
{/* Cards Grid - 3 Column Layout */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<AnimatePresence mode="popLayout">
{SPICE_VARIANTS.slice(0, visibleCount).map((spice: SpiceData, i) => (
<motion.div
key={spice.id}
layout
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, scale: 0.95 }}
transition={{ duration: 0.6, delay: (i % 3) * 0.1, ease: "easeOut" }}
viewport={{ once: true }}
className="group relative"
>
{/* Floating Card Container - No Bouncing */}
<motion.div
className="relative h-full bg-[#0e0303] border border-white/10 rounded-2xl overflow-hidden transition-[transform,box-shadow,background-color,border-color] duration-300 shadow-[0_18px_55px_-38px_rgba(0,0,0,0.9)] flex flex-col transform-gpu focus-within:ring-2 focus-within:ring-brand-gold/30 hover:-translate-y-1 hover:bg-[#120404] hover:border-white/15 hover:shadow-[0_26px_70px_-45px_rgba(0,0,0,0.95)]"
>
{/* Image Half */}
<div className="h-56 overflow-hidden relative flex-shrink-0">
<div className="absolute inset-0 bg-gradient-to-t from-[#1a0505] to-transparent z-10 opacity-60" />
<motion.img
src={spice.image}
alt={spice.name}
className="w-full h-full object-cover transform-gpu"
whileHover={{ scale: 1.05 }}
transition={{ duration: 0.7 }}
/>
{/* Floating Tag */}
<div className="absolute top-6 right-6 z-20 px-3 py-1 bg-black/70 rounded-full border border-white/10 text-xs font-medium text-white/80">
Premium Grade
</div>
</div>
{/* Content Half */}
<div className="p-8 flex flex-col flex-grow">
<div className="flex justify-between items-start mb-6">
<div>
<h3 className="font-serif text-2xl text-white mb-1 group-hover:text-brand-gold transition-colors duration-300">
{spice.name}
</h3>
<div className="flex items-center gap-2 text-gray-500 text-xs uppercase tracking-wide">
<MapPin className="w-3 h-3" /> {spice.origin}
</div>
</div>
{/* Color Swatch */}
<div className="flex flex-col items-center gap-1">
<div
className="w-6 h-6 rounded-full border border-white/20 shadow-lg"
style={{ backgroundColor: spice.color }}
/>
</div>
</div>
<div className="space-y-6 mt-auto">
<p className="text-gray-400 text-sm leading-relaxed border-l-2 border-white/10 pl-4 min-h-[60px]">
{spice.description}
</p>
{/* Specs Grid */}
<div className="grid grid-cols-2 gap-4 py-4 border-t border-white/5 border-b">
<div>
<span className="block text-[10px] text-gray-500 uppercase tracking-wider mb-1">Scoville (SHU)</span>
<span className="font-mono text-white text-xs md:text-sm">{spice.scoville}</span>
</div>
<div>
<span className="block text-[10px] text-gray-500 uppercase tracking-wider mb-1">Color Value</span>
<span className="font-mono text-white text-xs md:text-sm">High Retention</span>
</div>
</div>
{/* Interactive Heat Meter */}
<div className="pt-2">
<HeatMeter index={spice.heatIndex} color={spice.color} />
</div>
</div>
</div>
</motion.div>
</motion.div>
))}
</AnimatePresence>
</div>
{/* Load More Button - Bottom Center */}
{!isAllVisible && (
<motion.div
initial={{ opacity: 0 }}
whileInView={{ opacity: 1 }}
className="mt-16 flex justify-center"
>
<button
onClick={handleLoadMore}
className="group relative px-8 py-4 overflow-hidden bg-[#0e0303] border border-white/10 rounded-full hover:bg-[#120404] hover:border-white/15 transition-[transform,box-shadow,background-color,border-color] duration-300 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-gold/40 shadow-[0_18px_55px_-42px_rgba(0,0,0,0.9)] hover:shadow-[0_26px_70px_-48px_rgba(0,0,0,0.95)] transform-gpu"
>
<span className="relative z-10 font-sans text-brand-gold text-sm tracking-[0.2em] uppercase font-semibold flex items-center gap-3">
View Full Inventory
<ArrowDown className="w-4 h-4 group-hover:translate-y-1 transition-transform duration-300" />
</span>
</button>
</motion.div>
)}
</div>
</section>
);
};
export default VarietiesSection;