apex-ui-kit 2.12.0 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,103 +1,98 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
3
|
-
import { motion, useAnimation } from 'framer-motion';
|
|
4
|
-
|
|
5
|
-
const BeamBar = ({
|
|
6
|
-
fromColor = "#a855f7",
|
|
7
|
-
viaColor = "#38bdf8",
|
|
8
|
-
toColor = "#06b6d4",
|
|
9
|
-
barWidth: maxBarWidth = 320, // Prop ko maxBarWidth ki tarah use karenge
|
|
10
|
-
barHeight = 8,
|
|
11
|
-
duration = 1.2,
|
|
12
|
-
pulseDuration = 2.5
|
|
13
|
-
}) => {
|
|
14
|
-
const controls = useAnimation();
|
|
15
|
-
const [pulse, setPulse] = useState(false);
|
|
16
|
-
const [beamOpacity, setBeamOpacity] = useState(0.1);
|
|
17
|
-
|
|
18
|
-
// Responsive width ke liye state
|
|
19
|
-
const [dynamicBarWidth, setDynamicBarWidth] = useState(0);
|
|
20
|
-
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</motion.div>
|
|
99
|
-
</div>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { motion, useAnimation } from 'framer-motion';
|
|
4
|
+
|
|
5
|
+
const BeamBar = ({
|
|
6
|
+
fromColor = "#a855f7",
|
|
7
|
+
viaColor = "#38bdf8",
|
|
8
|
+
toColor = "#06b6d4",
|
|
9
|
+
barWidth: maxBarWidth = 320, // Prop ko maxBarWidth ki tarah use karenge
|
|
10
|
+
barHeight = 8,
|
|
11
|
+
duration = 1.2,
|
|
12
|
+
pulseDuration = 2.5
|
|
13
|
+
}) => {
|
|
14
|
+
const controls = useAnimation();
|
|
15
|
+
const [pulse, setPulse] = useState(false);
|
|
16
|
+
const [beamOpacity, setBeamOpacity] = useState(0.1);
|
|
17
|
+
|
|
18
|
+
// Responsive width ke liye state
|
|
19
|
+
const [dynamicBarWidth, setDynamicBarWidth] = useState(0);
|
|
20
|
+
|
|
21
|
+
// 80% of the space it sits in (not the screen) or maxBarWidth, whichever is smaller,
|
|
22
|
+
// so it also fits sidebars, preview frames and narrow columns.
|
|
23
|
+
const wrap = useRef(null);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const el = wrap.current;
|
|
26
|
+
if (!el) return undefined;
|
|
27
|
+
const ro = new ResizeObserver(() => setDynamicBarWidth(Math.min(el.clientWidth * 0.8, maxBarWidth)));
|
|
28
|
+
ro.observe(el);
|
|
29
|
+
return () => ro.disconnect();
|
|
30
|
+
}, [maxBarWidth]);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
// Jab dynamicBarWidth set ho jaye tab animation start karein
|
|
34
|
+
if (dynamicBarWidth > 0) {
|
|
35
|
+
controls.start({
|
|
36
|
+
width: dynamicBarWidth,
|
|
37
|
+
transition: { duration, ease: "easeInOut" }
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Animate beam opacity gradually during width expansion
|
|
41
|
+
let start = null;
|
|
42
|
+
let frame = 0;
|
|
43
|
+
function animateBeam(ts) {
|
|
44
|
+
if (!start) start = ts;
|
|
45
|
+
const elapsed = (ts - start) / 1000;
|
|
46
|
+
const progress = Math.min(elapsed / duration, 1);
|
|
47
|
+
setBeamOpacity(0.2 + 0.8 * progress); // from 0.2 to 1.0
|
|
48
|
+
if (progress < 1) {
|
|
49
|
+
frame = requestAnimationFrame(animateBeam);
|
|
50
|
+
} else {
|
|
51
|
+
setPulse(true);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
frame = requestAnimationFrame(animateBeam);
|
|
55
|
+
|
|
56
|
+
// Cleanup (stop the running loop so a resize or unmount doesn't leave it going)
|
|
57
|
+
return () => {
|
|
58
|
+
cancelAnimationFrame(frame);
|
|
59
|
+
setBeamOpacity(0.2);
|
|
60
|
+
setPulse(false);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}, [dynamicBarWidth, duration, controls]);
|
|
64
|
+
|
|
65
|
+
// Beam ka size ab bar ki width par depend karega
|
|
66
|
+
const beamWidth = dynamicBarWidth * 1.25;
|
|
67
|
+
const beamHeight = 800; // Ise bhi dynamic kar sakte hain agar zaroorat ho
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<div ref={wrap} className="fixed top-10 left-0 w-full flex justify-center z-50 pointer-events-none">
|
|
71
|
+
<motion.div
|
|
72
|
+
initial={{ width: 0 }}
|
|
73
|
+
animate={controls}
|
|
74
|
+
className={`absolute top-0 left-1/2 -translate-x-1/2 rounded-md shadow-[0_0_10px_#fff,0_0_20px_#4f46e5,0_0_30px_#06b6d4] ${pulse ? 'animate-pulse' : ''}`}
|
|
75
|
+
style={{
|
|
76
|
+
height: barHeight,
|
|
77
|
+
background: `linear-gradient(to right, ${fromColor}, ${viaColor}, ${toColor})`,
|
|
78
|
+
animationDuration: pulse ? `${pulseDuration}s` : undefined,
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{/* Beam from Bar using pseudo-element */}
|
|
82
|
+
<div
|
|
83
|
+
className="absolute top-2 left-1/2 transform -translate-x-1/2 pointer-events-none z-0"
|
|
84
|
+
style={{
|
|
85
|
+
width: `${beamWidth}px`, // Dynamic width
|
|
86
|
+
height: `${beamHeight}px`, // Dynamic height (optional)
|
|
87
|
+
background: `linear-gradient(to bottom, rgba(111, 93, 245, 0.7), rgba(7, 7, 7, 0.3), transparent)`,
|
|
88
|
+
filter: "blur(100px)",
|
|
89
|
+
opacity: beamOpacity,
|
|
90
|
+
animation: pulse ? `glow ${pulseDuration}s infinite alternate` : undefined
|
|
91
|
+
}}
|
|
92
|
+
></div>
|
|
93
|
+
</motion.div>
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
103
98
|
export default BeamBar;
|
package/package.json
CHANGED