|
| 1 | +import React, { useEffect, useState } from 'react'; |
| 2 | +import { motion } from 'framer-motion'; |
| 3 | + |
| 4 | +const FLOWER_TYPES = [ |
| 5 | + // Type 1: Simple Daisy-like |
| 6 | + (color) => ( |
| 7 | + <svg viewBox="0 0 100 100" width="100%" height="100%" className="overflow-visible"> |
| 8 | + <path d="M50 50 Q50 20 50 10 Q50 20 60 40 Z" fill={color} /> |
| 9 | + <path d="M50 50 Q80 50 90 50 Q80 50 60 60 Z" fill={color} /> |
| 10 | + <path d="M50 50 Q50 80 50 90 Q50 80 40 60 Z" fill={color} /> |
| 11 | + <path d="M50 50 Q20 50 10 50 Q20 50 40 40 Z" fill={color} /> |
| 12 | + <path d="M50 50 Q30 30 20 20 Q30 30 45 45 Z" fill={color} /> |
| 13 | + <path d="M50 50 Q70 30 80 20 Q70 30 55 45 Z" fill={color} /> |
| 14 | + <path d="M50 50 Q70 70 80 80 Q70 70 55 55 Z" fill={color} /> |
| 15 | + <path d="M50 50 Q30 70 20 80 Q30 70 45 55 Z" fill={color} /> |
| 16 | + <circle cx="50" cy="50" r="10" fill="#fbbf24" /> |
| 17 | + </svg> |
| 18 | + ), |
| 19 | + // Type 2: Tulip-like |
| 20 | + (color) => ( |
| 21 | + <svg viewBox="0 0 100 100" width="100%" height="100%" className="overflow-visible"> |
| 22 | + <path d="M30 40 Q30 80 50 90 Q70 80 70 40 Q50 50 30 40 Z" fill={color} /> |
| 23 | + <path d="M30 40 Q40 20 50 40 Q60 20 70 40" fill={color} /> |
| 24 | + <path d="M50 90 L50 150" stroke="#166534" strokeWidth="4" /> |
| 25 | + </svg> |
| 26 | + ), |
| 27 | + // Type 3: Round |
| 28 | + (color) => ( |
| 29 | + <svg viewBox="0 0 100 100" width="100%" height="100%" className="overflow-visible"> |
| 30 | + <circle cx="50" cy="50" r="30" fill={color} opacity="0.8" /> |
| 31 | + <circle cx="50" cy="50" r="20" fill="#fff" opacity="0.3" /> |
| 32 | + <path d="M50 80 L50 150" stroke="#166534" strokeWidth="4" /> |
| 33 | + </svg> |
| 34 | + ) |
| 35 | +]; |
| 36 | + |
| 37 | +const COLORS = ['#f472b6', '#c084fc', '#60a5fa', '#f87171', '#fbbf24']; |
| 38 | + |
| 39 | +const DigitalFlowers = () => { |
| 40 | + const [flowers, setFlowers] = useState([]); |
| 41 | + |
| 42 | + useEffect(() => { |
| 43 | + // Generate random flowers |
| 44 | + const newFlowers = Array.from({ length: 40 }).map((_, i) => ({ |
| 45 | + id: i, |
| 46 | + left: Math.random() * 100, // percentage |
| 47 | + size: 60 + Math.random() * 80, // px (Increased size from 40-100 to 60-140) |
| 48 | + delay: Math.random() * 2, // seconds |
| 49 | + type: Math.floor(Math.random() * FLOWER_TYPES.length), |
| 50 | + color: COLORS[Math.floor(Math.random() * COLORS.length)], |
| 51 | + rotation: Math.random() * 30 - 15, // degrees |
| 52 | + })); |
| 53 | + setFlowers(newFlowers); |
| 54 | + }, []); |
| 55 | + |
| 56 | + return ( |
| 57 | + <div className="fixed bottom-0 left-0 w-full h-0 z-50 pointer-events-none"> |
| 58 | + {flowers.map((flower) => ( |
| 59 | + <motion.div |
| 60 | + key={flower.id} |
| 61 | + initial={{ y: 200, opacity: 0, rotate: flower.rotation }} |
| 62 | + animate={{ |
| 63 | + y: 0, |
| 64 | + opacity: 1, |
| 65 | + rotate: [flower.rotation - 5, flower.rotation + 5, flower.rotation - 5] |
| 66 | + }} |
| 67 | + transition={{ |
| 68 | + y: { duration: 1.5, delay: flower.delay, type: 'spring', stiffness: 50 }, |
| 69 | + opacity: { duration: 1.5, delay: flower.delay }, |
| 70 | + rotate: { |
| 71 | + duration: 3 + Math.random() * 2, |
| 72 | + repeat: Infinity, |
| 73 | + ease: "easeInOut", |
| 74 | + delay: flower.delay + 0.5 |
| 75 | + } |
| 76 | + }} |
| 77 | + style={{ |
| 78 | + position: 'absolute', |
| 79 | + left: `${flower.left}%`, |
| 80 | + bottom: -20, |
| 81 | + width: flower.size, |
| 82 | + height: flower.size * 1.5, // Make them taller |
| 83 | + transformOrigin: 'bottom center', |
| 84 | + }} |
| 85 | + > |
| 86 | + {FLOWER_TYPES[flower.type](flower.color)} |
| 87 | + </motion.div> |
| 88 | + ))} |
| 89 | + </div> |
| 90 | + ); |
| 91 | +}; |
| 92 | + |
| 93 | +export default DigitalFlowers; |
0 commit comments