Commit 15bbb1c5 authored by Shaini Thenuwara's avatar Shaini Thenuwara

View post updated

parent b86f7974
This diff is collapsed.
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@material-ui/core": "^4.9.10",
"axios": "^0.18.0", "axios": "^0.18.0",
"bootstrap": "^4.3.1", "bootstrap": "^4.4.1",
"react": "^16.8.6", "react": "^16.8.6",
"react-bootstrap": "^1.0.0",
"react-bootstrap-table": "^4.3.1", "react-bootstrap-table": "^4.3.1",
"react-dom": "^16.8.6", "react-dom": "^16.8.6",
"react-router-dom": "^5.0.0", "react-router-dom": "^5.0.0",
......
import React, { Component } from 'react' import React, { Component } from 'react'
import axios from 'axios' import axios from 'axios'
import constant from '../service/constant'; import constant from '../service/constant';
import Card from 'react-bootstrap/Card'
const CardPostNav = props =>( import { makeStyles } from '@material-ui/core/styles';
<div> import GridList from '@material-ui/core/GridList';
<div className="card postCard"> import GridListTile from '@material-ui/core/GridListTile';
<img className="card-img-top" src="..." alt="Card image cap"/>
<div className="card-body">
<h5 className="card-title">Card title</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" className="btn btn-primary">Go somewhere</a>
</div>
</div>
<br/>
</div>
);
class Student extends Component { class Student extends Component {
constructor(pros){ constructor(pros) {
super(pros) super(pros)
this.state = { this.state = {
postList:[] postList: [],
} count: 0,
} }
}
componentWillMount() { componentWillMount() {
axios.get(constant()+'/post') axios.get(constant() + '/post')
.then(res => { .then(res => {
this.setState({postList: res.data}); this.setState({ postList: res.data });
}).catch(err => { }).catch(err => {
console.log(err); console.log(err);
}); });
} }
viewCardList = () => { render() {
return this.state.postList.map(function(value,index){
return <CardPostNav postObj={value} index={index} />;
})
}
const { postList } = this.state;
render(){ const classes = makeStyles((theme) => ({
const { postList } = this.state; root: {
return( display: 'flex',
<div className="container"> flexWrap: 'wrap',
<div className="panel panel-default"> justifyContent: 'space-around',
<div className="panel-heading"> overflow: 'hidden',
<h3 className="panel-title"> backgroundColor: theme.palette.background.paper,
Login },
</h3> gridList: {
</div> width: 500,
<div className="panel-body"> height: 450,
{this.viewCardList()} },
<br/> }));
</div>
return (
<div className="container">
<div className="panel panel-default">
<div className="panel-heading">
<h3 className="panel-title">
Login
</h3>
</div>
<div className="panel-body">
<div className={classes.root}>
<GridList cellHeight={500} className={classes.gridList} cols={3}>
{postList.map((item) => (
<GridListTile key={item.img} cols={item.cols || 1}>
<Card>
<Card.Img className="postImageSize" variant="top" src={item.image} />
<Card.Body>
<Card.Title>{item.title}</Card.Title>
<Card.Text>{item.content} </Card.Text>
</Card.Body>
<Card.Footer>
<a href="#" class="btn btn-primary">Go somewhere</a>
</Card.Footer>
</Card>
</GridListTile>
))}
</GridList>
</div> </div>
</div> </div>
) </div>
} </div>
)
}
} }
export default Student; export default Student;
...@@ -116,5 +116,18 @@ a:link { ...@@ -116,5 +116,18 @@ a:link {
} }
.postCard{ .postCard{
width: 18rem; width: 20rem;
} }
\ No newline at end of file
.postImageSize {
width: 23rem;
height: 200px;
}
ul#CardView-Align li {
display:inline;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment