-
Notifications
You must be signed in to change notification settings - Fork 480
/
PlanterCellEditor.jsx
38 lines (33 loc) · 1.01 KB
/
PlanterCellEditor.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
/**
* @overview React component to allow for easy editing and creation of PlanterCells
* @see @code-dot-org/maze/src/harvesterCell
*/
import React from 'react';
import CellEditor from './CellEditor';
import { cells, tiles } from '@code-dot-org/maze';
const PlanterCell = cells.PlanterCell;
const SquareType = tiles.SquareType;
export default class PlanterCellEditor extends CellEditor {
/**
* @override
*/
getSelectFieldNames() {
return ['tileType', 'featureType'];
}
/**
* @override
*/
renderFields(values) {
return (
<div>
{this.renderTileTypes(values)}
<label htmlFor="featureType">Feature Type:</label>
<select name="featureType" value={values.featureType} disabled={this.props.cell.getTile() !== SquareType.OPEN} onChange={this.handleChange}>
{Object.keys(PlanterCell.FeatureType).map(type => (
<option key={type} value={PlanterCell.FeatureType[type]}>{type.toLowerCase()}</option>
))}
</select>
</div>
);
}
}