Merge pull request #1237 from waywardmonkeys/more-es2015-classes

Convert Popover & Spin to ES2015 classes.
This commit is contained in:
afc163 2016-03-20 23:49:49 +08:00
commit 79bfb5a993
2 changed files with 25 additions and 33 deletions

View File

@ -5,18 +5,7 @@ import getPlacements from './placements';
const placements = getPlacements(); const placements = getPlacements();
const prefixCls = 'ant-popover'; const prefixCls = 'ant-popover';
const Popover = React.createClass({ export default class Popover extends React.Component {
getDefaultProps() {
return {
prefixCls,
placement: 'top',
trigger: 'hover',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
overlayStyle: {}
};
},
render() { render() {
const transitionName = ({ const transitionName = ({
top: 'zoom-down', top: 'zoom-down',
@ -42,11 +31,11 @@ const Popover = React.createClass({
{this.props.children} {this.props.children}
</Tooltip> </Tooltip>
); );
}, }
getPopupDomNode() { getPopupDomNode() {
return this.refs.tooltip.getPopupDomNode(); return this.refs.tooltip.getPopupDomNode();
}, }
getOverlay() { getOverlay() {
return ( return (
@ -57,7 +46,14 @@ const Popover = React.createClass({
</div> </div>
</div> </div>
); );
}, }
}); }
export default Popover; Popover.defaultProps = {
prefixCls,
placement: 'top',
trigger: 'hover',
mouseEnterDelay: 0.1,
mouseLeaveDelay: 0.1,
overlayStyle: {}
};

View File

@ -2,22 +2,10 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { isCssAnimationSupported } from 'css-animation'; import { isCssAnimationSupported } from 'css-animation';
const AntSpin = React.createClass({ export default class Spin extends React.Component {
getDefaultProps() {
return {
prefixCls: 'ant-spin',
spining: true,
};
},
propTypes: {
className: React.PropTypes.string,
size: React.PropTypes.oneOf(['small', 'default', 'large']),
},
isNestedPattern() { isNestedPattern() {
return !!(this.props && this.props.children); return !!(this.props && this.props.children);
}, }
render() { render() {
const { className, size, prefixCls, tip } = this.props; const { className, size, prefixCls, tip } = this.props;
@ -56,6 +44,14 @@ const AntSpin = React.createClass({
} }
return spinElement; return spinElement;
} }
}); }
export default AntSpin; Spin.defaultProps = {
prefixCls: 'ant-spin',
spining: true,
};
Spin.propTypes = {
className: React.PropTypes.string,
size: React.PropTypes.oneOf(['small', 'default', 'large']),
};