ant-design/components/layout/col.jsx

31 lines
862 B
React
Raw Normal View History

2016-02-25 16:48:03 +08:00
import React, { PropTypes } from 'react';
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() {
const { span, order, offset, push, pull, className, ...others } = this.props;
const classes = classNames({
[`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,
});
return <div {...others} className={classes}>{ this.props.children }</div>;
2015-10-27 23:52:17 +08:00
},
});
export default Col;