Skip to content

Commit

Permalink
Change toolbar components to use props.children instead of arrays of …
Browse files Browse the repository at this point in the history
…js objects as props
  • Loading branch information
jtollerene committed Nov 13, 2014
1 parent f2e7139 commit c1109f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 64 deletions.
53 changes: 3 additions & 50 deletions src/js/toolbar-group.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,23 @@ var React = require('react');
var ToolbarGroup = React.createClass({

propTypes: {
float: React.PropTypes.string,
groupItems: React.PropTypes.array
float: React.PropTypes.string
},

mixins: [Classable],

getInitialState: function() {
return {
}
},

getDefaultProps: function() {
return {
};
},

render: function() {

var classes = this.getClasses('mui-toolbar-group', {
'mui-left': this.props.float === 'left',
'mui-right': this.props.float === 'right'
})
});

return (
<div className={classes}>
{this._getChildren()}
{this.props.children}
</div>
);
},

_getChildren: function() {
var children = [],
item,
itemComponent;

for (var i=0; i < this.props.groupItems.length; i++) {
item = this.props.groupItems[i];

switch (item.type) {

case 'separator':
itemComponent = (
<span className="mui-toolbar-separator">
&nbsp;
</span>
);
break;

case 'title':
itemComponent = (
<span className="mui-toolbar-title">
{item.title}
</span>
);
break;

default:
itemComponent = item;
}

children.push(itemComponent);
}

return children;
}

});
Expand Down
16 changes: 2 additions & 14 deletions src/js/toolbar.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/** @jsx React.DOM */

var Classable = require('./mixins/classable.js');
var Paper = require('./paper.jsx');
var React = require('react');
var ToolbarGroup = require('./toolbar-group.jsx');

var Toolbar = React.createClass({

Expand All @@ -13,23 +11,13 @@ var Toolbar = React.createClass({

mixins: [Classable],

getInitialState: function() {
return {
}
},

getDefaultProps: function() {
return {
};
},

render: function() {
var classes = this.getClasses('mui-toolbar', {
})
});

return (
<div className={classes}>
{this._getChildren()}
{this.props.children}
</div>
);
},
Expand Down

0 comments on commit c1109f5

Please sign in to comment.