|
2 | 2 |
|
3 | 3 | import { motion } from 'framer-motion'; |
4 | 4 | import Link from 'next/link'; |
5 | | -import { Cpu, HardDrive, Cpu as Gpu, MemoryStick, Box, Zap, Fan, Monitor } from 'lucide-react'; |
| 5 | +import { |
| 6 | + Cpu, |
| 7 | + HardDrive, |
| 8 | + Cpu as Gpu, |
| 9 | + MemoryStick, |
| 10 | + Box, |
| 11 | + Zap, |
| 12 | + Fan, |
| 13 | + Monitor, |
| 14 | + ChevronLeft, |
| 15 | + ChevronRight |
| 16 | +} from 'lucide-react'; |
| 17 | +import { useRef } from 'react'; |
6 | 18 |
|
7 | 19 | export default function CategoriesSection() { |
| 20 | + const scrollContainerRef = useRef<HTMLDivElement>(null); |
| 21 | + |
8 | 22 | const categories = [ |
9 | | - { name: 'CPUs', icon: Cpu, href: '/components/cpu' }, |
10 | | - { name: 'GPUs', icon: Gpu, href: '/components/gpu' }, |
11 | | - { name: 'Motherboards', icon: Monitor, href: '/components/motherboard' }, |
12 | | - { name: 'RAM', icon: MemoryStick, href: '/components/ram' }, |
13 | | - { name: 'Storage', icon: HardDrive, href: '/components/storage' }, |
14 | | - { name: 'Power Supply', icon: Zap, href: '/components/psu' }, |
15 | | - { name: 'Cooling', icon: Fan, href: '/components/cooler' }, |
16 | | - { name: 'Cases', icon: Box, href: '/components/case' }, |
| 23 | + { |
| 24 | + name: 'CPUs', |
| 25 | + description: 'The brain of your computer. Handle complex tasks with ease.', |
| 26 | + icon: Cpu, |
| 27 | + href: '/components/cpu' |
| 28 | + }, |
| 29 | + { |
| 30 | + name: 'GPUs', |
| 31 | + description: 'Immersive graphics for gaming and professional rendering.', |
| 32 | + icon: Gpu, |
| 33 | + href: '/components/gpu' |
| 34 | + }, |
| 35 | + { |
| 36 | + name: 'Motherboards', |
| 37 | + description: 'The foundation connecting all your components together.', |
| 38 | + icon: Monitor, |
| 39 | + href: '/components/motherboard' |
| 40 | + }, |
| 41 | + { |
| 42 | + name: 'RAM', |
| 43 | + description: 'High-speed memory for seamless multitasking.', |
| 44 | + icon: MemoryStick, |
| 45 | + href: '/components/ram' |
| 46 | + }, |
| 47 | + { |
| 48 | + name: 'Storage', |
| 49 | + description: 'Secure and fast storage for all your data needs.', |
| 50 | + icon: HardDrive, |
| 51 | + href: '/components/storage' |
| 52 | + }, |
| 53 | + { |
| 54 | + name: 'Power Supply', |
| 55 | + description: 'Reliable power delivery for stable system performance.', |
| 56 | + icon: Zap, |
| 57 | + href: '/components/psu' |
| 58 | + }, |
| 59 | + { |
| 60 | + name: 'Cooling', |
| 61 | + description: 'Keep your temperatures low and performance high.', |
| 62 | + icon: Fan, |
| 63 | + href: '/components/cooler' |
| 64 | + }, |
| 65 | + { |
| 66 | + name: 'Cases', |
| 67 | + description: 'Stylish protection for your high-performance build.', |
| 68 | + icon: Box, |
| 69 | + href: '/components/case' |
| 70 | + }, |
17 | 71 | ]; |
18 | 72 |
|
| 73 | + const scroll = (direction: 'left' | 'right') => { |
| 74 | + if (scrollContainerRef.current) { |
| 75 | + const scrollAmount = 400; |
| 76 | + scrollContainerRef.current.scrollBy({ |
| 77 | + left: direction === 'right' ? scrollAmount : -scrollAmount, |
| 78 | + behavior: 'smooth' |
| 79 | + }); |
| 80 | + } |
| 81 | + }; |
| 82 | + |
19 | 83 | return ( |
20 | | - <section className="py-12 sm:py-16 md:py-20 bg-background"> |
| 84 | + <section className="py-12 sm:py-16 md:py-20 bg-background relative overflow-hidden"> |
21 | 85 | <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> |
22 | | - <motion.div |
23 | | - initial={{ opacity: 0, y: 20 }} |
24 | | - whileInView={{ opacity: 1, y: 0 }} |
25 | | - viewport={{ once: true }} |
26 | | - transition={{ duration: 0.6 }} |
27 | | - className="text-center mb-8 sm:mb-10 md:mb-12" |
28 | | - > |
29 | | - <h2 className="text-2xl sm:text-3xl md:text-4xl font-heading font-bold text-foreground mb-3 sm:mb-4"> |
30 | | - Shop by Category |
31 | | - </h2> |
32 | | - <p className="text-base sm:text-lg text-muted-foreground"> |
33 | | - Find the perfect components for your build |
34 | | - </p> |
35 | | - </motion.div> |
| 86 | + <div className="flex justify-between items-end mb-8 sm:mb-10 md:mb-12"> |
| 87 | + <motion.div |
| 88 | + initial={{ opacity: 0, x: -20 }} |
| 89 | + whileInView={{ opacity: 1, x: 0 }} |
| 90 | + viewport={{ once: true }} |
| 91 | + transition={{ duration: 0.6 }} |
| 92 | + className="max-w-2xl" |
| 93 | + > |
| 94 | + <h2 className="text-2xl sm:text-3xl md:text-4xl font-heading font-bold text-foreground mb-3 sm:mb-4"> |
| 95 | + Shop by Category |
| 96 | + </h2> |
| 97 | + <p className="text-base sm:text-lg text-muted-foreground"> |
| 98 | + Find the perfect components for your build |
| 99 | + </p> |
| 100 | + </motion.div> |
36 | 101 |
|
37 | | - <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-4 sm:gap-6"> |
| 102 | + <div className="hidden sm:flex items-center gap-2"> |
| 103 | + <button |
| 104 | + onClick={() => scroll('left')} |
| 105 | + className="p-2 rounded-full border border-border bg-background hover:bg-muted transition-colors" |
| 106 | + aria-label="Scroll left" |
| 107 | + > |
| 108 | + <ChevronLeft className="h-6 w-6" /> |
| 109 | + </button> |
| 110 | + <button |
| 111 | + onClick={() => scroll('right')} |
| 112 | + className="p-2 rounded-full border border-border bg-background hover:bg-muted transition-colors" |
| 113 | + aria-label="Scroll right" |
| 114 | + > |
| 115 | + <ChevronRight className="h-6 w-6" /> |
| 116 | + </button> |
| 117 | + </div> |
| 118 | + </div> |
| 119 | + |
| 120 | + <div |
| 121 | + ref={scrollContainerRef} |
| 122 | + className="flex overflow-x-auto gap-4 sm:gap-6 pb-4 -mx-4 px-4 sm:mx-0 sm:px-0 scrollbar-hide snap-x" |
| 123 | + style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' }} |
| 124 | + > |
38 | 125 | {categories.map((category, index) => ( |
39 | 126 | <motion.div |
40 | 127 | key={category.name} |
41 | 128 | initial={{ opacity: 0, y: 20 }} |
42 | 129 | whileInView={{ opacity: 1, y: 0 }} |
43 | 130 | viewport={{ once: true }} |
44 | 131 | transition={{ delay: index * 0.05, duration: 0.4 }} |
| 132 | + className="min-w-[280px] sm:min-w-[350px] md:min-w-[400px] snap-start" |
45 | 133 | > |
46 | | - <Link href={category.href}> |
| 134 | + <Link href={category.href} className="block h-full"> |
47 | 135 | <motion.div |
48 | 136 | whileHover={{ y: -5 }} |
49 | 137 | whileTap={{ scale: 0.98 }} |
50 | | - className="group relative flex flex-col items-center justify-center p-6 rounded-2xl bg-gradient-to-br from-card to-secondary/5 border border-primary/10 shadow-sm hover:shadow-lg hover:border-primary/50 transition-all duration-300 h-full min-h-[160px]" |
| 138 | + className="group relative h-full flex items-center justify-between p-6 sm:p-8 rounded-2xl bg-gradient-to-br from-secondary/30 to-background border border-border hover:border-primary/50 hover:from-secondary/50 hover:to-background transition-all duration-300 overflow-hidden" |
51 | 139 | > |
52 | | - <div className="mb-4 text-primary group-hover:scale-110 transition-transform duration-300 bg-primary/10 p-4 rounded-xl"> |
53 | | - <category.icon className="h-8 w-8" strokeWidth={1.5} /> |
| 140 | + <div className="absolute -right-4 -bottom-4 text-primary/5 rotate-12 transform group-hover:scale-110 group-hover:text-primary/10 transition-all duration-500"> |
| 141 | + <category.icon className="w-32 h-32" strokeWidth={1} /> |
| 142 | + </div> |
| 143 | + |
| 144 | + <div className="relative z-10 flex-1 pr-4"> |
| 145 | + <h3 className="text-lg sm:text-xl font-bold text-foreground mb-2 group-hover:text-primary transition-colors"> |
| 146 | + {category.name} |
| 147 | + </h3> |
| 148 | + <p className="text-sm sm:text-base text-muted-foreground line-clamp-2"> |
| 149 | + {category.description} |
| 150 | + </p> |
| 151 | + </div> |
| 152 | + <div className="relative z-10 flex-shrink-0 w-16 h-16 sm:w-20 sm:h-20 flex items-center justify-center rounded-xl bg-background/80 backdrop-blur-sm shadow-sm group-hover:scale-105 transition-transform duration-300 border border-primary/10"> |
| 153 | + <category.icon className="h-8 w-8 sm:h-10 sm:w-10 text-primary" strokeWidth={1.5} /> |
54 | 154 | </div> |
55 | | - <h3 className="text-base sm:text-lg font-semibold text-foreground group-hover:text-primary transition-colors"> |
56 | | - {category.name} |
57 | | - </h3> |
58 | 155 | </motion.div> |
59 | 156 | </Link> |
60 | 157 | </motion.div> |
|
0 commit comments