pitaya-launcher/js/components/desktop-app-item.jsx

49 lines
1.0 KiB
React
Raw Normal View History

2015-08-28 14:20:07 +02:00
var React = require('react');
var Util = require('../util');
var LazyLoad = require('./mixins/lazy-load');
2015-08-28 14:20:07 +02:00
module.exports = React.createClass({
mixins: [LazyLoad],
2015-08-28 14:20:07 +02:00
getInitialState: function() {
return { icon: 'img/hourglass.svg', loading: false };
},
onInViewport: function() {
if(!this.state.loading) {
this.setState({ loading: true });
var desktopEntry = this.props.desktopEntry;
this._findIcon(desktopEntry.Icon);
}
2015-08-28 14:20:07 +02:00
},
render: function() {
var desktopEntry = this.props.desktopEntry;
var label = desktopEntry.Name;
var category = desktopEntry.Categories;
return (
<li className="desktop-app">
<img src={this.state.icon} className="desktop-app-icon" />
2015-08-28 14:20:07 +02:00
<span className="desktop-app-label">{label}</span>
</li>
);
},
_findIcon: function(iconPath) {
var self = this;
2015-08-28 14:20:07 +02:00
Util.DesktopApps.findIcon(iconPath || 'application-default-icon')
2015-08-28 14:20:07 +02:00
.then(function(iconPath) {
self.setState({ icon: iconPath });
})
2015-08-28 14:20:07 +02:00
;
}
});