X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d38fcf4f5b9d8a1889b9bdf79ee77a2022ed4b52..a0e9ecd6a913a6465b500f642412daf1e1a6420b:/src/views-components/search-bar/search-bar-view.tsx diff --git a/src/views-components/search-bar/search-bar-view.tsx b/src/views-components/search-bar/search-bar-view.tsx index e7067f5b42..b2575a8f5f 100644 --- a/src/views-components/search-bar/search-bar-view.tsx +++ b/src/views-components/search-bar/search-bar-view.tsx @@ -20,15 +20,21 @@ import { SearchView } from '~/store/search-bar/search-bar-reducer'; import { SearchBarBasicView } from '~/views-components/search-bar/search-bar-basic-view'; import { SearchBarAdvancedView } from '~/views-components/search-bar/search-bar-advanced-view'; import { SearchBarAutocompleteView, SearchBarAutocompleteViewDataProps } from '~/views-components/search-bar/search-bar-autocomplete-view'; +import { ArvadosTheme } from '~/common/custom-theme'; -type CssRules = 'container' | 'input' | 'searchBar'; +type CssRules = 'container' | 'containerSearchViewOpened' | 'input' | 'searchBar'; -const styles: StyleRulesCallback = theme => { +const styles: StyleRulesCallback = (theme: ArvadosTheme) => { return { container: { position: 'relative', width: '100%', - borderRadius: '0px' + borderRadius: theme.spacing.unit / 4 + }, + containerSearchViewOpened: { + position: 'relative', + width: '100%', + borderRadius: `${theme.spacing.unit / 4}px ${theme.spacing.unit / 4}px 0 0` }, input: { border: 'none', @@ -41,7 +47,7 @@ const styles: StyleRulesCallback = theme => { }; type SearchBarDataProps = { - value: string; + searchValue: string; currentView: string; open: boolean; } & SearchBarAutocompleteViewDataProps; @@ -52,6 +58,8 @@ interface SearchBarActionProps { onSetView: (currentView: string) => void; openView: () => void; closeView: () => void; + saveQuery: (query: string) => void; + loadQueries: () => string[]; } type SearchBarProps = SearchBarDataProps & SearchBarActionProps & WithStyles; @@ -61,7 +69,7 @@ interface SearchBarState { } interface RenderQueriesProps { - text: string; + text: string | JSX.Element; } export const RecentQueriesItem = (props: RenderQueriesProps) => { @@ -97,7 +105,7 @@ export const SearchBarView = withStyles(styles)( render() { const { classes, currentView, openView, closeView, open } = this.props; return closeView()}> - +
{ switch (currentView) { case SearchView.BASIC: - return ; + return ; case SearchView.ADVANCED: return ; case SearchView.AUTOCOMPLETE: - return ; + return ; default: - return ; + return ; } } handleSubmit = (event: React.FormEvent) => { event.preventDefault(); clearTimeout(this.timeout); + this.props.saveQuery(this.state.value); this.props.onSearch(this.state.value); + this.props.loadQueries(); } handleChange = (event: React.ChangeEvent) => {