11"use client" ;
22import { cn } from "@/lib/utils" ;
3- import React , { ReactNode } from "react" ;
3+ import React , { ReactNode , useEffect , useState } from "react" ;
4+ import { isLowEndDevice } from "@/utils/performance" ;
45
5- interface AuroraBackgroundProps extends React . HTMLProps < HTMLDivElement > {
6+ interface EfficientBackgroundProps extends React . HTMLProps < HTMLDivElement > {
67 children : ReactNode ;
78}
89
9- export const AuroraBackground = ( {
10+ export const EfficientBackground = ( {
1011 className,
1112 children,
1213 ...props
13- } : AuroraBackgroundProps ) => {
14+ } : EfficientBackgroundProps ) => {
15+ const [ shouldAnimate , setShouldAnimate ] = useState ( true ) ;
16+
17+ useEffect ( ( ) => {
18+ // Check if device has limited resources and disable animations if needed
19+ const isLowEnd = isLowEndDevice ( ) ;
20+ setShouldAnimate ( ! isLowEnd ) ;
21+ } , [ ] ) ;
22+
1423 return (
1524 < main className = "min-h-screen w-full" >
1625 < div
@@ -20,32 +29,35 @@ export const AuroraBackground = ({
2029 ) }
2130 { ...props }
2231 >
23- { /* Background container */ }
32+ { /* Efficient background container */ }
2433 < div className = "absolute inset-0 overflow-hidden" >
25- { /* Primary aurora */ }
26- < div className = "absolute - inset-[10px] opacity-50 " >
34+ { /* Primary gradient layer - no blur for better performance */ }
35+ < div className = "absolute inset-0 opacity-30 " >
2736 < div
28- className = "absolute inset-0 bg-gradient-to-r from-[#3B82F6] via-[#8B5CF6] to-[#EC4899]
29- animate-aurora blur-[100px]
30- after:absolute after:inset-0
31- after:bg-gradient-to-t after:from-[#3B82F6] after:via-transparent after:to-transparent
32- after:animate-aurora after:blur-[120px]"
37+ className = { cn (
38+ "absolute inset-0 bg-gradient-to-br from-blue-400/20 via-purple-500/15 to-pink-400/20" ,
39+ shouldAnimate && "animate-efficient-gradient"
40+ ) }
3341 />
3442 </ div >
3543
36- { /* Secondary aurora */ }
37- { /* <div className="absolute - inset-[10px] opacity-30 ">
44+ { /* Secondary gradient layer */ }
45+ < div className = "absolute inset-0 opacity-20 " >
3846 < div
39- className="absolute inset-0 bg-gradient-to-l from-violet-500 via-indigo-500 to-blue-500
40- animate-aurora blur-[90px]
41- after:absolute after:inset-0
42- after:bg-gradient-to-b after:from-violet-500 after:via-transparent after:to-transparent
43- after:animate-aurora after:blur-[100px]"
47+ className = { cn (
48+ "absolute inset-0 bg-gradient-to-tl from-indigo-400/15 via-violet-400/10 to-blue-500/15" ,
49+ shouldAnimate && "animate-efficient-gradient-reverse"
50+ ) }
4451 />
45- </div> */ }
52+ </ div >
53+
54+ { /* Subtle mesh pattern for texture */ }
55+ < div className = "absolute inset-0 opacity-[0.02] dark:opacity-[0.05]" >
56+ < div className = "absolute inset-0 bg-[radial-gradient(circle_at_1px_1px,rgba(0,0,0,0.15)_1px,transparent_0)] bg-[length:20px_20px]" />
57+ </ div >
4658
4759 { /* Overlay gradient */ }
48- < div className = "absolute inset-0 bg-gradient-to-t from-white via-white/80 to-transparent dark:from-zinc-900 dark:via-zinc-900/80 " />
60+ < div className = "absolute inset-0 bg-gradient-to-t from-white via-white/90 to-transparent dark:from-zinc-900 dark:via-zinc-900/90 " />
4961 </ div >
5062
5163 { /* Content */ }
@@ -54,3 +66,6 @@ export const AuroraBackground = ({
5466 </ main >
5567 ) ;
5668} ;
69+
70+ // Keep the old component for backward compatibility during transition
71+ export const AuroraBackground = EfficientBackground ;
0 commit comments