diff --git a/src/App.jsx b/src/App.jsx index de60b9e842..4d3fc5b75e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -7,7 +7,6 @@ import { auth, db } from "./lib/firebase"; import ErrorBoundary from "./reusableComponents/ErrorBoundary"; import { FaArrowCircleUp } from "react-icons/fa"; -import { FaSearch } from "react-icons/fa"; import { GuestSignUpBtn } from "./components"; import { RowModeContext } from "./hooks/useRowMode"; import { makeStyles } from "@mui/styles"; @@ -79,8 +78,6 @@ function App() { const [postText, setPostText] = useState(""); const [rowMode, setRowMode] = useState(false); const [showScroll, setShowScroll] = useState(false); - const [searchText, setSearchText] = useState(""); - const [searchedPosts, setSearchedPosts] = useState([]); const [anonymous, setAnonymous] = useState(false); const navigate = useNavigate(); @@ -94,10 +91,6 @@ function App() { } }; - const handleSearch = (e) => { - setSearchText(e.target.value); - }; - const scrollTop = () => { window.scrollTo({ top: 0, behavior: "smooth" }); }; @@ -166,24 +159,6 @@ function App() { setLoadMorePosts(false); }, [loadMorePosts]); - useEffect(() => { - const fetchSearchResults = async () => { - setSearchedPosts( - posts.filter( - (post) => - post.post?.displayName - ?.toLowerCase() - .includes(searchText?.toLowerCase()) || - post.post?.username - ?.toLowerCase() - .includes(searchText?.toLowerCase()) - ) - ); - }; - - fetchSearchResults(); - }, [searchText, posts.length]); - return ( @@ -216,88 +191,48 @@ function App() { path="/dummygram/" element={ user ? ( -
+
-
- {loadingPosts ? ( - - ) : ( -
-
- + ) : ( +
+ + {posts.map(({ id, post }) => ( + - -
- -
- {searchText - ? searchedPosts.map(({ id, post }) => ( - - )) - : posts.map(({ id, post }) => ( - - ))} -
-
-
- )} -
+ ))} + +
+ )}
) : ( diff --git a/src/components/SearchBar/index.css b/src/components/SearchBar/index.css new file mode 100644 index 0000000000..23e348ea5e --- /dev/null +++ b/src/components/SearchBar/index.css @@ -0,0 +1,39 @@ +/* search file css */ +.search-bar { + position: relative; + height: 50px; + max-width: 380px; + background: #fff; + margin: 30px auto; + border: 1px solid #0cc; + border-radius: 25px; +} +.search-input { + position: absolute; + height: 100%; + width: 100%; + border-radius: 25px; + background: #fff; + border: none; + font-size: 16px; + padding-left: 20px; + margin-top: -2px; +} +.search-icon { + position: absolute; + right: 0px; + top: 0; + width: 54px; + background: linear-gradient(40deg, #0cc, #daf1f7); + height: 103%; + text-align: center; + line-height: 50px; + color: #fff; + font-size: 20px; + border-radius: 0 25px 25px 0; + margin-top: -2px; +} + +.text-white { + color: var(--color); +} diff --git a/src/components/SearchBar/index.jsx b/src/components/SearchBar/index.jsx index ceea75b159..9bbcb33f3e 100644 --- a/src/components/SearchBar/index.jsx +++ b/src/components/SearchBar/index.jsx @@ -1,3 +1,5 @@ +import "./index.css"; + import React, { memo, useEffect, useState } from "react"; import { auth, db } from "../../lib/firebase"; @@ -66,10 +68,7 @@ function SearchBar() { currentPostLink={currentPostLink} postText={postText} /> -
+