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:
parent
4833f1a4c0
commit
a833496e04
33 changed files with 415 additions and 475 deletions
32
packages/components/src/Draft/Snippet/index.js
Normal file
32
packages/components/src/Draft/Snippet/index.js
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue