mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-20 08:33:52 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
31 lines
643 B
TypeScript
31 lines
643 B
TypeScript
import { useEffect, useState } from "react";
|
|
|
|
interface Props {
|
|
text: string;
|
|
className?: string;
|
|
}
|
|
|
|
export function SvgViewer({ text, className }: Props) {
|
|
const [src, setSrc] = useState<string | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!text) {
|
|
return setSrc(null);
|
|
}
|
|
|
|
const blob = new Blob([text], { type: "image/svg+xml;charset=utf-8" });
|
|
const url = URL.createObjectURL(blob);
|
|
setSrc(url);
|
|
|
|
return () => URL.revokeObjectURL(url);
|
|
}, [text]);
|
|
|
|
if (src == null) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<img src={src} alt="Response preview" className={className ?? "max-w-full max-h-full pb-2"} />
|
|
);
|
|
}
|