@@ -9,25 +9,44 @@ class ModeSelector extends Component {
9
9
location : PropTypes . object ,
10
10
label : PropTypes . string ,
11
11
setLocation : PropTypes . func ,
12
+ showLabel : PropTypes . boolean ,
12
13
type : PropTypes . string // replace with locationType?
13
14
}
15
+
14
16
_onChange = ( evt ) => {
15
17
console . log ( evt . target . value )
16
18
this . props . setMode ( evt . target . value )
17
19
}
20
+
21
+ _getDisplayText ( mode ) {
22
+ switch ( mode ) {
23
+ case 'TRANSIT,WALK' : return 'Walk to Transit'
24
+ case 'TRANSIT,BICYCLE' : return 'Bike to Transit'
25
+ case 'WALK' : return 'Walk Only'
26
+ case 'BICYCLE' : return 'Bike Only'
27
+ }
28
+ return mode
29
+ }
30
+
18
31
render ( ) {
19
32
const { config, mode } = this . props
33
+ const label = this . props . label || 'Mode:'
34
+ const showLabel = this . props . showLabel === undefined ? true : this . props . showLabel
35
+
20
36
return (
21
37
< form >
22
- < FormGroup >
23
- < ControlLabel > Mode:</ ControlLabel >
38
+ < FormGroup className = 'mode-selector' >
39
+ { showLabel
40
+ ? < ControlLabel > { label } </ ControlLabel >
41
+ : null
42
+ }
24
43
< FormControl
25
44
componentClass = 'select'
26
45
value = { mode }
27
46
onChange = { this . _onChange }
28
47
>
29
48
{ config . modes . map ( ( m , i ) => (
30
- < option key = { i } value = { m } > { m } </ option >
49
+ < option key = { i } value = { m } > { this . _getDisplayText ( m ) } </ option >
31
50
) ) }
32
51
</ FormControl >
33
52
</ FormGroup >
0 commit comments