Skip to content

Commit

Permalink
Clean, style and move search icon
Browse files Browse the repository at this point in the history
  • Loading branch information
SandraBergstrom committed Jun 28, 2023
1 parent 01c148b commit 3ce36b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
33 changes: 15 additions & 18 deletions src/pages/posts/PostsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { axiosReq } from "../../api/axiosDefaults";

import NoResults from "../../assets/no-results.png";
import InfiniteScroll from "react-infinite-scroll-component";
import {fetchMoreData} from "../../utils/utils"
import { fetchMoreData } from "../../utils/utils";

function PostsPage({ message, filter = "" }) {
const [posts, setPosts] = useState({ results: [] });
Expand All @@ -36,24 +36,24 @@ function PostsPage({ message, filter = "" }) {
setHasLoaded(false);
const timer = setTimeout(() => {
fetchPosts();
}, 1000)
}, 1000);
return () => {
clearTimeout(timer)
}
clearTimeout(timer);
};
}, [filter, query, pathname]);

return (
<Row className="h-100">
<Col className="py-2 p-0 p-lg-2" lg={8}>
<p>Popular profiles mobile</p>
<i className={`fas fa-search ${styles.SearchIcon}`} />
<Form
className={styles.SearchBar}
className={`d-flex ${styles.SearchBar}`}
onSubmit={(event) => event.preventDefault()}
>
<i className={`fas fa-search ${styles.SearchIcon}`} />
<Form.Control
value={query}
onChange={(event) => setQuery(event.target.value)}
value={query}
onChange={(event) => setQuery(event.target.value)}
type="text"
className="mr-sm-2"
placeholder="Search posts"
Expand All @@ -62,18 +62,15 @@ function PostsPage({ message, filter = "" }) {
{hasLoaded ? (
<>
{posts.results.length ? (
<InfiniteScroll
children={
posts.results.map((post) => (
<InfiniteScroll
children={posts.results.map((post) => (
<Post key={post.id} {...post} setPosts={setPosts} />
))
}
dataLength={posts.results.length}
loader={<Asset spinner />}
hasMore={!!posts.next}
next={() => fetchMoreData(posts, setPosts)}
))}
dataLength={posts.results.length}
loader={<Asset spinner />}
hasMore={!!posts.next}
next={() => fetchMoreData(posts, setPosts)}
/>

) : (
<Container className="appStyles.Content">
<Asset src={NoResults} message={message} />
Expand Down
1 change: 0 additions & 1 deletion src/styles/PostsPage.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.SearchBar input {
border-radius: 20px;
color: #242a3d;
padding-left: 40px;
margin-bottom: 16px;
Expand Down

0 comments on commit 3ce36b8

Please sign in to comment.