1
0
Fork 0

🚧 Progress on workbench

This commit is contained in:
Joost De Cock 2019-05-06 17:01:44 +02:00
parent 158c19ae1d
commit a888922968
31 changed files with 716 additions and 153 deletions
packages/components/src/Draft/Defs

View file

@ -1,9 +1,37 @@
import React, { useState } from "react";
import PropTypes from "prop-types";
import React from "react";
import Markers from "./Markers";
import Snippets from "./Snippets";
import Grid from "./Grid";
const Defs = props => <defs>{props.defs}</defs>;
Defs.propTypes = { defs: PropTypes.string };
Defs.defaultProps = { defs: "" };
const Defs = props => {
let paperlessGrids = null;
if (props.paperless) {
paperlessGrids = [];
for (let p in props.parts) {
let anchor = { x: 0, y: 0 };
if (typeof props.parts[p].points.gridAnchor !== "undefined")
anchor = props.parts[p].points.gridAnchor;
else if (typeof props.parts[p].points.anchor !== "undefined")
anchor = props.parts[p].points.anchor;
paperlessGrids.push(
<pattern
id={"grid-" + p}
key={"grid-" + p}
xlinkHref="#grid"
x={anchor.x}
y={anchor.y}
/>
);
}
}
return (
<defs>
<Markers />
<Snippets />
<Grid units={props.units} />
{paperlessGrids}
</defs>
);
};
export default Defs;