|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { m } from 'motion/react' |
| 4 | + |
| 5 | +import { cn } from '~/lib/cn' |
| 6 | + |
| 7 | +const floatingOrbs = [ |
| 8 | + { |
| 9 | + size: 360, |
| 10 | + initial: { x: -200, y: -80, opacity: 0.35 }, |
| 11 | + animate: { x: -160, y: -10, opacity: 0.6 }, |
| 12 | + className: 'from-[#6A4DFB]/25 via-transparent to-transparent', |
| 13 | + duration: 18, |
| 14 | + }, |
| 15 | + { |
| 16 | + size: 420, |
| 17 | + initial: { x: 240, y: 120, opacity: 0.2 }, |
| 18 | + animate: { x: 200, y: 60, opacity: 0.45 }, |
| 19 | + className: 'from-[#CBB28B]/35 via-transparent to-transparent', |
| 20 | + duration: 24, |
| 21 | + }, |
| 22 | + { |
| 23 | + size: 280, |
| 24 | + initial: { x: -40, y: 360, opacity: 0.25 }, |
| 25 | + animate: { x: 10, y: 310, opacity: 0.5 }, |
| 26 | + className: 'from-[#2E2A40]/60 via-transparent to-transparent', |
| 27 | + duration: 30, |
| 28 | + }, |
| 29 | +] |
| 30 | + |
| 31 | +const auroraBands = [ |
| 32 | + { |
| 33 | + rotate: '-12deg', |
| 34 | + className: 'from-transparent via-white/5 to-transparent', |
| 35 | + delay: 0, |
| 36 | + }, |
| 37 | + { |
| 38 | + rotate: '18deg', |
| 39 | + className: 'from-transparent via-purple-400/10 to-transparent', |
| 40 | + delay: 4, |
| 41 | + }, |
| 42 | +] |
| 43 | + |
| 44 | +export const NocturneBackground = () => { |
| 45 | + return ( |
| 46 | + <div className="pointer-events-none absolute inset-0 overflow-hidden"> |
| 47 | + <div className="absolute inset-0 bg-[radial-gradient(circle_at_top,rgba(255,255,255,0.08),transparent_55%)]" /> |
| 48 | + <div className="absolute inset-x-0 top-0 h-64 bg-linear-to-b from-black via-black/70 to-transparent" /> |
| 49 | + |
| 50 | + {floatingOrbs.map((orb, index) => ( |
| 51 | + <m.div |
| 52 | + key={index} |
| 53 | + initial={orb.initial} |
| 54 | + animate={orb.animate} |
| 55 | + transition={{ |
| 56 | + duration: orb.duration, |
| 57 | + repeat: Infinity, |
| 58 | + repeatType: 'mirror', |
| 59 | + ease: 'easeInOut', |
| 60 | + }} |
| 61 | + className="absolute blur-[90px]" |
| 62 | + > |
| 63 | + <div |
| 64 | + className={cn('rounded-full bg-linear-to-br', orb.className)} |
| 65 | + style={{ |
| 66 | + width: orb.size, |
| 67 | + height: orb.size, |
| 68 | + }} |
| 69 | + /> |
| 70 | + </m.div> |
| 71 | + ))} |
| 72 | + |
| 73 | + {auroraBands.map((band) => ( |
| 74 | + <m.div |
| 75 | + key={band.rotate} |
| 76 | + initial={{ opacity: 0 }} |
| 77 | + animate={{ opacity: [0.1, 0.4, 0.1], x: [-20, 20, -20] }} |
| 78 | + transition={{ |
| 79 | + duration: 20, |
| 80 | + repeat: Infinity, |
| 81 | + delay: band.delay, |
| 82 | + ease: 'easeInOut', |
| 83 | + }} |
| 84 | + className="absolute inset-x-[-20%] top-1/4 h-56" |
| 85 | + style={{ rotate: band.rotate }} |
| 86 | + > |
| 87 | + <div |
| 88 | + className={cn( |
| 89 | + 'h-full w-full rounded-[60px] bg-linear-to-r blur-[60px]', |
| 90 | + band.className, |
| 91 | + )} |
| 92 | + /> |
| 93 | + </m.div> |
| 94 | + ))} |
| 95 | + |
| 96 | + <div className="absolute inset-0 opacity-40"> |
| 97 | + {Array.from({ length: 20 }).map((_, idx) => ( |
| 98 | + <m.div |
| 99 | + key={idx} |
| 100 | + className="absolute h-px w-32 bg-linear-to-r from-white/10 via-white/50 to-transparent" |
| 101 | + style={{ |
| 102 | + top: `${(idx * 13) % 100}%`, |
| 103 | + left: `${(idx * 27) % 100}%`, |
| 104 | + }} |
| 105 | + initial={{ opacity: 0.2 }} |
| 106 | + animate={{ opacity: [0.1, 0.4, 0.15], x: [0, 20, 0] }} |
| 107 | + transition={{ |
| 108 | + duration: 12 + idx * 0.3, |
| 109 | + repeat: Infinity, |
| 110 | + repeatType: 'mirror', |
| 111 | + ease: 'easeInOut', |
| 112 | + }} |
| 113 | + /> |
| 114 | + ))} |
| 115 | + </div> |
| 116 | + </div> |
| 117 | + ) |
| 118 | +} |
0 commit comments