diff --git a/src/components/SearchBar/SearchBar.tsx b/src/components/SearchBar/SearchBar.tsx index 99ac0bb..20fcaa3 100644 --- a/src/components/SearchBar/SearchBar.tsx +++ b/src/components/SearchBar/SearchBar.tsx @@ -10,9 +10,13 @@ import { FileInterface } from "../../types/file"; import classNames from "classnames"; import { closeDrawer } from "../../reducers/leftSection"; import { setPopupSelect } from "../../reducers/selected"; +import CloseIcon from "../../icons/CloseIcon"; +import Spinner from "../Spinner/Spinner"; +import SearchIcon from "../../icons/SearchIcon"; const SearchBar = memo(() => { const [searchText, setSearchText] = useState(""); + const [showSuggestions, setShowSuggestions] = useState(false); const dispatch = useAppDispatch(); const [debouncedSearchText, setDebouncedSearchText] = useState(""); const { data: searchSuggestions, isLoading: isLoadingSearchSuggestions } = @@ -39,6 +43,7 @@ const SearchBar = memo(() => { const outOfContainerClick = useCallback(() => { closeDrawer(); + setShowSuggestions(false); }, []); const { wrapperRef } = useClickOutOfBounds(outOfContainerClick); @@ -87,6 +92,7 @@ const SearchBar = memo(() => { const onFocus = () => { dispatch(closeDrawer()); + setShowSuggestions(true); }; const searchTextPlaceholder = useMemo(() => { @@ -106,32 +112,30 @@ const SearchBar = memo(() => { // @ts-ignore ref={wrapperRef} > - + {searchText.length !== 0 && !isLoadingSearchSuggestions && ( + )} - > - {isLoadingSearchSuggestions ? ( -
- ) : ( - search - )} -
+ {isLoadingSearchSuggestions &&
} + {searchText.length === 0 && } +
{ if (type === "folder" && folder) { return (
folderClick(folder)} >
- + {folder.name}
@@ -56,14 +56,14 @@ const SearchBarItem = (props: SearchBarItemProps) => { } else if (type === "file" && file) { return (
fileClick(file)} >
- +
@@ -72,7 +72,7 @@ const SearchBarItem = (props: SearchBarItemProps) => {
- + {file.filename}
diff --git a/src/components/Spinner/Spinner.tsx b/src/components/Spinner/Spinner.tsx index d4ea031..b30007e 100644 --- a/src/components/Spinner/Spinner.tsx +++ b/src/components/Spinner/Spinner.tsx @@ -1,7 +1,3 @@ import React from "react"; -export default () => ( -
- -
-) \ No newline at end of file +export default () =>
; diff --git a/src/icons/SearchIcon.tsx b/src/icons/SearchIcon.tsx new file mode 100644 index 0000000..d1c16f4 --- /dev/null +++ b/src/icons/SearchIcon.tsx @@ -0,0 +1,30 @@ +type SearchIconType = React.SVGAttributes; + +const SearchIcon: React.FC = (props) => { + return ( + + + + + + + ); +}; + +export default SearchIcon;