From 66af3e9503de8e1cad2c2aca31fbcba78d96ce08 Mon Sep 17 00:00:00 2001 From: jack Date: Fri, 26 Apr 2019 19:16:29 -0400 Subject: [PATCH] Add search clearing --- site/src/components/Header.js | 27 +++++++++++++++++++++++--- site/src/templates/ReleaseTemplate.js | 5 ++--- site/src/templates/ReleasesTemplate.js | 5 ++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/site/src/components/Header.js b/site/src/components/Header.js index f923d40..9c67921 100644 --- a/site/src/components/Header.js +++ b/site/src/components/Header.js @@ -4,12 +4,13 @@ import { Close } from 'icons/Close' import { ExternalLink } from 'icons/ExternalLink' import React from 'react' import { onClose } from '../providers/WidgetProvider' +import { theme } from '../styles/theme' import { AnchorButton } from './Button/AnchorButton' import { Button } from './Button/Button' export const Header = ({ primaryColor: [red, green, blue], - onSearchChange, + setSearchValue, logoSrc, homepage, htmlUrl, @@ -63,6 +64,7 @@ export const Header = ({ borderRadius: 34, flexGrow: 1, marginLeft: '0.5rem', + position: 'relative', }} > setSearchValue(value)} /> + {searchValue && ( + + )} {isWidget ? ( diff --git a/site/src/templates/ReleaseTemplate.js b/site/src/templates/ReleaseTemplate.js index 630d206..f4195af 100644 --- a/site/src/templates/ReleaseTemplate.js +++ b/site/src/templates/ReleaseTemplate.js @@ -47,8 +47,7 @@ const ReleaseTemplate = ({ mark.current.mark(value) }, 100) - search.current = event => { - const value = event.target.value + search.current = value => { setSearchValue(value) debouncedMark(value) } @@ -103,7 +102,7 @@ const ReleaseTemplate = ({ htmlUrl={htmlUrl} logoSrc={logoSrc} primaryColor={primaryColor} - onSearchChange={getReleaseSearch()} + setSearchValue={getReleaseSearch()} searchValue={searchValue} /> diff --git a/site/src/templates/ReleasesTemplate.js b/site/src/templates/ReleasesTemplate.js index 8038ca5..9f0221a 100644 --- a/site/src/templates/ReleasesTemplate.js +++ b/site/src/templates/ReleasesTemplate.js @@ -55,8 +55,7 @@ const ReleasesTemplate = ({ setReleases(!!value ? releaseSearch.search(value) : edges) }, 100) - search.current = event => { - const value = event.target.value + search.current = value => { setSearchValue(value) debouncedReleaseSearch(value) } @@ -120,7 +119,7 @@ const ReleasesTemplate = ({