diff --git a/src/components/search.js b/src/components/search.js index 0a14f5b..d9450b9 100644 --- a/src/components/search.js +++ b/src/components/search.js @@ -20,16 +20,30 @@ const inputStyles = css` export default function Search(props) { const [searchInput, setSearchInput] = useState(''); + const searchBarPlaceholder = props.isGlobalSearch ? 'Search published posts...' : 'Search your posts...' - useEffect(() => { - const delayDebounceFn = setTimeout(() => { - if (props.posts) { - filterPosts(); + const handleKeyDown = (event) => { + if (props.isGlobalSearch) { + if (event.key === 'Enter') { + console.log('do validate') props.getSearchInput(searchInput); } - }, 500) + } + } - return () => clearTimeout(delayDebounceFn) + useEffect(() => { + if (props.isGlobalSearch) { + + } else { + const delayDebounceFn = setTimeout(() => { + if (props.posts) { + filterPosts(); + props.getSearchInput(searchInput); + } + }, 500) + + return () => clearTimeout(delayDebounceFn) + } }, [searchInput]) const filterPosts = () => { @@ -39,13 +53,18 @@ export default function Search(props) { let tempPosts = props.posts.filter(p => p.title.toLowerCase().includes(searchInput.toLowerCase())) props.getFilteredPosts(tempPosts); } - } + const exploreSearchBarStyles = + props.isGlobalSearch ? + css`width: 100%` // Explore page search bar styles + : + css`width: 80%` // Dashboard page search bar styles + return ( -