apex-ui-kit 2.1.3 → 2.3.0
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.
- package/dist/ApexUI-Kit/templates/AiChat/AiChat.jsx +171 -0
- package/dist/ApexUI-Kit/templates/AiModelPrompt/AiModelPrompt.jsx +221 -0
- package/dist/ApexUI-Kit/templates/AiModelPrompt/index.js +2 -0
- package/dist/ApexUI-Kit/templates/AiModelPrompt/models.js +15 -0
- package/dist/ApexUI-Kit/templates/AiPromptBox/AiPromptBox.jsx +173 -0
- package/dist/ApexUI-Kit/templates/AiResponse/AiResponse.jsx +172 -0
- package/dist/ApexUI-Kit/templates/AiThinking/AiThinking.jsx +106 -0
- package/dist/ApexUI-Kit/templates/AiVoiceBars/AiVoiceBars.jsx +78 -0
- package/dist/ApexUI-Kit/templates/AiVoiceBlob/AiVoiceBlob.jsx +105 -0
- package/dist/ApexUI-Kit/templates/AiVoiceOrb/AiVoiceOrb.jsx +74 -0
- package/dist/ApexUI-Kit/templates/AiVoiceRing/AiVoiceRing.jsx +120 -0
- package/dist/ApexUI-Kit/templates/AiVoiceWave/AiVoiceWave.jsx +107 -0
- package/dist/ApexUI-Kit/templates/AnimatedButton/AnimatedButton.jsx +251 -0
- package/dist/ApexUI-Kit/templates/AnimatedSwitch/AnimatedSwitch.jsx +80 -0
- package/dist/ApexUI-Kit/templates/AnimatedTabs/AnimatedTabs.jsx +107 -0
- package/dist/ApexUI-Kit/templates/AuroraBackground/AuroraBackground.jsx +48 -0
- package/dist/ApexUI-Kit/templates/BlurRevealText/BlurRevealText.jsx +60 -0
- package/dist/ApexUI-Kit/templates/BounceCards/BounceCards.jsx +53 -0
- package/dist/ApexUI-Kit/templates/CardSwap3D/CardSwap3D.jsx +80 -0
- package/dist/ApexUI-Kit/templates/Carousel3D/Carousel3D.jsx +222 -0
- package/dist/ApexUI-Kit/templates/CircularText/CircularText.jsx +49 -0
- package/dist/ApexUI-Kit/templates/ClickSpark/ClickSpark.jsx +72 -0
- package/dist/ApexUI-Kit/templates/Coverflow3D/Coverflow3D.jsx +108 -0
- package/dist/ApexUI-Kit/templates/CubeGallery/CubeGallery.jsx +166 -0
- package/dist/ApexUI-Kit/templates/CursorTrail/CursorTrail.jsx +200 -0
- package/dist/ApexUI-Kit/templates/DotGlobe/DotGlobe.jsx +289 -0
- package/dist/ApexUI-Kit/templates/ElasticSlider/ElasticSlider.jsx +152 -0
- package/dist/ApexUI-Kit/templates/ExtrudedText/ExtrudedText.jsx +78 -0
- package/dist/ApexUI-Kit/templates/FaqAccordion/FaqAccordion.jsx +88 -0
- package/dist/ApexUI-Kit/templates/FlipBook/FlipBook.jsx +191 -0
- package/dist/ApexUI-Kit/templates/FlipClock/FlipClock.jsx +121 -0
- package/dist/ApexUI-Kit/templates/FloatingNavbar/FloatingNavbar.jsx +162 -0
- package/dist/ApexUI-Kit/templates/Folder/Folder.jsx +101 -0
- package/dist/ApexUI-Kit/templates/GlitchText/GlitchText.jsx +56 -0
- package/dist/ApexUI-Kit/templates/GooeyNav/GooeyNav.jsx +310 -0
- package/dist/ApexUI-Kit/templates/HoldToConfirm/HoldToConfirm.jsx +169 -0
- package/dist/ApexUI-Kit/templates/HoldToConfirm/UndoNotice.jsx +58 -0
- package/dist/ApexUI-Kit/templates/HoloCard/HoloCard.jsx +92 -0
- package/dist/ApexUI-Kit/templates/ImageCompare/ImageCompare.jsx +94 -0
- package/dist/ApexUI-Kit/templates/IsoStack/IsoStack.jsx +86 -0
- package/dist/ApexUI-Kit/templates/LiquidGradient/LiquidGradient.jsx +238 -0
- package/dist/ApexUI-Kit/templates/LoadingScreen/LoadingScreen.jsx +805 -0
- package/dist/ApexUI-Kit/templates/MagnetLines/MagnetLines.jsx +67 -0
- package/dist/ApexUI-Kit/templates/MagneticCursor/MagneticCursor.jsx +148 -0
- package/dist/ApexUI-Kit/templates/PixelTransition/PixelTransition.jsx +75 -0
- package/dist/ApexUI-Kit/templates/PricingCards/PricingCards.jsx +115 -0
- package/dist/ApexUI-Kit/templates/ProfileCard/ProfileCard.jsx +213 -0
- package/dist/ApexUI-Kit/templates/ProximityText/ProximityText.jsx +66 -0
- package/dist/ApexUI-Kit/templates/RotatingText/RotatingText.jsx +50 -0
- package/dist/ApexUI-Kit/templates/ShinyText/ShinyText.jsx +30 -0
- package/dist/ApexUI-Kit/templates/SidebarNav/SidebarNav.jsx +220 -0
- package/dist/ApexUI-Kit/templates/SpotlightGrid/SpotlightGrid.jsx +110 -0
- package/dist/ApexUI-Kit/templates/StarBorder/StarBorder.jsx +33 -0
- package/dist/ApexUI-Kit/templates/Stepper/Stepper.jsx +129 -0
- package/dist/ApexUI-Kit/templates/SwipeCards/SwipeCards.jsx +123 -0
- package/dist/ApexUI-Kit/templates/TextRing3D/TextRing3D.jsx +73 -0
- package/dist/ApexUI-Kit/templates/ToastStack/ToastStack.jsx +108 -0
- package/dist/ApexUI-Kit/templates/ToolTip/ToolTip.jsx +5 -3
- package/dist/ApexUI-Kit/templates/TrueFocus/TrueFocus.jsx +64 -0
- package/dist/ApexUI-Kit/templates/TypewriterText/TypewriterText.jsx +70 -0
- package/dist/ApexUI-Kit/templates/WebGLCarousel/WebGLCarousel.jsx +326 -0
- package/dist/ApexUI-Kit/templates/WorldMap/WorldMap.jsx +359 -0
- package/dist/cli/index.js +63 -0
- package/package.json +1 -1
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react";
|
|
2
|
+
import { Mesh, Program, Renderer, Triangle } from "ogl";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Liquid Gradient: a slow, flowing four-color mesh gradient drawn by a single
|
|
6
|
+
* OGL fragment shader on one full-screen triangle. The colors lean toward the
|
|
7
|
+
* pointer, a light film grain keeps it from banding, and it pauses off screen.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const hexToVec3 = (hex) => {
|
|
11
|
+
let h = String(hex).replace("#", "");
|
|
12
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
13
|
+
const n = parseInt(h, 16) || 0;
|
|
14
|
+
return [((n >> 16) & 255) / 255, ((n >> 8) & 255) / 255, (n & 255) / 255];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const vertex = /* glsl */ `
|
|
18
|
+
attribute vec2 uv;
|
|
19
|
+
attribute vec2 position;
|
|
20
|
+
varying vec2 vUv;
|
|
21
|
+
void main() {
|
|
22
|
+
vUv = uv;
|
|
23
|
+
gl_Position = vec4(position, 0.0, 1.0);
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
const fragment = /* glsl */ `
|
|
28
|
+
precision highp float;
|
|
29
|
+
uniform float uTime;
|
|
30
|
+
uniform vec2 uResolution;
|
|
31
|
+
uniform vec2 uMouse;
|
|
32
|
+
uniform float uMouseStrength;
|
|
33
|
+
uniform float uScale;
|
|
34
|
+
uniform float uGrain;
|
|
35
|
+
uniform vec3 uColor1;
|
|
36
|
+
uniform vec3 uColor2;
|
|
37
|
+
uniform vec3 uColor3;
|
|
38
|
+
uniform vec3 uColor4;
|
|
39
|
+
varying vec2 vUv;
|
|
40
|
+
|
|
41
|
+
vec2 hash(vec2 p) {
|
|
42
|
+
p = vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)));
|
|
43
|
+
return -1.0 + 2.0 * fract(sin(p) * 43758.5453);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
float noise(vec2 p) {
|
|
47
|
+
vec2 i = floor(p);
|
|
48
|
+
vec2 f = fract(p);
|
|
49
|
+
vec2 u = f * f * (3.0 - 2.0 * f);
|
|
50
|
+
return mix(
|
|
51
|
+
mix(dot(hash(i), f), dot(hash(i + vec2(1.0, 0.0)), f - vec2(1.0, 0.0)), u.x),
|
|
52
|
+
mix(dot(hash(i + vec2(0.0, 1.0)), f - vec2(0.0, 1.0)), dot(hash(i + vec2(1.0, 1.0)), f - vec2(1.0, 1.0)), u.x),
|
|
53
|
+
u.y
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
float fbm(vec2 p) {
|
|
58
|
+
float v = 0.0;
|
|
59
|
+
float a = 0.5;
|
|
60
|
+
for (int i = 0; i < 4; i++) {
|
|
61
|
+
v += a * noise(p);
|
|
62
|
+
p *= 2.0;
|
|
63
|
+
a *= 0.5;
|
|
64
|
+
}
|
|
65
|
+
return v;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
void main() {
|
|
69
|
+
float aspect = uResolution.x / uResolution.y;
|
|
70
|
+
vec2 p = (vUv - 0.5) * vec2(aspect, 1.0) * uScale;
|
|
71
|
+
float t = uTime * 0.12;
|
|
72
|
+
|
|
73
|
+
// Pull the field toward the pointer.
|
|
74
|
+
vec2 m = (uMouse - 0.5) * vec2(aspect, 1.0) * uScale;
|
|
75
|
+
float md = length(p - m);
|
|
76
|
+
p += (m - p) * uMouseStrength * 0.35 * exp(-md * md * 1.5);
|
|
77
|
+
|
|
78
|
+
// Domain-warped noise: noise feeding noise gives the liquid folds.
|
|
79
|
+
vec2 q = vec2(fbm(p + t), fbm(p + vec2(5.2, 1.3) - t));
|
|
80
|
+
vec2 r = vec2(fbm(p + 3.0 * q + vec2(1.7, 9.2) + t * 0.6), fbm(p + 3.0 * q + vec2(8.3, 2.8) - t * 0.4));
|
|
81
|
+
float n = fbm(p + 2.5 * r);
|
|
82
|
+
|
|
83
|
+
vec3 col = mix(uColor1, uColor2, smoothstep(-0.4, 0.4, q.x));
|
|
84
|
+
col = mix(col, uColor3, smoothstep(-0.3, 0.5, r.y));
|
|
85
|
+
col = mix(col, uColor4, smoothstep(0.1, 0.7, n));
|
|
86
|
+
|
|
87
|
+
col *= 1.0 - 0.25 * length(vUv - 0.5);
|
|
88
|
+
float g = fract(sin(dot(gl_FragCoord.xy + fract(uTime) * 100.0, vec2(12.9898, 78.233))) * 43758.5453);
|
|
89
|
+
col += (g - 0.5) * uGrain;
|
|
90
|
+
|
|
91
|
+
gl_FragColor = vec4(col, 1.0);
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
95
|
+
const LiquidGradient = ({
|
|
96
|
+
children,
|
|
97
|
+
className = "",
|
|
98
|
+
containerClassName = "",
|
|
99
|
+
colors = ["#1e1b4b", "#4f46e5", "#db2777", "#f97316"],
|
|
100
|
+
speed = 1,
|
|
101
|
+
scale = 1.6,
|
|
102
|
+
grain = 0.06,
|
|
103
|
+
mouseInteractive = true,
|
|
104
|
+
quality = 1,
|
|
105
|
+
}) => {
|
|
106
|
+
const containerRef = useRef(null);
|
|
107
|
+
const programRef = useRef(null);
|
|
108
|
+
const renderRef = useRef(() => {});
|
|
109
|
+
const speedRef = useRef(speed);
|
|
110
|
+
speedRef.current = speed;
|
|
111
|
+
const pointer = useRef({ x: 0.5, y: 0.5, tx: 0.5, ty: 0.5, strength: 0, target: 0 });
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
const container = containerRef.current;
|
|
115
|
+
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
116
|
+
const renderer = new Renderer({ dpr: Math.min(window.devicePixelRatio || 1, 1.5) * quality, antialias: false, alpha: false });
|
|
117
|
+
const gl = renderer.gl;
|
|
118
|
+
gl.canvas.style.cssText = "position:absolute;inset:0;width:100%;height:100%;display:block;";
|
|
119
|
+
container.prepend(gl.canvas);
|
|
120
|
+
|
|
121
|
+
const program = new Program(gl, {
|
|
122
|
+
vertex,
|
|
123
|
+
fragment,
|
|
124
|
+
uniforms: {
|
|
125
|
+
uTime: { value: 0 },
|
|
126
|
+
uResolution: { value: [1, 1] },
|
|
127
|
+
uMouse: { value: [0.5, 0.5] },
|
|
128
|
+
uMouseStrength: { value: 0 },
|
|
129
|
+
uScale: { value: scale },
|
|
130
|
+
uGrain: { value: grain },
|
|
131
|
+
uColor1: { value: hexToVec3(colors[0]) },
|
|
132
|
+
uColor2: { value: hexToVec3(colors[1] ?? colors[0]) },
|
|
133
|
+
uColor3: { value: hexToVec3(colors[2] ?? colors[0]) },
|
|
134
|
+
uColor4: { value: hexToVec3(colors[3] ?? colors[0]) },
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
programRef.current = program;
|
|
138
|
+
const mesh = new Mesh(gl, { geometry: new Triangle(gl), program });
|
|
139
|
+
|
|
140
|
+
let raf = 0;
|
|
141
|
+
let last = performance.now();
|
|
142
|
+
let time = 7; // start mid-flow so the first frame already looks liquid
|
|
143
|
+
let visible = true;
|
|
144
|
+
|
|
145
|
+
const render = () => renderer.render({ scene: mesh });
|
|
146
|
+
renderRef.current = render;
|
|
147
|
+
const resize = () => {
|
|
148
|
+
const { width, height } = container.getBoundingClientRect();
|
|
149
|
+
renderer.setSize(Math.max(1, width), Math.max(1, height));
|
|
150
|
+
program.uniforms.uResolution.value = [Math.max(1, width), Math.max(1, height)];
|
|
151
|
+
render();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const loop = (now) => {
|
|
155
|
+
const dt = Math.min(0.05, (now - last) / 1000);
|
|
156
|
+
last = now;
|
|
157
|
+
time += dt * speedRef.current;
|
|
158
|
+
const p = pointer.current;
|
|
159
|
+
p.x += (p.tx - p.x) * 0.06;
|
|
160
|
+
p.y += (p.ty - p.y) * 0.06;
|
|
161
|
+
p.strength += (p.target - p.strength) * 0.05;
|
|
162
|
+
program.uniforms.uTime.value = time;
|
|
163
|
+
program.uniforms.uMouse.value = [p.x, p.y];
|
|
164
|
+
program.uniforms.uMouseStrength.value = p.strength;
|
|
165
|
+
render();
|
|
166
|
+
raf = requestAnimationFrame(loop);
|
|
167
|
+
};
|
|
168
|
+
const start = () => {
|
|
169
|
+
if (reduced || raf || !visible) return;
|
|
170
|
+
last = performance.now();
|
|
171
|
+
raf = requestAnimationFrame(loop);
|
|
172
|
+
};
|
|
173
|
+
const stop = () => {
|
|
174
|
+
cancelAnimationFrame(raf);
|
|
175
|
+
raf = 0;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const ro = new ResizeObserver(resize);
|
|
179
|
+
ro.observe(container);
|
|
180
|
+
const io = new IntersectionObserver(([entry]) => {
|
|
181
|
+
visible = entry.isIntersecting;
|
|
182
|
+
if (visible) start();
|
|
183
|
+
else stop();
|
|
184
|
+
});
|
|
185
|
+
io.observe(container);
|
|
186
|
+
program.uniforms.uTime.value = time;
|
|
187
|
+
resize();
|
|
188
|
+
start();
|
|
189
|
+
|
|
190
|
+
return () => {
|
|
191
|
+
stop();
|
|
192
|
+
ro.disconnect();
|
|
193
|
+
io.disconnect();
|
|
194
|
+
programRef.current = null;
|
|
195
|
+
renderRef.current = () => {};
|
|
196
|
+
gl.canvas.remove();
|
|
197
|
+
gl.getExtension("WEBGL_lose_context")?.loseContext();
|
|
198
|
+
};
|
|
199
|
+
// The renderer is rebuilt only when quality changes; other props update uniforms below.
|
|
200
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
201
|
+
}, [quality]);
|
|
202
|
+
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
const program = programRef.current;
|
|
205
|
+
if (!program) return;
|
|
206
|
+
program.uniforms.uScale.value = scale;
|
|
207
|
+
program.uniforms.uGrain.value = grain;
|
|
208
|
+
program.uniforms.uColor1.value = hexToVec3(colors[0]);
|
|
209
|
+
program.uniforms.uColor2.value = hexToVec3(colors[1] ?? colors[0]);
|
|
210
|
+
program.uniforms.uColor3.value = hexToVec3(colors[2] ?? colors[0]);
|
|
211
|
+
program.uniforms.uColor4.value = hexToVec3(colors[3] ?? colors[0]);
|
|
212
|
+
// Redraw now so a paused (reduced-motion) gradient shows the change too.
|
|
213
|
+
renderRef.current();
|
|
214
|
+
}, [colors, scale, grain]);
|
|
215
|
+
|
|
216
|
+
const onPointerMove = (e) => {
|
|
217
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
218
|
+
pointer.current.tx = (e.clientX - rect.left) / rect.width;
|
|
219
|
+
pointer.current.ty = 1 - (e.clientY - rect.top) / rect.height;
|
|
220
|
+
pointer.current.target = 1;
|
|
221
|
+
};
|
|
222
|
+
const onPointerLeave = () => {
|
|
223
|
+
pointer.current.target = 0;
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<div
|
|
228
|
+
ref={containerRef}
|
|
229
|
+
onPointerMove={mouseInteractive ? onPointerMove : undefined}
|
|
230
|
+
onPointerLeave={onPointerLeave}
|
|
231
|
+
className={`relative h-screen w-full overflow-hidden bg-[#0b0b14] ${containerClassName}`}
|
|
232
|
+
>
|
|
233
|
+
{children && <div className={`relative z-10 h-full w-full ${className}`}>{children}</div>}
|
|
234
|
+
</div>
|
|
235
|
+
);
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export default LiquidGradient;
|