Skip to content

Commit

Permalink
fix search and add css
Browse files Browse the repository at this point in the history
  • Loading branch information
ShyarK committed Dec 5, 2019
1 parent e8dece4 commit 659947d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 11 deletions.
35 changes: 35 additions & 0 deletions client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,41 @@ button {
margin-bottom: 0.5rem;
}

/* Developers */
.div_search {
display: flex;
align-items: center;
background: #2f3640;
border-radius: 40px;
height: 40px;
margin: 5px;
margin-left: -5px;
width: 40px;
overflow: hidden;
transition: width 0.9s;
}

.search-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
margin-left: -40px;
border-radius: 50%;
color: white;
}

input[class='search-txt'] {
border: none;
background: none;
padding: 6px 0 0 20px;
color: white;
}

.div_search:hover {
width: 40%;
}
/* Mobile Styles */
@media (max-width: 700px) {
.container {
Expand Down
28 changes: 17 additions & 11 deletions client/src/components/profiles/Profiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ const Profiles = ({ getProfiles, profile: { profiles, loading } }) => {

const [searchField, setSearchField] = useState('');

const filteredProfiles = profiles.filter(profile =>
profile.user.name.toLowerCase().includes(searchField.toLowerCase()),
);
const filteredProfiles = profiles.filter(profile => {
const userName = profile.user.name.toLowerCase().substring(0, 3);
const searchText = searchField.toLowerCase().substring(0, 3);
return userName.includes(searchText);
});
console.log(filteredProfiles);

const [currentPage, setCurrentPage] = useState(1);
Expand All @@ -40,14 +42,18 @@ const Profiles = ({ getProfiles, profile: { profiles, loading } }) => {
<p className="lead">
<i className="fab fa-connectdevelop" /> Browse and connect with developers
</p>
<input
type="search"
placeholder="search for developers"
onChange={e => {
setSearchField(e.target.value);
setCurrentPage(1);
}}
/>
<div className="div_search">
<input
className="search-txt"
type="search"
placeholder="search for developers"
onChange={e => {
setSearchField(e.target.value);
setCurrentPage(1);
}}
/>
<i className="search-btn fas fa-search"></i>
</div>
<Pagination
profilesPerPage={profilesPerPage}
totalProfiles={filteredProfiles.length}
Expand Down

0 comments on commit 659947d

Please sign in to comment.