Skip to content

Instantly share code, notes, and snippets.

@psaia
Created May 11, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psaia/8287c76140221f247d61 to your computer and use it in GitHub Desktop.
Save psaia/8287c76140221f247d61 to your computer and use it in GitHub Desktop.
import React from 'react';
export default class Path extends React.Component {
constuctor(props) {
super(props);
this.state = {
d: props.d || props.initialD,
fill: props.fill || props.initialFill,
stroke: props.stroke || props.initialStroke,
className: props.className || props.initialClassName,
transform: props.transform || props.initialTransform,
'stroke-width': props.strokeWidth || props.initialStrokeWidth
};
}
render() {
return <path {...this.state} />;
}
}
Path.defaultProps = {
initialD: '',
initialFill: '#000000',
initialStroke: 'transparent',
initialStrokeWidth: 1,
initialClassName: 'path',
initialTransform: null
};
import React from 'react';
export default class SVG extends React.Component {
constuctor(props) {
super(props);
this.state = {
width: props.width || props.initialWidth,
height: props.height || props.initialHeight
};
}
render() {
return <svg {...this.state}>{this.props.children}</svg>;
}
}
SVG.defaultProps = {
initialWidth: 500,
initialHeight: 500
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment