forked from clarabstract/factorio-calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
input.jsx
53 lines (50 loc) · 1.7 KB
/
input.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* global React,App*/
App.Input = class Input extends React.Component {
componentWillMount() {
this.recipes = App.getData.call();
}
render() {
var self = this;
var onChangeRecipe = function(event) {
self.props.onChange({recipe: event.target.value, ipm: self.props.input.ipm});
};
var onChangeIpm = function(event) {
self.props.onChange({recipe: self.props.input.recipe, ipm: parseFloat(event.target.value)});
};
return (
<div>
<p>
Calculate the requirements for
<input
id="recipe"
type="text"
list="recipes"
placeholder="recipe name"
value={this.props.input.recipe}
onChange={onChangeRecipe}/>
<datalist id="recipes">
{ Object.entries(this.recipes)
.filter(function([recipeName, recipe]) {
return recipe.hidden !== true
})
.map(function([recipeName, recipe]) {
return <option key={recipeName}>{recipeName}</option>;
}) }
</datalist>
producing at a rate of
<input
id="ipm"
type="number"
min="0"
step="any"
value={this.props.input.ipm}
onChange={onChangeIpm}/>
item(s) / minute.
<button id="addAnother" onClick={ this.props.onAddAnother }>Add Another</button>
<button id="clear" onClick={ this.props.onClear }>Clear</button>
<button id="bulk" onClick={ this.props.onBulk }>Bulk</button>
</p>
</div>
);
}
};