feat: add set gain
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
|
||||
// degrees per second
|
||||
const DONUT_BASE_SPEED = 360 / 8;
|
||||
const DONUT_HOVER_SPEED = 360 / 2;
|
||||
const INNER_BASE_SPEED = 360 / 12;
|
||||
const INNER_HOVER_SPEED = 360 / 3;
|
||||
|
||||
const AnimatedLogo = ({ size = 45, className = '' }) => {
|
||||
const [isHovered, setIsHovered] = useState(false);
|
||||
const isHoveredRef = useRef(false);
|
||||
const donutGroupRef = useRef<SVGGElement | null>(null);
|
||||
const innerGroupRef = useRef<SVGGElement | null>(null);
|
||||
const angleRef = useRef({ donut: 0, inner: 0 });
|
||||
const lastTimeRef = useRef<number | null>(null);
|
||||
const rafIdRef = useRef<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
isHoveredRef.current = isHovered;
|
||||
}, [isHovered]);
|
||||
|
||||
useEffect(() => {
|
||||
const tick = (time: number) => {
|
||||
if (lastTimeRef.current == null) lastTimeRef.current = time;
|
||||
const dt = (time - lastTimeRef.current) / 1000;
|
||||
lastTimeRef.current = time;
|
||||
|
||||
const donutSpeed = isHoveredRef.current ? DONUT_HOVER_SPEED : DONUT_BASE_SPEED;
|
||||
const innerSpeed = isHoveredRef.current ? INNER_HOVER_SPEED : INNER_BASE_SPEED;
|
||||
|
||||
// Accumulate angle continuously -- speed can change instantly
|
||||
// without ever resetting the current rotation.
|
||||
angleRef.current.donut = (angleRef.current.donut + donutSpeed * dt) % 360;
|
||||
angleRef.current.inner = (angleRef.current.inner + innerSpeed * dt) % 360;
|
||||
|
||||
if (donutGroupRef.current) {
|
||||
donutGroupRef.current.setAttribute(
|
||||
'transform',
|
||||
`rotate(${angleRef.current.donut} 100 100)`
|
||||
);
|
||||
}
|
||||
if (innerGroupRef.current) {
|
||||
innerGroupRef.current.setAttribute(
|
||||
'transform',
|
||||
`rotate(${angleRef.current.inner} 100 100)`
|
||||
);
|
||||
}
|
||||
|
||||
rafIdRef.current = requestAnimationFrame(tick);
|
||||
};
|
||||
|
||||
rafIdRef.current = requestAnimationFrame(tick);
|
||||
return () => {
|
||||
if (rafIdRef.current) cancelAnimationFrame(rafIdRef.current);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`animated-logo ${className}`}
|
||||
style={{ width: size, height: size }}
|
||||
onMouseEnter={() => setIsHovered(true)}
|
||||
onMouseLeave={() => setIsHovered(false)}
|
||||
>
|
||||
<svg
|
||||
width="100%"
|
||||
height="100%"
|
||||
viewBox="0 0 200 200"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
style={{ display: 'block' }}
|
||||
>
|
||||
<style>
|
||||
{`
|
||||
.animated-logo {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.animated-logo:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
.richGradient stop:nth-child(1) {
|
||||
stop-color: #1e3a8a;
|
||||
animation: pulse-primary 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.richGradient stop:nth-child(6) {
|
||||
stop-color: #ea437a;
|
||||
animation: pulse-secondary 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.darkening-overlay {
|
||||
animation: breathe 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse-primary {
|
||||
0%, 100% { stop-opacity: 1; }
|
||||
50% { stop-opacity: 0.8; }
|
||||
}
|
||||
|
||||
@keyframes pulse-secondary {
|
||||
0%, 100% { stop-opacity: 1; }
|
||||
50% { stop-opacity: 0.9; }
|
||||
}
|
||||
|
||||
@keyframes breathe {
|
||||
0%, 100% { opacity: 0.6; }
|
||||
50% { opacity: 0.3; }
|
||||
}
|
||||
|
||||
@keyframes logo-entrance {
|
||||
0% {
|
||||
opacity: 0;
|
||||
transform: scale(0.8) rotate(-10deg);
|
||||
}
|
||||
50% {
|
||||
opacity: 0.7;
|
||||
transform: scale(1.05) rotate(5deg);
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
transform: scale(1) rotate(0deg);
|
||||
}
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="richGradient"
|
||||
x1="0%"
|
||||
y1="0%"
|
||||
x2="100%"
|
||||
y2="100%"
|
||||
className="richGradient"
|
||||
>
|
||||
<stop offset="0%" stopColor="#1e3a8a" />
|
||||
<stop offset="25%" stopColor="#2d3485" />
|
||||
<stop offset="45%" stopColor="#4c2e7f" />
|
||||
<stop offset="60%" stopColor="#6b2878" />
|
||||
<stop offset="80%" stopColor="#b9326e" />
|
||||
<stop offset="100%" stopColor="#ea437a" />
|
||||
</linearGradient>
|
||||
|
||||
<radialGradient id="darkenGradient" cx="50%" cy="50%" r="50%">
|
||||
<stop offset="0%" stopColor="rgba(255,255,255,0.3)" />
|
||||
<stop offset="30%" stopColor="rgba(255,255,255,0.1)" />
|
||||
<stop offset="60%" stopColor="rgba(0,0,0,0)" />
|
||||
<stop offset="80%" stopColor="rgba(0,0,0,0.2)" />
|
||||
<stop offset="100%" stopColor="rgba(0,0,0,0.5)" />
|
||||
</radialGradient>
|
||||
|
||||
<linearGradient id="shadowGradient" x1="20%" y1="20%" x2="80%" y2="80%">
|
||||
<stop offset="0%" stopColor="#0f1d42" />
|
||||
<stop offset="25%" stopColor="#1f2a5d" />
|
||||
<stop offset="45%" stopColor="#332f78" />
|
||||
<stop offset="60%" stopColor="#5f3458" />
|
||||
<stop offset="80%" stopColor="#7a2250" />
|
||||
<stop offset="100%" stopColor="#a50d57" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
|
||||
{/* Donut base -- rotation driven by JS so speed can change on hover
|
||||
without resetting the current angle */}
|
||||
<g ref={donutGroupRef}>
|
||||
<path
|
||||
d="M100,20
|
||||
A80,80 0 1,1 99.9,20
|
||||
M100,60
|
||||
A40,40 0 1,0 100.1,60"
|
||||
fill="url(#richGradient)"
|
||||
fillRule="evenodd"
|
||||
/>
|
||||
</g>
|
||||
|
||||
{/* Darkening overlay with breathing effect (opacity only, no rotation) */}
|
||||
<path
|
||||
className="darkening-overlay"
|
||||
d="M100,20
|
||||
A80,80 0 1,1 99.9,20
|
||||
M100,60
|
||||
A40,40 0 1,0 100.1,60"
|
||||
fill="url(#darkenGradient)"
|
||||
fillRule="evenodd"
|
||||
/>
|
||||
|
||||
{/* Inner shadow -- also JS-driven rotation, independent speed/direction */}
|
||||
<g ref={innerGroupRef}>
|
||||
<path
|
||||
d="M100,60
|
||||
A40,40 0 1,0 100.1,60
|
||||
M100,75
|
||||
A25,25 0 1,1 99.9,75"
|
||||
fill="url(#shadowGradient)"
|
||||
fillRule="evenodd"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default AnimatedLogo;
|
||||
@@ -0,0 +1,33 @@
|
||||
export function InfoIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
||||
<path
|
||||
d="M12 11V16M12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21ZM12.0498 8V8.1L11.9502 8.1002V8H12.0498Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
|
||||
export function SlidersIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
||||
<circle cx="16" cy="13" r="3" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" />
|
||||
|
||||
<circle cx="6" cy="22" r="3" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" />
|
||||
|
||||
<circle cx="26" cy="16" r="3" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" />
|
||||
|
||||
<path
|
||||
d="M6 29V25M6 16V3M16 7V3M26 10V3M16 29V16M26 29V19"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
export function ChevronLeftIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
||||
<path
|
||||
d="M9 2.5L4.5 7L9 11.5"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.75"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export function CloseIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 20 20" fill="currentColor" {...props}>
|
||||
<path d="M6.28 5.22a.75.75 0 00-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 101.06 1.06L10 11.06l3.72 3.72a.75.75 0 101.06-1.06L11.06 10l3.72-3.72a.75.75 0 00-1.06-1.06L10 8.94 6.28 5.22z" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
export function CrownIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
||||
<path
|
||||
d="M3 7L6.5 10L9 5L12 10L15 5L17.5 10L21 7L19 18H5L3 7Z"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
<path d="M5 18H19" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export function PlusIcon(props: React.SVGProps<SVGSVGElement>) {
|
||||
return (
|
||||
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
|
||||
<path
|
||||
d="M8 2.5V13.5M2.5 8H13.5"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.6"
|
||||
strokeLinecap="round"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user