import oc from "open-color"; import { useEffect, useRef } from "react"; import { t } from "../i18n"; import { exportToSvg } from "../packages/utils"; import { AppState, LibraryItem } from "../types"; import { close } from "./icons"; import "./SingleLibraryItem.scss"; import { ToolButton } from "./ToolButton"; const SingleLibraryItem = ({ libItem, appState, index, onChange, onRemove, }: { libItem: LibraryItem; appState: AppState; index: number; onChange: (val: string, index: number) => void; onRemove: (id: string) => void; }) => { const svgRef = useRef(null); const inputRef = useRef(null); useEffect(() => { const node = svgRef.current; if (!node) { return; } (async () => { const svg = await exportToSvg({ elements: libItem.elements, appState: { ...appState, viewBackgroundColor: oc.white, exportBackground: true, }, files: null, }); node.innerHTML = svg.outerHTML; })(); }, [libItem.elements, appState]); return (
{libItem.error}
); }; export default SingleLibraryItem;