File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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
59function 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
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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 ;
You can’t perform that action at this time.
0 commit comments