diff --git a/src/components/SearchAttributes/SearchAttributes.css b/src/components/SearchAttributes/SearchAttributes.css new file mode 100644 index 00000000..ee2e0c3b --- /dev/null +++ b/src/components/SearchAttributes/SearchAttributes.css @@ -0,0 +1,52 @@ +@import '../../marketplace.css'; + +.searchResultSummary { + display: none; + + @media (--viewportMedium) { + display: block; + margin: 8px 24px 14px 24px; + } + + @media (--viewportLarge) { + margin: 8px 36px 14px 36px; + } +} + +.searchResultSummaryMobile { + display: flex; + justify-content: space-between; + + background-color: var(--matterColorBright); + width: 100vw; + padding: 1px 24px 14px 24px; + + /* sticky result summary in mobile */ + position: sticky; + top: 0; + z-index: 9; + + @media (--viewportMedium) { + display: none; + } +} + +.mapIcon { + /* Font */ + @apply --marketplaceTinyFontStyles; + font-weight: var(--fontWeightBold); + + /* background map image */ + background-image: url(./images/map_icon@2x.png); + background-size: cover; + + border-radius: 3px; + width: 72px; + height: 35px; + margin-top: 23px; + padding: 9px 22px; +} + +.error { + color: var(--failColor); +} diff --git a/src/components/SearchAttributes/SearchAttributes.js b/src/components/SearchAttributes/SearchAttributes.js new file mode 100644 index 00000000..952c48c4 --- /dev/null +++ b/src/components/SearchAttributes/SearchAttributes.js @@ -0,0 +1,66 @@ +import React from 'react'; +import { FormattedMessage } from 'react-intl'; + +import css from './SearchAttributes.css'; + +const SearchAttributes = props => { + const { listingsAreLoaded, resultsCount, searchInProgress, searchListingsError, onMapIconClick} = props; + + const searchError = ( +

+ +

+ ); + + const loadingResults = ( +

+ +

+ ); + + const resultsFound = ( +

+ +

+ ); + + const noResults = ( +

+ +

+ ); + + const resultsFoundMobile = ( +

+ +

+ ); + + return ( +
+
+ {searchListingsError ? searchError : null} + {listingsAreLoaded && resultsCount > 0 ? resultsFound : null} + {listingsAreLoaded && resultsCount === 0 ? noResults : null} + {searchInProgress ? loadingResults : null} +
+ +
+
+ {searchListingsError ? searchError : null} + {listingsAreLoaded && resultsCount > 0 ? resultsFoundMobile : null} + {listingsAreLoaded && resultsCount === 0 ? noResults : null} + {searchInProgress ? loadingResults : null} +
+
+ +
+
+
+ ); +}; + +export default SearchAttributes; diff --git a/src/containers/SearchPage/images/map_icon@2x.png b/src/components/SearchAttributes/images/map_icon@2x.png similarity index 100% rename from src/containers/SearchPage/images/map_icon@2x.png rename to src/components/SearchAttributes/images/map_icon@2x.png diff --git a/src/components/index.js b/src/components/index.js index b98aa345..1d1d1dc1 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -85,6 +85,7 @@ export { default as ResponsiveImage } from './ResponsiveImage/ResponsiveImage'; export { default as ReviewModal } from './ReviewModal/ReviewModal'; export { default as ReviewRating } from './ReviewRating/ReviewRating'; export { default as Reviews } from './Reviews/Reviews'; +export { default as SearchAttributes } from './SearchAttributes/SearchAttributes'; export { default as SearchMap } from './SearchMap/SearchMap'; export { default as SearchMapGroupLabel } from './SearchMapGroupLabel/SearchMapGroupLabel'; export { default as SearchMapInfoCard } from './SearchMapInfoCard/SearchMapInfoCard'; diff --git a/src/containers/SearchPage/SearchPage.css b/src/containers/SearchPage/SearchPage.css index ebad339d..1dce18ee 100644 --- a/src/containers/SearchPage/SearchPage.css +++ b/src/containers/SearchPage/SearchPage.css @@ -45,57 +45,6 @@ } } -.searchResultSummary { - display: none; - - @media (--viewportMedium) { - display: block; - margin: 8px 24px 14px 24px; - } - - @media (--viewportLarge) { - margin: 8px 36px 14px 36px; - } -} - -.searchResultSummaryMobile { - display: flex; - justify-content: space-between; - - background-color: var(--matterColorBright); - width: 100vw; - padding: 1px 24px 14px 24px; - - /* sticky result summary in mobile */ - position: sticky; - top: 0; - z-index: 9; - - @media (--viewportMedium) { - display: none; - } -} - -.mapIcon { - /* Font */ - @apply --marketplaceTinyFontStyles; - font-weight: var(--fontWeightBold); - - /* background map image */ - background-image: url(./images/map_icon@2x.png); - background-size: cover; - - border-radius: 3px; - width: 72px; - height: 35px; - margin-top: 23px; - padding: 9px 22px; -} - -.error { - color: var(--failColor); -} - .searchString { /* Search string should not break on white spaces - i.e. line-break should happen before. */ white-space: nowrap; diff --git a/src/containers/SearchPage/SearchPage.js b/src/containers/SearchPage/SearchPage.js index 6dafdc68..452a2244 100644 --- a/src/containers/SearchPage/SearchPage.js +++ b/src/containers/SearchPage/SearchPage.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { FormattedMessage, injectIntl, intlShape } from 'react-intl'; +import { injectIntl, intlShape } from 'react-intl'; import { connect } from 'react-redux'; import { compose } from 'redux'; import { withRouter } from 'react-router-dom'; @@ -19,7 +19,13 @@ import { createSlug, parse, stringify } from '../../util/urlHelpers'; import * as propTypes from '../../util/propTypes'; import { getListingsById } from '../../ducks/marketplaceData.duck'; import { manageDisableScrolling, isScrollingDisabled } from '../../ducks/UI.duck'; -import { SearchMap, ModalInMobile, Page, SearchResultsPanel } from '../../components'; +import { + SearchMap, + ModalInMobile, + Page, + SearchResultsPanel, + SearchAttributes, +} from '../../components'; import { TopbarContainer } from '../../containers'; import { searchListings, searchMapListings } from './SearchPage.duck'; @@ -172,48 +178,6 @@ export class SearchPageComponent extends Component { const totalItems = searchParamsMatch && hasPaginationInfo ? pagination.totalItems : 0; const listingsAreLoaded = !searchInProgress && searchParamsMatch && hasPaginationInfo; - const searchError = ( -

- -

- ); - - const resultsFoundNoAddress = ( -

- -

- ); - const addressNode = address ? ( - {searchInURL.address.split(', ')[0]} - ) : null; - const resultsFoundWithAddress = ( -

- -

- ); - const resultsFound = address && !mapSearch ? resultsFoundWithAddress : resultsFoundNoAddress; - - const resultsFoundMobile = ( -

- -

- ); - - const noResults = ( -

- -

- ); - - const loadingResults = ( -

- -

- ); - const searchMap = ( { + this.useLocationSearchBounds = true; + this.modalOpenedBoundsChange = true; + this.setState({ isSearchMapOpenOnMobile: true }); + }; + + // N.B. openMobileMap button is sticky. // For some reason, stickyness doesn't work on Safari, if the element is