diff --git a/src/assets/xcircle.svg b/src/assets/xcircle.svg new file mode 100644 index 00000000..6fee8505 --- /dev/null +++ b/src/assets/xcircle.svg @@ -0,0 +1 @@ + diff --git a/src/components/Layout/SearchInput/index.tsx b/src/components/Layout/SearchInput/index.tsx index 60e9f62a..643235ae 100644 --- a/src/components/Layout/SearchInput/index.tsx +++ b/src/components/Layout/SearchInput/index.tsx @@ -1,6 +1,7 @@ import React from 'react'; import useSearchInput from '../../../hooks/useSearchInput'; import { defineMessages, useIntl } from 'react-intl'; +import ClearButton from '../../../assets/xcircle.svg'; const messages = defineMessages({ searchPlaceholder: 'Search Movies & TV', @@ -8,7 +9,7 @@ const messages = defineMessages({ const SearchInput: React.FC = () => { const intl = useIntl(); - const { searchValue, setSearchValue, setIsOpen } = useSearchInput(); + const { searchValue, setSearchValue, setIsOpen, clear } = useSearchInput(); return (
@@ -27,7 +28,8 @@ const SearchInput: React.FC = () => {
0 ? '1.75rem' : '' }} + className="block w-full h-full pl-8 py-2 rounded-md border-transparent focus:border-transparent bg-gray-600 text-white placeholder-gray-300 focus:outline-none focus:ring-0 focus:placeholder-gray-400 sm:text-base" placeholder={intl.formatMessage(messages.searchPlaceholder)} type="search" value={searchValue} @@ -35,6 +37,14 @@ const SearchInput: React.FC = () => { onFocus={() => setIsOpen(true)} onBlur={() => setIsOpen(false)} /> + {searchValue.length > 0 && ( + + )}
diff --git a/src/styles/globals.css b/src/styles/globals.css index 3517a6a6..bd248bf0 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -56,3 +56,7 @@ body { code { @apply px-2 py-1 bg-gray-800 rounded-md; } + +input[type='search']::-webkit-search-cancel-button { + -webkit-appearance: none; +}