From c824ff15427f6fd933a67a9fa9d2ab6ee3f440a8 Mon Sep 17 00:00:00 2001 From: yoonie-jang Date: Tue, 17 Sep 2024 10:45:09 -0400 Subject: [PATCH] change implementation --- demo/src/App.tsx | 5 +---- demo/src/DownloadSVGButton.tsx | 3 +-- demo/src/SvgDisplay.tsx | 2 ++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/demo/src/App.tsx b/demo/src/App.tsx index ac29f032..ac85dca4 100644 --- a/demo/src/App.tsx +++ b/demo/src/App.tsx @@ -71,10 +71,7 @@ export default function App() { setSvgResult={setSvgResult} /> - + diff --git a/demo/src/DownloadSVGButton.tsx b/demo/src/DownloadSVGButton.tsx index 43ec4f36..2ca8ba0d 100644 --- a/demo/src/DownloadSVGButton.tsx +++ b/demo/src/DownloadSVGButton.tsx @@ -3,7 +3,6 @@ import { Button } from "@mui/material"; type DownloadSVGButtonPropTypes = { svgResult: string; - disabled: boolean; }; export default function DownloadSVGButton(props: DownloadSVGButtonPropTypes) { const file = new global.Blob([props.svgResult], { type: "image/svg+xml" }); @@ -13,7 +12,7 @@ export default function DownloadSVGButton(props: DownloadSVGButtonPropTypes) { color="primary" variant="text" data-testid="download-svg-btn" - disabled={props.disabled} + disabled={!props.svgResult} href={URL.createObjectURL(file)} target="_blank" rel="noreferrer" diff --git a/demo/src/SvgDisplay.tsx b/demo/src/SvgDisplay.tsx index edd87c84..773f915a 100644 --- a/demo/src/SvgDisplay.tsx +++ b/demo/src/SvgDisplay.tsx @@ -27,6 +27,8 @@ export default function SvgDisplay(props: SvgDisplayPropTypes) { props.setSvgResult(m.serializeSVG()); m.clear(canvasRef.current); m.render(canvasRef.current); + } else { + props.setSvgResult(null); } }, [props.jsonResult]);