import { XCircleIcon } from '@heroicons/react/outline'; import { SearchIcon } from '@heroicons/react/solid'; import { defineMessages, useIntl } from 'react-intl'; import useSearchInput from '../../../hooks/useSearchInput'; const messages = defineMessages({ searchPlaceholder: 'Search Movies & TV', }); const SearchInput = () => { const intl = useIntl(); const { searchValue, setSearchValue, setIsOpen, clear } = useSearchInput(); return (
0 ? '1.75rem' : '' }} className="block w-full rounded-full border border-gray-600 bg-gray-900 bg-opacity-80 py-2 pl-10 text-white placeholder-gray-300 hover:border-gray-500 focus:border-gray-500 focus:bg-opacity-100 focus:placeholder-gray-400 focus:outline-none focus:ring-0 sm:text-base" placeholder={intl.formatMessage(messages.searchPlaceholder)} type="search" autoComplete="off" value={searchValue} onChange={(e) => setSearchValue(e.target.value)} onFocus={() => setIsOpen(true)} onBlur={() => { if (searchValue === '') { setIsOpen(false); } }} onKeyUp={(e) => { if (e.key === 'Enter') { e.preventDefault(); (e.target as HTMLInputElement).blur(); } }} /> {searchValue.length > 0 && ( )}
); }; export default SearchInput;