pitaya-launcher/js/components/launcher/app-list.js

48 lines
1.0 KiB
JavaScript
Raw Normal View History

2015-08-27 18:24:29 +02:00
var React = require('react');
var AppItem = require('./app-item.js');
2015-08-27 18:24:29 +02:00
module.exports = React.createClass({
2015-08-27 22:52:30 +02:00
propTypes: {
// The app items to display in the list
2015-08-27 22:52:30 +02:00
items: React.PropTypes.arrayOf(React.PropTypes.object).isRequired,
// the parent item path
2015-08-27 22:52:30 +02:00
parentPath: React.PropTypes.oneOfType([
React.PropTypes.string,
React.PropTypes.arrayOf(React.PropTypes.number)
]).isRequired,
// Item click handler
2015-08-27 22:52:30 +02:00
onItemClick: React.PropTypes.func.isRequired,
2015-08-27 22:52:30 +02:00
},
2015-08-27 18:24:29 +02:00
render: function() {
2015-08-27 22:52:30 +02:00
var parentPath = this.props.parentPath;
// For each items, we create an AppItem component
2015-08-27 22:52:30 +02:00
var items = (this.props.items).map(function(item, i) {
// The item path identifier
2015-08-27 22:52:30 +02:00
var path = parentPath+'.'+i;
2015-08-27 22:52:30 +02:00
return (
<AppItem key={path} itemPath={path} item={item} onItemClick={this.props.onItemClick} />
);
2015-08-27 22:52:30 +02:00
}.bind(this));
// Create the apps list
2015-08-27 18:24:29 +02:00
return (
2015-08-27 22:52:30 +02:00
<ul key={parentPath} className="apps-list">
{items}
2015-08-27 18:24:29 +02:00
</ul>
);
2015-08-27 22:52:30 +02:00
2015-08-27 18:24:29 +02:00
}
});