Skip to content

armgit / ARES

Public Imported from GitHub
0

ARES - authorized red-team engagement automation with dashboard, campaign scope, module orchestration, OPSEC controls, encrypted vault, and reporting.

feat(ui): rework fire button - continuous hover fire enveloping button edges + Enter key burst

Mafifrizif498a6e0e921
diff --git a/frontend/src/features/auth/AresIgniteButton.tsx b/frontend/src/features/auth/AresIgniteButton.tsx
index 8e72c73..20daf52 100644
--- a/frontend/src/features/auth/AresIgniteButton.tsx
+++ b/frontend/src/features/auth/AresIgniteButton.tsx
@@ -1,91 +1,243 @@
import { Loader2 } from "lucide-react";
-import { ButtonHTMLAttributes, ReactNode, useRef } from "react";
+import { ButtonHTMLAttributes, ReactNode, useEffect, useRef, useState } from "react";
+
+interface FireParticle {
+ x: number;
+ y: number;
+ vx: number;
+ vy: number;
+ life: number; // 1..0
+ maxLife: number;
+ size: number;
+ hue: number; // 0=red .. 28=orange-red
+ edge: 0 | 1 | 2 | 3; // 0=top 1=bottom 2=left 3=right
+}
interface AresIgniteButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
isLoading?: boolean;
children: ReactNode;
}
-/**
- * ARES Signature Interaction: Crimson Plasma Shockwave on click.
- * On mousedown: spawns an expanding radial shockwave ring (crimson) that erupts
- * outward from the exact click origin and dissolves in 500ms.
- * On hover: laser-border sweep via CSS class.
- * On loading: perimeter crimson pulse + dark inversion.
- * Pure imperative DOM + CSS - no animation library dependency.
- */
+// Padding around button where fire lives (keep tight so it hugs the button)
+const PAD = 32;
+
+function spawnEdgeParticles(
+ particles: FireParticle[],
+ bw: number,
+ bh: number,
+ count: number
+) {
+ for (let i = 0; i < count; i++) {
+ const edge = Math.floor(Math.random() * 4) as 0 | 1 | 2 | 3;
+ let px = 0, py = 0, vx = 0, vy = 0;
+
+ if (edge === 0) {
+ // Top edge — fire curls up and slightly inward
+ px = PAD + Math.random() * bw;
+ py = PAD + (Math.random() * 4 - 2); // tight to top border
+ vy = -(Math.random() * 0.8 + 0.3); // gently upward
+ vx = (Math.random() - 0.5) * 0.6;
+ } else if (edge === 1) {
+ // Bottom edge — fire rises upward more strongly
+ px = PAD + Math.random() * bw;
+ py = PAD + bh + (Math.random() * 3); // just below bottom border
+ vy = -(Math.random() * 1.2 + 0.6); // rise up toward button
+ vx = (Math.random() - 0.5) * 0.8;
+ } else if (edge === 2) {
+ // Left edge
+ px = PAD + (Math.random() * 3 - 1);
+ py = PAD + Math.random() * bh;
+ vy = -(Math.random() * 0.9 + 0.2);
+ vx = -(Math.random() * 0.4);
+ } else {
+ // Right edge
+ px = PAD + bw + (Math.random() * 3 - 1);
+ py = PAD + Math.random() * bh;
+ vy = -(Math.random() * 0.9 + 0.2);
+ vx = Math.random() * 0.4;
+ }
+
+ particles.push({
+ x: px,
+ y: py,
+ vx,
+ vy,
+ life: 1,
+ maxLife: 18 + Math.random() * 18, // short life = stays close to button
+ size: 3 + Math.random() * 5,
+ hue: Math.random() * 28,
+ edge,
+ });
+ }
+}
+
export function AresIgniteButton({
isLoading,
children,
- onClick,
disabled,
- className: _className,
...props
}: AresIgniteButtonProps) {
- const buttonRef = useRef<HTMLButtonElement>(null);
-
- function spawnShockwave(e: React.MouseEvent<HTMLButtonElement>) {
- const btn = buttonRef.current;
- if (!btn || disabled || isLoading) return;
-
- const rect = btn.getBoundingClientRect();
-
- // Calculate click origin relative to button
- const x = e.clientX - rect.left;
- const y = e.clientY - rect.top;
-
- // Diameter must cover entire button diagonally
- const diameter = Math.max(rect.width, rect.height) * 2.6;
- const radius = diameter / 2;
-
- // Spawn the shockwave ring element
- const ring = document.createElement("span");
- ring.style.cssText = `
- position: absolute;
- left: ${x - radius}px;
- top: ${y - radius}px;
- width: ${diameter}px;
- height: ${diameter}px;
- border-radius: 50%;
- pointer-events: none;
- animation: aresShockwave 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
- `;
-
- btn.style.position = "relative";
- btn.style.overflow = "hidden";
- btn.appendChild(ring);
-
- ring.addEventListener("animationend", () => {
- ring.remove();
- });
+ const wrapRef = useRef<HTMLDivElement>(null);
+ const canvasRef = useRef<HTMLCanvasElement>(null);
+ const particlesRef = useRef<FireParticle[]>([]);
+ const rafRef = useRef<number>(0);
+ const isHoveringRef = useRef(false);
+ const [isHovering, setIsHovering] = useState(false);
+
+ useEffect(() => {
+ const canvas = canvasRef.current;
+ if (!canvas) return;
+ const ctx = canvas.getContext("2d");
+ if (!ctx) return;
+
+ function tick() {
+ const particles = particlesRef.current;
+ if (!ctx || !canvas) return;
+
+ // Keep canvas fitted to wrapper
+ const wrap = wrapRef.current;
+ if (wrap) {
+ const w = wrap.offsetWidth + PAD * 2;
+ const h = wrap.offsetHeight + PAD * 2;
+ if (canvas.width !== w || canvas.height !== h) {
+ canvas.width = w;
+ canvas.height = h;
+ canvas.style.left = `-${PAD}px`;
+ canvas.style.top = `-${PAD}px`;
+ }
+
+ // Continuously spawn while hovered
+ if (isHoveringRef.current) {
+ spawnEdgeParticles(particles, wrap.offsetWidth, wrap.offsetHeight, 5);
+ }
+ }
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
- if (onClick) onClick(e);
+ for (let i = particles.length - 1; i >= 0; i--) {
+ const p = particles[i];
+
+ p.x += p.vx;
+ p.y += p.vy;
+ // Very gentle buoyancy — keep fire hugging button, not flying away
+ p.vy -= 0.06;
+ // Slight turbulence
+ p.vx += (Math.random() - 0.5) * 0.18;
+ // Damp horizontal so fire doesn't drift too far sideways
+ p.vx *= 0.97;
+ p.size *= 0.965;
+ p.life -= 1 / p.maxLife;
+
+ if (p.life <= 0 || p.size < 0.4) {
+ particles.splice(i, 1);
+ continue;
+ }
+
+ const alpha = Math.pow(p.life, 0.7);
+ const r = Math.max(0.1, p.size);
+
+ // Outer glow — soft halo hugging edge
+ const glow = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, r * 2.8);
+ glow.addColorStop(0, `hsla(${p.hue}, 100%, 65%, ${alpha * 0.45})`);
+ glow.addColorStop(0.5, `hsla(${p.hue}, 100%, 45%, ${alpha * 0.2})`);
+ glow.addColorStop(1, `hsla(${p.hue}, 100%, 30%, 0)`);
+ ctx.beginPath();
+ ctx.arc(p.x, p.y, r * 2.8, 0, Math.PI * 2);
+ ctx.fillStyle = glow;
+ ctx.fill();
+
+ // Inner bright core — white-yellow at center, red at edge
+ const core = ctx.createRadialGradient(p.x, p.y, 0, p.x, p.y, r);
+ core.addColorStop(0, `hsla(${p.hue + 25}, 100%, 92%, ${alpha})`);
+ core.addColorStop(0.35, `hsla(${p.hue + 10}, 100%, 65%, ${alpha * 0.85})`);
+ core.addColorStop(0.8, `hsla(${p.hue}, 100%, 45%, ${alpha * 0.6})`);
+ core.addColorStop(1, `hsla(${p.hue - 5}, 100%, 30%, 0)`);
+ ctx.beginPath();
+ ctx.arc(p.x, p.y, r, 0, Math.PI * 2);
+ ctx.fillStyle = core;
+ ctx.fill();
+ }
+
+ rafRef.current = requestAnimationFrame(tick);
+ }
+
+ rafRef.current = requestAnimationFrame(tick);
+ return () => cancelAnimationFrame(rafRef.current);
+ }, []);
+
+ // Burst fire on Enter key (even without hover)
+ useEffect(() => {
+ function onKeyDown(e: KeyboardEvent) {
+ if (e.key === "Enter" && !disabled && !isLoading) {
+ const wrap = wrapRef.current;
+ if (!wrap) return;
+ spawnEdgeParticles(particlesRef.current, wrap.offsetWidth, wrap.offsetHeight, 60);
+ }
+ }
+ window.addEventListener("keydown", onKeyDown);
+ return () => window.removeEventListener("keydown", onKeyDown);
+ }, [disabled, isLoading]);
+
+ function handleMouseEnter() {
+ if (disabled || isLoading) return;
+ isHoveringRef.current = true;
+ setIsHovering(true);
+ }
+
+ function handleMouseLeave() {
+ isHoveringRef.current = false;
+ setIsHovering(false);
+ }
+
+ // Also burst on click for instant impact
+ function handleMouseDown() {
+ if (disabled || isLoading) return;
+ const wrap = wrapRef.current;
+ if (!wrap) return;
+ spawnEdgeParticles(particlesRef.current, wrap.offsetWidth, wrap.offsetHeight, 55);
}
return (
- <button
- ref={buttonRef}
- {...props}
- disabled={disabled || isLoading}
- onMouseDown={spawnShockwave}
- className={[
- "w-full mt-2 flex items-center justify-center gap-2 rounded-md px-4 py-2.5 text-sm font-semibold",
- "transition-all duration-200",
- "focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-zinc-950",
- "disabled:cursor-not-allowed",
- isLoading
- ? "bg-zinc-950 text-red-400 border border-red-800/60 ares-ignite-loading disabled:opacity-100 focus:ring-red-800/60"
- : "bg-zinc-100 hover:bg-white text-zinc-950 shadow-sm active:scale-[0.98] ares-ignite-idle focus:ring-zinc-400 disabled:opacity-50",
- ].join(" ")}
- >
- {isLoading ? (
- <>
- <Loader2 size={15} className="animate-spin text-red-500 shrink-0" />
- <span>Authenticating...</span>
- </>
- ) : (
- children
- )}
- </button>
+ <div ref={wrapRef} className="relative mt-2 w-full">
+ {/* Fire canvas — absolute overlay, pointer-events none */}
+ <canvas
+ ref={canvasRef}
+ className="absolute pointer-events-none z-20"
+ style={{ mixBlendMode: "screen" }}
+ />
+
+ <button
+ {...props}
+ type="submit"
+ disabled={disabled || isLoading}
+ onMouseEnter={handleMouseEnter}
+ onMouseLeave={handleMouseLeave}
+ onMouseDown={handleMouseDown}
+ className={[
+ "relative z-10 w-full flex items-center justify-center gap-2 rounded-md px-4 py-2.5 text-sm font-semibold",
+ "transition-all duration-300",
+ "focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950",
+ "disabled:cursor-not-allowed",
+ isLoading
+ ? "bg-zinc-950 text-red-400 border border-red-800/60 disabled:opacity-100 focus-visible:ring-red-800/60"
+ : [
+ "bg-zinc-100 text-zinc-950 shadow-sm",
+ "active:scale-[0.98] focus-visible:ring-zinc-400 disabled:opacity-50",
+ isHovering
+ ? "bg-white shadow-[0_0_22px_4px_rgba(220,38,38,0.45)]"
+ : "hover:bg-white",
+ ].join(" "),
+ ].join(" ")}
+ >
+ {isLoading ? (
+ <>
+ <Loader2 size={15} className="animate-spin text-red-500 shrink-0" />
+ <span>Authenticating...</span>
+ </>
+ ) : (
+ children
+ )}
+ </button>
+ </div>
);
}