import { Button, Callout, H2, InputGroup, Intent, NonIdealState, Spinner } from "@blueprintjs/core"; import { IconNames } from "@blueprintjs/icons"; import { push } from "connected-react-router"; import { get, isEqual } from "lodash"; import React, { MouseEvent } from "react"; import { connect } from "react-redux"; import { Dispatch } from "redux"; import styled from "styled-components"; import { setResultHover, updateSearch } from "../../redux/actions"; import { IAppState, ISearchResultInstance } from "../../redux/types"; import { ISearchFilter } from "../../searchFilters"; import { isSmallScreen } from "../../util"; import { SearchResult } from "../molecules"; import { SearchFilters } from "../organisms"; interface ISearchBarContainerProps { hasSearchResults: boolean; hasError: boolean; } const SearchBarContainer = styled.div` width: 80%; text-align: center; margin: ${props => (props.hasSearchResults || props.hasError ? "0 auto" : "auto")}; align-self: center; `; const SearchResults = styled.div` width: 100%; display: flex; flex-direction: column; justify-items: center; `; const StyledSpinner = styled(Spinner)` margin-top: 10px; `; const CalloutContainer = styled.div` width: 90%; margin: 0 auto 20px auto; text-align: left; `; interface ISearchScreenProps { error: boolean; isLoadingResults: boolean; query: string; hasMoreResults: boolean; results: ISearchResultInstance[]; handleSearch: (query: string, filters: ISearchFilter[]) => void; navigateToInstance: (domain: string) => void; setIsHoveringOver: (domain?: string) => void; } interface ISearchScreenState { currentQuery: string; searchFilters: ISearchFilter[]; } class SearchScreen extends React.PureComponent { public constructor(props: ISearchScreenProps) { super(props); this.state = { currentQuery: "", searchFilters: [] }; } public componentDidMount() { if (this.props.query) { this.setState({ currentQuery: this.props.query }); } } public render() { const { error, hasMoreResults, results, isLoadingResults, query } = this.props; let content; if (error) { content = ; } else if (!isLoadingResults && query && results.length === 0) { content = ( ); } else if (!!results && results.length > 0) { content = ( {results.map(result => ( ))} {isLoadingResults && } {!isLoadingResults && hasMoreResults && ( )} ); } let rightSearchBarElement; if (isLoadingResults) { rightSearchBarElement = ; } else if (query || error) { rightSearchBarElement = (