From 871f55587e3a6bced1529c7e52edd4c7510a13a1 Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Tue, 6 Dec 2022 21:09:09 -0800 Subject: [PATCH 1/4] search input directs query to google --- src/components/UI/search/Search.tsx | 42 +++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/src/components/UI/search/Search.tsx b/src/components/UI/search/Search.tsx index 27913e5e51..075de7cf37 100644 --- a/src/components/UI/search/Search.tsx +++ b/src/components/UI/search/Search.tsx @@ -1,29 +1,55 @@ -import { FC } from 'react'; -import { Input, InputGroup, Stack } from '@chakra-ui/react'; +import { FC, useState } from 'react'; +import { Input, InputGroup, Link, Stack } from '@chakra-ui/react'; import { BORDER_WIDTH } from '../../../constants'; import { LensIcon } from '../icons'; export const Search: FC = () => { + const [query, setQuery] = useState(''); + + // Handlers + const handleSubmit = (e: React.FormEvent): void => { + document.getElementById('search-link')?.click(); + }; + const handleKeyPress = (e: React.KeyboardEvent): void => { + if (e.key === 'Enter') handleSubmit(e); + }; + const handleChange = (e: React.ChangeEvent): void => { + setQuery(e.target.value); + }; + return ( + > - - - + + + ); From e8faee0bd3e7f4208e2e87f2b8ece3e8095cd62f Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Wed, 7 Dec 2022 15:47:35 -0800 Subject: [PATCH 2/4] update search to form get request similar to existing site, using duckduckgo using the get method of a form element. Converted magnifying class wrapped in anchor tag to be a submit button instead --- src/components/UI/search/Search.tsx | 70 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/src/components/UI/search/Search.tsx b/src/components/UI/search/Search.tsx index 075de7cf37..7b8ad0c3c1 100644 --- a/src/components/UI/search/Search.tsx +++ b/src/components/UI/search/Search.tsx @@ -1,5 +1,5 @@ import { FC, useState } from 'react'; -import { Input, InputGroup, Link, Stack } from '@chakra-ui/react'; +import { Button, Input, InputGroup, Stack } from '@chakra-ui/react'; import { BORDER_WIDTH } from '../../../constants'; import { LensIcon } from '../icons'; @@ -8,12 +8,6 @@ export const Search: FC = () => { const [query, setQuery] = useState(''); // Handlers - const handleSubmit = (e: React.FormEvent): void => { - document.getElementById('search-link')?.click(); - }; - const handleKeyPress = (e: React.KeyboardEvent): void => { - if (e.key === 'Enter') handleSubmit(e); - }; const handleChange = (e: React.ChangeEvent): void => { setQuery(e.target.value); }; @@ -24,33 +18,41 @@ export const Search: FC = () => { borderRight={{ base: 'none', md: BORDER_WIDTH }} borderColor={{ base: 'bg', md: 'primary' }} _hover={{ base: { bg: 'primary' }, md: { bg: 'none' } }} - > - - - - - - + > +
+ + + + + +
); }; From c9ef66acbf27e895ff0abe0b3850ea4b4e4f0c7e Mon Sep 17 00:00:00 2001 From: Paul Wackerow <54227730+wackerow@users.noreply.github.com> Date: Fri, 9 Dec 2022 13:29:14 -0800 Subject: [PATCH 3/4] add submit type to search button --- src/components/UI/search/Search.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/UI/search/Search.tsx b/src/components/UI/search/Search.tsx index 7b8ad0c3c1..41a6b364cf 100644 --- a/src/components/UI/search/Search.tsx +++ b/src/components/UI/search/Search.tsx @@ -36,6 +36,7 @@ export const Search: FC = () => { outlineOffset={4} />