2016-02-25 16:48:03 +08:00
|
|
|
import React, { PropTypes } from 'react';
|
2015-11-24 20:03:57 +08:00
|
|
|
import classNames from 'classnames';
|
2015-10-27 23:52:17 +08:00
|
|
|
|
2016-02-25 16:48:03 +08:00
|
|
|
const stringOrNumber = PropTypes.oneOfType([PropTypes.string, PropTypes.number]);
|
|
|
|
|
2015-10-27 23:52:17 +08:00
|
|
|
const Col = React.createClass({
|
|
|
|
propTypes: {
|
2016-02-25 16:48:03 +08:00
|
|
|
span: stringOrNumber,
|
|
|
|
order: stringOrNumber,
|
|
|
|
offset: stringOrNumber,
|
|
|
|
push: stringOrNumber,
|
|
|
|
pull: stringOrNumber,
|
|
|
|
className: PropTypes.string,
|
|
|
|
children: PropTypes.node,
|
2015-10-27 23:52:17 +08:00
|
|
|
},
|
|
|
|
render() {
|
2016-01-07 17:46:46 +08:00
|
|
|
const { span, order, offset, push, pull, className, ...others } = this.props;
|
2015-11-24 20:03:57 +08:00
|
|
|
const classes = classNames({
|
2016-02-17 18:04:42 +08:00
|
|
|
[`col-${span}`]: span,
|
|
|
|
[`col-order-${order}`]: order,
|
|
|
|
[`col-offset-${offset}`]: offset,
|
|
|
|
[`col-push-${push}`]: push,
|
|
|
|
[`col-pull-${pull}`]: pull,
|
2016-02-25 16:48:03 +08:00
|
|
|
[className]: !!className,
|
2015-10-28 18:04:56 +08:00
|
|
|
});
|
|
|
|
return <div {...others} className={classes}>{ this.props.children }</div>;
|
2015-10-27 23:52:17 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Col;
|