From 4a35fd73d2e61e5ace0f6aee1ffd90cfccaa586c Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 30 Jun 2020 15:24:30 +0200 Subject: [PATCH] make the search work --- .storybook/webpack.config.js | 5 + package-lock.json | 53 +++++++- package.json | 1 + src/components/molecules/SearchBar.module.css | 48 ++----- src/components/molecules/SearchBar.tsx | 7 +- .../molecules/SearchPriceFilter.module.css | 4 - .../molecules/SearchPriceFilter.tsx | 21 ++- src/components/templates/Search.tsx | 123 ++++++++++++++---- src/hooks/usePriceQueryParams.tsx | 5 +- src/pages/search.tsx | 73 +---------- 10 files changed, 183 insertions(+), 157 deletions(-) diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 1dd8896df..ea7568e39 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -65,6 +65,11 @@ module.exports = ({ config }) => { config.resolve.extensions.push('.ts', '.tsx') + // 'fs' fix for squid.js + config.node = { + fs: 'empty' + } + // Handle SVGs // Don't use Storybook's default SVG Configuration config.module.rules = config.module.rules.map((rule) => { diff --git a/package-lock.json b/package-lock.json index 7be76e031..84e615740 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14100,6 +14100,18 @@ "prepend-http": "^2.0.0", "query-string": "^5.0.1", "sort-keys": "^2.0.0" + }, + "dependencies": { + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "requires": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + } } }, "p-cancelable": { @@ -23978,6 +23990,18 @@ "prepend-http": "^2.0.0", "query-string": "^5.0.1", "sort-keys": "^2.0.0" + }, + "dependencies": { + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "requires": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + } } }, "p-cancelable": { @@ -36070,13 +36094,20 @@ "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" }, "query-string": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", - "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-6.13.1.tgz", + "integrity": "sha512-RfoButmcK+yCta1+FuU8REvisx1oEzhMKwhLUNcepQTPGcNMp1sIqjnfCtfnvGSQZQEhaBHvccujtWoUV3TTbA==", "requires": { "decode-uri-component": "^0.2.0", - "object-assign": "^4.1.0", - "strict-uri-encode": "^1.0.0" + "split-on-first": "^1.0.0", + "strict-uri-encode": "^2.0.0" + }, + "dependencies": { + "strict-uri-encode": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-2.0.0.tgz", + "integrity": "sha1-ucczDHBChi9rFC3CdLvMWGbONUY=" + } } }, "querystring": { @@ -44017,6 +44048,18 @@ "timed-out": "^4.0.1", "url-set-query": "^1.0.0", "xhr": "^2.0.4" + }, + "dependencies": { + "query-string": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz", + "integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==", + "requires": { + "decode-uri-component": "^0.2.0", + "object-assign": "^4.1.0", + "strict-uri-encode": "^1.0.0" + } + } } }, "xhr-request-promise": { diff --git a/package.json b/package.json index 051bd6f3f..9185d3a5b 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "intersection-observer": "^0.11.0", "is-url-superb": "^4.0.0", "numeral": "^2.0.6", + "query-string": "^6.13.1", "react": "^16.13.1", "react-data-table-component": "^6.9.3", "react-datepicker": "^3.0.0", diff --git a/src/components/molecules/SearchBar.module.css b/src/components/molecules/SearchBar.module.css index 26cf4907e..8ee36fe6b 100644 --- a/src/components/molecules/SearchBar.module.css +++ b/src/components/molecules/SearchBar.module.css @@ -2,7 +2,15 @@ margin-bottom: var(--spacer); } -.inputGroup .input { +.inputGroup > div { + margin: 0; +} + +.inputGroup label { + display: none; +} + +.inputGroup input { border-bottom-left-radius: 0; border-bottom-right-radius: 0; } @@ -12,44 +20,23 @@ border-top-right-radius: 0; margin-top: -1px; width: 100%; - border-width: 1px; - text-transform: uppercase; - color: var(--brand-grey-lighter); - background: var(--brand-gradient); - box-shadow: none; } .inputGroup button:hover, .inputGroup button:focus, -.inputGroup .input:focus + button:hover, -.inputGroup .input:focus + button:focus { +.inputGroup input:focus + button:hover, +.inputGroup input:focus + button:focus { background: var(--brand-gradient); transform: none; box-shadow: none; } -.inputGroup .input:focus + button { - color: var(--brand-white); -} - -/* .inputGroup button:hover, -.inputGroup button:focus, -.inputGroup .input:focus + button { - color: var(--brand-white); - background-color: var(--brand-pink); -} - -.inputGroup .input:focus + button { - border-color: var(--brand-pink); - background-color: var(--brand-pink); -} */ - @media screen and (min-width: 30rem) { .inputGroup { display: flex; } - .inputGroup .input { + .inputGroup input { border-bottom-left-radius: var(--border-radius); border-top-right-radius: 0; border-bottom-right-radius: 0; @@ -64,14 +51,3 @@ width: auto; } } - -.input { - composes: input from './Form/FieldTemplate.module.css'; -} - -.large { - composes: large from './Form/FieldTemplate.module.css'; -} - -.filters { -} diff --git a/src/components/molecules/SearchBar.tsx b/src/components/molecules/SearchBar.tsx index 9f7f40650..ec6211312 100644 --- a/src/components/molecules/SearchBar.tsx +++ b/src/components/molecules/SearchBar.tsx @@ -3,6 +3,7 @@ import { useNavigate } from '@reach/router' import styles from './SearchBar.module.css' import Loader from '../atoms/Loader' import Button from '../atoms/Button' +import Input from '../atoms/Input' export default function SearchBar({ placeholder, @@ -35,12 +36,12 @@ export default function SearchBar({ return (
- handleChange(e)} + onChange={handleChange} required />