pitaya-launcher/js/components/edit/icon-theme-selector.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-08-31 23:08:56 +02:00
var React = require('react');
var Util = require('../../util');
2015-08-31 23:08:56 +02:00
module.exports = React.createClass({
propsType: {
onThemeSelected: React.PropTypes.func.isRequired,
},
getInitialState: function() {
return { selectedTheme: null, availableThemes: [] };
},
componentDidMount: function() {
Util.DesktopApps.findIconThemes()
.then(function(themes) {
this.setState({ availableThemes: themes });
}.bind(this))
;
},
onChange: function(evt) {
var selectedTheme = evt.target.value;
this.setState({ selectedTheme: selectedTheme });
this.props.onThemeSelected(selectedTheme);
},
render: function() {
var selectedTheme = this.state.selectedTheme;
var options = this.state.availableThemes.map(function(theme) {
return (
<option key={theme} value={theme}>{theme}</option>
);
});
options.unshift(
<option key="__none__"></option>
);
2015-08-31 23:08:56 +02:00
return (
2015-09-11 16:25:45 +02:00
<div className="icon-theme-selector">
<select className="form-control" value={selectedTheme} onChange={this.onChange}>
{options}
</select>
</div>
2015-08-31 23:08:56 +02:00
);
}
});