Skip to content

Commit 9412001

Browse files
committed
not done yet but time over
1 parent 936e970 commit 9412001

10 files changed

Lines changed: 195 additions & 6 deletions

File tree

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"@testing-library/react": "^9.5.0",
88
"@testing-library/user-event": "^7.2.1",
99
"axios": "^0.20.0",
10+
"bootstrap": "^4.5.3",
1011
"react": "^17.0.1",
1112
"react-bootstrap": "^1.4.0",
1213
"react-dom": "^17.0.1",

src/App.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
a:hover{
2+
text-decoration: none !important;
3+
}
4+
.footer{
5+
position: absolute;
6+
bottom: 0;
7+
width: 100%;
8+
height: 60px;
9+
line-height: 60px;
10+
background-color: black;
11+
}

src/App.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
3-
import './App.css';
1+
import React from "react";
2+
import "./App.css";
3+
import "bootstrap/dist/css/bootstrap.min.css";
4+
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
5+
import Header from "./Components/Header";
6+
import Footer from "./Components/Footer"
7+
import HomeView from "./Pages/HomeView"
48

59
function App() {
610
return (
7-
<div className="App">
8-
9-
</div>
11+
<Router>
12+
<div className="App">
13+
<Header />
14+
<Switch>
15+
<Route exact path="/" component={HomeView}></Route>
16+
</Switch>
17+
<Footer />
18+
</div>
19+
</Router>
1020
);
1121
}
1222

src/Components/Comments.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React, { useState, useEffect } from "react";
2+
import axios from "axios";
3+
import {Container} from "react-bootstrap";
4+
5+
const Comments = () => {
6+
const [comments, setComments] = useState([]);
7+
8+
useEffect(() => {
9+
axios
10+
.get("https://jsonplaceholder.typicode.com/comments")
11+
.then((res) => setComments(res.data))
12+
.catch((err) => console.log(err));
13+
});
14+
15+
const commentStyle = {
16+
"height" : "75vh",
17+
"overflow" : "auto"
18+
}
19+
20+
return (
21+
<Container className="mt-4 border" style={commentStyle}>
22+
<ul>
23+
{
24+
comments.map(comment=>(<li key={comment.id}>{comment.body}</li>))
25+
}
26+
</ul>
27+
</Container>
28+
)
29+
};
30+
31+
export default Comments;

src/Components/Footer.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React from 'react'
2+
import {Container} from "react-bootstrap"
3+
4+
const Footer = () => {
5+
return (
6+
<footer className="footer">
7+
<Container>
8+
<span className="text-muted">HEY this is footer</span>
9+
</Container>
10+
</footer>
11+
)
12+
}
13+
14+
export default Footer

src/Components/Header.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react";
2+
import { Navbar, NavbarBrand } from "react-bootstrap";
3+
import {Link} from "react-router-dom"
4+
5+
const Header = () => {
6+
return (
7+
<>
8+
<Navbar bg="dark" variant="dark">
9+
<NavbarBrand>Codevian</NavbarBrand>
10+
<Navbar.Text className="mr-3 ml-3"><Link to="/">Posts</Link></Navbar.Text>
11+
<Navbar.Text className="ml-3"><Link to="/photos">Photos</Link></Navbar.Text>
12+
</Navbar>
13+
</>
14+
);
15+
};
16+
17+
export default Header;

src/Components/PostsList.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React, { useState, useEffect } from "react";
2+
import axios from "axios";
3+
import {Container} from "react-bootstrap"
4+
5+
const PostsList = () => {
6+
const [posts, setPosts] = useState([]);
7+
8+
useEffect(() => {
9+
axios
10+
.get("https://jsonplaceholder.typicode.com/posts")
11+
.then((res) => setPosts(res.data))
12+
.catch((err) => console.log(err));
13+
});
14+
15+
const postsList = {
16+
"height" : "75vh",
17+
"overflow" : "auto"
18+
}
19+
20+
return (
21+
// <div className="mt-4">
22+
// <ol>
23+
// {
24+
// posts.map(post => (
25+
// <li key={post.id}>{post.title}</li>
26+
// ))
27+
// }
28+
// </ol>
29+
// </div>
30+
<Container className="mt-4 border" style={postsList}>
31+
<ol>
32+
{
33+
posts.map(post => (
34+
<li key={post.id}>{post.title}</li>
35+
))
36+
}
37+
</ol>
38+
</Container>
39+
)
40+
};
41+
42+
export default PostsList;

src/Components/UserList.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useState, useEffect } from "react";
2+
import axios from "axios";
3+
import { Container } from "react-bootstrap";
4+
5+
const UserList = () => {
6+
const [users, setUsers] = useState([]);
7+
8+
useEffect(() => {
9+
axios
10+
.get("https://jsonplaceholder.typicode.com/users")
11+
.then((res) => setUsers(res.data))
12+
.catch((err) => console.log(err));
13+
});
14+
15+
const listStyle = {
16+
listStyleType: "none",
17+
};
18+
const listClass = {
19+
height: "75vh",
20+
};
21+
22+
return (
23+
<Container className="mt-4 border ml-2" style={listClass}>
24+
<ul style={listStyle}>
25+
{users.map((user) => (
26+
<li key={user.id}>
27+
{user.name}
28+
</li>
29+
))}
30+
</ul>
31+
</Container>
32+
);
33+
};
34+
35+
export default UserList;

src/Pages/HomeView.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import { Row, Col } from "react-bootstrap";
3+
import UserList from "../Components/UserList";
4+
import PostsList from "../Components/PostsList";
5+
import Comments from "../Components/Comments"
6+
7+
const HomeView = () => {
8+
return (
9+
<Row>
10+
<Col md="3">
11+
<UserList />
12+
</Col>
13+
<Col>
14+
<PostsList />
15+
</Col>
16+
<Col md="3">
17+
<Comments />
18+
</Col>
19+
</Row>
20+
);
21+
};
22+
23+
export default HomeView;

0 commit comments

Comments
 (0)