Spaces:
Paused
Paused
File size: 1,533 Bytes
d530f14 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 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 49 50 51 52 53 54 55 56 57 58 59 60 | "use client";
import React, { useEffect, useRef } from "react";
import { cn } from "@/utils/cn";
import { setIntervalOnVisible } from "@/utils/set-timeout-on-visible";
import data from "@/components/shared/effects/flame/explosion-data.json";
interface AsciiFlameBackgroundProps {
className?: string;
colorClassName?: string;
fontSizePx?: number;
lineHeightPx?: number;
}
// Reusable ASCII flame background (same frames used by CoreReliableBarFlame)
export default function AsciiFlameBackground({
className,
colorClassName = "text-heat-100/30",
fontSizePx = 10,
lineHeightPx = 12.5,
}: AsciiFlameBackgroundProps) {
const wrapperRef = useRef<HTMLDivElement>(null);
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
let index = 0;
const stop = setIntervalOnVisible({
element: wrapperRef.current,
callback: () => {
index += 1;
if (index >= (data as string[]).length) index = 0;
if (ref.current) ref.current.innerHTML = (data as string[])[index];
},
interval: 80,
});
return () => stop?.();
}, []);
return (
<div
ref={wrapperRef}
className={cn("relative pointer-events-none select-none", className)}
>
<div
ref={ref}
className={cn(
"font-ascii absolute inset-0 fc-decoration",
colorClassName,
)}
style={{
whiteSpace: "pre",
fontSize: `${fontSizePx}px`,
lineHeight: `${lineHeightPx}px`,
}}
/>
</div>
);
}
|