✨ Added export to components/Workbench
This commit is contained in:
parent
e3035747dc
commit
0ae95f64ad
6 changed files with 77 additions and 51 deletions
|
@ -5,6 +5,8 @@ import Design from "../Design";
|
|||
import DraftConfigurator from "../../DraftConfigurator";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import Prism from "prismjs";
|
||||
import fileSaver from "file-saver";
|
||||
import theme from "@freesewing/plugin-theme";
|
||||
|
||||
const DraftPattern = props => {
|
||||
const [design, setDesign] = useState(true);
|
||||
|
@ -30,6 +32,23 @@ const DraftPattern = props => {
|
|||
setFocus(f);
|
||||
};
|
||||
|
||||
const svgToFile = svg => {
|
||||
const blob = new Blob([svg], {
|
||||
type: "image/svg+xml;charset=utf-8"
|
||||
});
|
||||
fileSaver.saveAs(blob, "freesewing-" + props.config.name + ".svg");
|
||||
};
|
||||
|
||||
if (props.svgExport) {
|
||||
svgToFile(
|
||||
new props.Pattern(props.gist.settings)
|
||||
.use(theme)
|
||||
.draft()
|
||||
.render()
|
||||
);
|
||||
props.setSvgExport(false);
|
||||
}
|
||||
|
||||
const styles = {
|
||||
paragraph: {
|
||||
padding: "0 1rem"
|
||||
|
@ -56,6 +75,8 @@ const DraftPattern = props => {
|
|||
return (
|
||||
<div className="fs-sa">
|
||||
<section>
|
||||
<h5>REMOVEME</h5>
|
||||
<pre>{JSON.stringify(props.svgExport, null, 2)}</pre>
|
||||
<h2>
|
||||
<FormattedMessage id="app.pattern" />
|
||||
</h2>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue