Files
altbin.dev/components/dashboard/LordIcon.tsx
T

24 lines
680 B
TypeScript
Raw Normal View History

2025-08-20 14:14:33 +02:00
"use client";
import { Player } from "@lordicon/react";
2025-08-20 16:41:27 +02:00
import { forwardRef, useEffect, useState, type ForwardedRef } from "react";
2025-08-20 14:14:33 +02:00
const LordIcon = forwardRef(function LordIcon(
{ url, size = 28, colorize = "#3b82f6" }: { url: string; size?: number; colorize?: string },
2025-08-20 16:41:27 +02:00
ref: ForwardedRef<Player>
2025-08-20 14:14:33 +02:00
) {
2025-08-20 16:41:27 +02:00
const [iconData, setIconData] = useState<Record<string, unknown> | null>(null);
2025-08-20 14:14:33 +02:00
useEffect(() => {
2025-08-20 16:41:27 +02:00
fetch(url)
.then((res) => res.json())
.then((data: Record<string, unknown>) => setIconData(data));
2025-08-20 14:14:33 +02:00
}, [url]);
if (!iconData) return null;
2025-08-20 16:41:27 +02:00
2025-08-20 14:14:33 +02:00
return <Player ref={ref} icon={iconData} size={size} colorize={colorize} />;
});
export default LordIcon;