1
0
Fork 0

chore(components): Renamed Render to Draft

Note that this was already exported as Draft, and the Draft folder
was a symlink to Render. Now it's just called Draft.
This commit is contained in:
Joost De Cock 2020-04-18 18:14:09 +02:00
parent 4833f1a4c0
commit a833496e04
33 changed files with 415 additions and 475 deletions

View file

@ -0,0 +1,32 @@
import React from 'react'
import PropTypes from 'prop-types'
import { getProps } from '../utils'
const Snippet = (props) => {
const snippetProps = {
xlinkHref: '#' + props.snippet.def,
x: props.snippet.anchor.x,
y: props.snippet.anchor.y
}
let scale = props.snippet.attributes.get('data-scale')
let rotate = props.snippet.attributes.get('data-rotate')
if (scale || rotate) {
snippetProps.transform = ''
if (scale) {
snippetProps.transform += `translate(${snippetProps.x}, ${snippetProps.y}) `
snippetProps.transform += `scale(${scale}) `
snippetProps.transform += `translate(${snippetProps.x * -1}, ${snippetProps.y * -1}) `
}
if (rotate) {
snippetProps.transform += `rotate(${rotate}, ${snippetProps.x}, ${snippetProps.y}) `
}
}
return <use {...snippetProps} {...getProps(props.snippet)} />
}
Snippet.propTypes = {
snippet: PropTypes.object.isRequired
}
export default Snippet