complete ClipPath refactor

This commit is contained in:
Horcrux
2016-07-20 14:44:19 +08:00
parent dd6cb80e84
commit 18e1b60823
30 changed files with 254 additions and 251 deletions

View File

@@ -1,12 +1,17 @@
import React, {Component, PropTypes} from 'react';
import Path from './Path';
import {pathProps} from '../lib/props';
import _ from 'lodash';
class Polygon extends Component{
static displayName = 'Polygon';
static propTypes = {
...pathProps,
points: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
points: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).isRequired
};
static defaultProps = {
points: ''
};
setNativeProps = (...args) => {
@@ -14,10 +19,15 @@ class Polygon extends Component{
};
render() {
let points = this.props.points;
if (_.isArray(points)) {
points = points.join(',');
}
return <Path
ref={ele => this.root = ele}
{...this.props}
d={`M${this.props.points.trim().replace(/\s+/g, 'L')}z`}
d={`M${points.trim().replace(/\s+/g, 'L')}z`}
/>;
}
}