Skip to content

Commit

Permalink
simplified table component
Browse files Browse the repository at this point in the history
  • Loading branch information
zackify committed Sep 5, 2015
1 parent a5271f9 commit d4c2bbd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
12 changes: 8 additions & 4 deletions lib/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_ag

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }

function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
Expand Down Expand Up @@ -38,14 +40,16 @@ var Table = (function (_React$Component) {
_createClass(Table, [{
key: 'render',
value: function render() {
var attributes = Object.assign({}, this.props);
delete attributes.rows;
var _props = this.props;
var rows = _props.rows;

var attributes = _objectWithoutProperties(_props, ['rows']);

return _react2['default'].createElement(
'table',
attributes,
_react2['default'].createElement(_head2['default'], { row: this.props.rows[0] }),
_react2['default'].createElement(_rows2['default'], { rows: this.props.rows })
_react2['default'].createElement(_head2['default'], { row: rows[0] }),
_react2['default'].createElement(_rows2['default'], { rows: rows })
);
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-legit-table",
"version": "0.0.6",
"version": "0.1.0",
"description": "the simplest table component out there",
"main": "lib/index.js",
"scripts": {
Expand Down
7 changes: 3 additions & 4 deletions src/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import Rows from './rows'

export default class Table extends React.Component{
render(){
let attributes = Object.assign({}, this.props)
delete attributes.rows
let { rows, ...attributes } = this.props

return (
<table {...attributes}>
<Head row={this.props.rows[0]} />
<Rows rows={this.props.rows} />
<Head row={rows[0]} />
<Rows rows={rows} />
</table>
)
}
Expand Down

0 comments on commit d4c2bbd

Please sign in to comment.