Last active
March 19, 2018 23:15
-
-
Save matheusnascgomes/a9da02cdc47671499688c200c363e0bb to your computer and use it in GitHub Desktop.
Dynamic list with react
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
import React from 'react'; | |
import { Row, Col } from 'react-bootstrap'; | |
import FontAwesome from 'react-fontawesome'; | |
import CategoryTag from './helpers/CategoryTag'; | |
import User from './res/user.jpg'; | |
import './styles/content.css' | |
export default props => { | |
const { list, description } = props; | |
return( | |
list.filter(link => { | |
return ( | |
link.meta.title.toLowerCase().indexOf(description.toLowerCase()) >= 0 | |
|| | |
link.meta.url.toLowerCase().indexOf(description.toLowerCase()) >= 0 | |
|| | |
link.meta.author.toLowerCase().indexOf(description.toLowerCase()) >= 0 | |
|| | |
link.category.toLowerCase().indexOf(description.toLowerCase()) >= 0 | |
) | |
}) | |
.map(link => ( | |
<Row key={link.meta.author} className="content"> | |
<Col className="first-block" md={1} sm={6}> | |
<FontAwesome name="angle-up" size="2x" style={{ color: '#da4738'} } /> | |
<p>{link.upvotes}</p> | |
</Col> | |
<Col className="second-block" md={11} sm={6}> | |
<p>{link.meta.url}</p> | |
<h4>{link.meta.title}</h4> | |
<div className="links"> | |
<CategoryTag tagText={link.category}>{link.category}</CategoryTag> | |
<div><a className="user-name"><img src={User} alt="foto do dono do post" with="16px" height="16px" />{link.meta.author}</a></div> | |
<div><p className="time">43 minutes ago</p></div> | |
<div><a href="" ><FontAwesome name="comment" style={{ color: '#da4738'} } /> {link.comments} Comments</a></div> | |
<div><a href="">Edit</a></div> | |
</div> | |
</Col> | |
</Row> | |
)) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment