|
1 | 1 | import React, { KeyboardEvent, Component, ReactElement } from 'react';
|
2 | 2 | import { withRouter, RouteComponentProps } from 'react-router-dom';
|
| 3 | +import { css } from 'emotion'; |
3 | 4 |
|
4 | 5 | import { default as IconSearch } from '@material-ui/icons/Search';
|
5 | 6 | import InputAdornment from '@material-ui/core/InputAdornment';
|
@@ -50,6 +51,28 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
50 | 51 | this.requestList = [];
|
51 | 52 | }
|
52 | 53 |
|
| 54 | + public render(): ReactElement<HTMLElement> { |
| 55 | + const { suggestions, search, loaded, loading, error } = this.state; |
| 56 | + |
| 57 | + return ( |
| 58 | + <AutoComplete |
| 59 | + color={colors.white} |
| 60 | + onBlur={this.handleOnBlur} |
| 61 | + onChange={this.handleSearch} |
| 62 | + onCleanSuggestions={this.handlePackagesClearRequested} |
| 63 | + onClick={this.handleClickSearch} |
| 64 | + onSuggestionsFetch={debounce(this.handleFetchPackages, CONSTANTS.API_DELAY)} |
| 65 | + placeholder={CONSTANTS.PLACEHOLDER_TEXT} |
| 66 | + startAdornment={this.getAdorment()} |
| 67 | + suggestions={suggestions} |
| 68 | + suggestionsError={error} |
| 69 | + suggestionsLoaded={loaded} |
| 70 | + suggestionsLoading={loading} |
| 71 | + value={search} |
| 72 | + /> |
| 73 | + ); |
| 74 | + } |
| 75 | + |
53 | 76 | /**
|
54 | 77 | * Cancel all the requests which are in pending state.
|
55 | 78 | */
|
@@ -146,33 +169,15 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
|
146 | 169 | }
|
147 | 170 | };
|
148 | 171 |
|
149 |
| - public render(): ReactElement<HTMLElement> { |
150 |
| - const { suggestions, search, loaded, loading, error } = this.state; |
151 |
| - |
152 |
| - return ( |
153 |
| - <AutoComplete |
154 |
| - color={colors.white} |
155 |
| - onBlur={this.handleOnBlur} |
156 |
| - onChange={this.handleSearch} |
157 |
| - onCleanSuggestions={this.handlePackagesClearRequested} |
158 |
| - onClick={this.handleClickSearch} |
159 |
| - onSuggestionsFetch={debounce(this.handleFetchPackages, CONSTANTS.API_DELAY)} |
160 |
| - placeholder={CONSTANTS.PLACEHOLDER_TEXT} |
161 |
| - startAdornment={this.getAdorment()} |
162 |
| - suggestions={suggestions} |
163 |
| - suggestionsError={error} |
164 |
| - suggestionsLoaded={loaded} |
165 |
| - suggestionsLoading={loading} |
166 |
| - value={search} |
167 |
| - /> |
168 |
| - ); |
169 |
| - } |
170 |
| - |
171 | 172 | private requestList: AbortControllerInterface[];
|
172 | 173 |
|
173 | 174 | public getAdorment(): JSX.Element {
|
174 | 175 | return (
|
175 |
| - <InputAdornment position={'start'} style={{ color: colors.white }}> |
| 176 | + <InputAdornment |
| 177 | + className={css` |
| 178 | + color: ${colors.white}; |
| 179 | + `} |
| 180 | + position={'start'}> |
176 | 181 | <IconSearch />
|
177 | 182 | </InputAdornment>
|
178 | 183 | );
|
|
0 commit comments