Skip to content

Commit

Permalink
change implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonieaj committed Sep 17, 2024
1 parent ce08f23 commit c824ff1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
5 changes: 1 addition & 4 deletions demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ export default function App() {
setSvgResult={setSvgResult}
/>
</ErrorBoundary>
<DownloadSVGButton
svgResult={svgResult}
disabled={!jsonResult}
/>
<DownloadSVGButton svgResult={svgResult} />
</Box>
</Stack>
</main>
Expand Down
3 changes: 1 addition & 2 deletions demo/src/DownloadSVGButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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" });
Expand All @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions demo/src/SvgDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down

0 comments on commit c824ff1

Please sign in to comment.