11import React , { Component } from 'react' ;
22import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider' ;
3- import { TextField , List , ListItem , Divider } from 'material-ui'
43
54import { observer } from 'mobx-react' ;
65
@@ -10,40 +9,20 @@ import {observer} from 'mobx-react';
109import injectTapEventPlugin from 'react-tap-event-plugin' ;
1110injectTapEventPlugin ( ) ;
1211
12+ import SearchInput from './SearchInput' ;
13+ import SearchResults from './SearchResults' ;
14+
1315export default observer ( class App extends Component {
1416 static propTypes = {
1517 colors : React . PropTypes . object . isRequired
1618 } ;
1719
18- handleKeyDown = ( event ) => {
19- const ENTER_KEY = 13 ;
20- if ( event . keyCode === ENTER_KEY ) {
21- event . preventDefault ( ) ;
22- this . props . colors . search ( ) ;
23- }
24- } ;
25-
2620 render ( ) {
27- const listItems = this . props . colors . results . map ( ( color , index ) => {
28- return (
29- < div key = { `color-div-${ index } ` } >
30- < ListItem key = { `color-${ index } ` } primaryText = { color . name } style = { { backgroundColor : color . hex } } />
31- < Divider key = { `divider-${ index } ` } />
32- </ div >
33- ) ;
34- } ) ;
3521 return (
3622 < MuiThemeProvider >
3723 < div >
38- < TextField hintText = "Search..."
39- floatingLabelFixed = { true }
40- fullWidth = { true }
41- value = { this . props . colors . query }
42- onChange = { ( event , value ) => this . props . colors . updateQuery ( value ) }
43- onKeyDown = { this . handleKeyDown } />
44- < List >
45- { listItems }
46- </ List >
24+ < SearchInput colors = { this . props . colors } />
25+ < SearchResults colors = { this . props . colors } />
4726 </ div >
4827 </ MuiThemeProvider >
4928 ) ;
0 commit comments