You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/public/react/src/forge/Main/IndexItem.js

57 lines
2.2 KiB

5 years ago
import React , { Component } from 'react';
5 years ago
import { getImageUrl } from 'educoder';
5 years ago
import { Link } from 'react-router-dom';
import '../css/index.css'
import './list.css';
import img_parise from '../Images/parise.png';
5 years ago
class IndexItem extends Component{
// constructor(props){
// super(props);
// }
TurnToDetail=(login,url)=>{
this.props.history.push({
pathname:url,
state:login
})
}
5 years ago
render(){
const { projects } = this.props;
// item.author.login
5 years ago
const renderList = (
projects && projects.length >0 ? projects.map((item,key)=>{
5 years ago
return(
<div className="p-r-Item">
5 years ago
<img className="p-r-photo" alt="" src={getImageUrl(`images/${item.author && item.author.image_url}`)} ></img>
5 years ago
<div className="p-r-Infos">
<div className="p-r-name">
<a onClick={()=>this.TurnToDetail(`${item.author && item.author.login}`,`/projects/${item.identifier}/coder`)} className="hide-1 font-16 color-grey-3" style={{whiteSpace:"wrap"}}>{item.name}</a>
</div>
<div className="p-r-content">
<p className="break_word task-hide flex1" style={{maxHeight:"40px"}}>{item.description}</p>
5 years ago
<span className="p-r-tags">
{/* { item.forked_count ? <span><label>Fork</label><span>{ item.forked_count}</span></span>:"" } */}
<span className="pariseTag"><img src={img_parise} alt="" className="pariseImg"/>点赞 ({ item.praises_count })</span>
5 years ago
{ item.language && item.language.id ? <span><label>{ item.language.name }</label></span>:"" }
</span>
</div>
<div className="p-r-about">
5 years ago
<span className="p-r-detail">
<span><label>浏览量</label>{item.visits}</span>
{ item.category && item.category.id && <span><label>项目类别</label>{item.category.name}</span>}
{item.last_update_time ? <span ><label>更新于</label>{item.time_ago}</span> : "" }
5 years ago
</span>
</div>
</div>
</div>
)
}):""
5 years ago
)
return(
<div className="project-list">
{ renderList }
</div>
)
}
}
export default IndexItem;