This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add grid layout for user-list and refactor searchbar (#596)
* add Sachin-chaurasiya.json * Add React router component for links * Add grid layout for user-list closes #583
- Loading branch information
1 parent
1c3ae43
commit d56d557
Showing
5 changed files
with
89 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { InputText } from 'primereact/inputtext' | ||
|
||
const Searchbar = ({ searchHandler, searchTerm }) => { | ||
return ( | ||
<div className="search-section"> | ||
<span className="p-input-icon-left"> | ||
<i className="pi pi-search" /> | ||
<InputText | ||
type="search" | ||
value={searchTerm} | ||
onChange={({ target }) => searchHandler(target.value)} | ||
name="user" | ||
id="search-input" | ||
placeholder="Search user..." | ||
/> | ||
</span> | ||
</div> | ||
) | ||
} | ||
Searchbar.propTypes = { | ||
searchHandler: PropTypes.func.isRequired, | ||
searchTerm: PropTypes.string.isRequired, | ||
} | ||
|
||
export default Searchbar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,34 @@ | ||
import React, { useState } from 'react' | ||
import PropTypes from 'prop-types' | ||
import { Chip } from 'primereact/chip' | ||
import { InputText } from 'primereact/inputtext' | ||
import { Link } from 'react-router-dom' | ||
import Searchbar from './Searchbar' | ||
|
||
function User({ list }) { | ||
function Users({ list }) { | ||
const [searchTerm, setSearchTerm] = useState('') | ||
const searchHandler = (value) => { | ||
setSearchTerm(value || '') | ||
} | ||
return ( | ||
<> | ||
<div className="search-section"> | ||
<span className="p-input-icon-left"> | ||
<i className="pi pi-search" /> | ||
<InputText | ||
value={searchTerm} | ||
onChange={({ target }) => setSearchTerm(target.value)} | ||
name="user" | ||
id="search-input" | ||
placeholder="Search..." | ||
/> | ||
</span> | ||
<Searchbar searchTerm={searchTerm} searchHandler={searchHandler} /> | ||
<div className="user-list"> | ||
{list | ||
.filter((User) => | ||
User.name.toLowerCase().includes(searchTerm.toLowerCase()), | ||
) | ||
.map((user, key) => ( | ||
<Link to={`${user.username}`} key={`avatar-${key}`}> | ||
<Chip image={user.avatar} className="p-m-2" label={user.name} /> | ||
</Link> | ||
))} | ||
</div> | ||
{list | ||
.filter((User) => | ||
User.name.toLowerCase().includes(searchTerm.toLowerCase()), | ||
) | ||
.map((user, key) => ( | ||
<Link to={`${user.username}`} key={`avatar-${key}`}> | ||
<Chip image={user.avatar} className="p-m-2" label={user.name} /> | ||
</Link> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
User.propTypes = { | ||
Users.propTypes = { | ||
list: PropTypes.array.isRequired, | ||
} | ||
|
||
export default User | ||
export default Users |