-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
474287b
commit 6ef61cf
Showing
8 changed files
with
383 additions
and
307 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
const Books = ()=>{ | ||
return( | ||
<h1>This is Books page</h1> | ||
) | ||
import React from "react"; | ||
import books from "../data/books.json"; | ||
|
||
class Books extends React.Component { | ||
state = { | ||
searchTerm: "" | ||
}; | ||
handleChange = ({ target: { value } }) => { | ||
this.setState({ searchTerm: value }); | ||
}; | ||
render() { | ||
let filteredBooks = books.filter((article) => | ||
article.title.toLowerCase().includes(this.state.searchTerm) | ||
); | ||
return ( | ||
<div className="page"> | ||
<input | ||
placeholder="Search" | ||
className="search" | ||
value={this.state.searchTerm} | ||
onChange={this.handleChange} | ||
/> | ||
<ul className="archive"> | ||
{filteredBooks.map((book) => ( | ||
<Book {...book} /> | ||
))} | ||
</ul> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
function Book(props) { | ||
return ( | ||
<li className="book"> | ||
<img src={props.image} alt={props.title} /> | ||
<h2>{props.title}</h2> | ||
<p> | ||
Author:<span>{props.author}</span> | ||
</p> | ||
<a href={props.website}> | ||
<button>Buy Now</button> | ||
</a> | ||
</li> | ||
); | ||
} | ||
|
||
export default Books; | ||
export default Books; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
const Help = ()=>{ | ||
return( | ||
<h1>Nothing is here !</h1> | ||
) | ||
} | ||
|
||
export default Help; | ||
function Help() { | ||
return <h1>🤷♀️ How can we help you?</h1>; | ||
} | ||
|
||
export default Help; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,52 @@ | ||
const Peoples = ()=>{ | ||
return( | ||
<h1>This is people page</h1> | ||
) | ||
import React from "react"; | ||
|
||
import people from "../data/got.json"; | ||
|
||
class People extends React.Component { | ||
state = { | ||
searchTerm: "" | ||
}; | ||
handleChange = ({ target: { value } }) => { | ||
this.setState({ searchTerm: value }); | ||
}; | ||
render() { | ||
let allPeople = people.reduce((acc, cv) => { | ||
acc = acc.concat(cv.people); | ||
return acc; | ||
}, []); | ||
|
||
let filteredPeople = allPeople.filter((person) => | ||
person.name.toLowerCase().includes(this.state.searchTerm) | ||
); | ||
return ( | ||
<> | ||
<input | ||
placeholder="Search" | ||
className="search" | ||
value={this.state.searchTerm} | ||
onChange={this.handleChange} | ||
/> | ||
<ul className="people"> | ||
{filteredPeople.map((sp) => ( | ||
<SinglePerson {...sp} /> | ||
))} | ||
</ul> | ||
</> | ||
); | ||
} | ||
} | ||
|
||
function SinglePerson(props) { | ||
return ( | ||
<li className="card"> | ||
<div className="info"> | ||
<img src={props.image} alt={props.name} /> | ||
<h2>{props.name}</h2> | ||
</div> | ||
<p>{props.description}</p> | ||
<a href={props.wikiLink}>Learn More!</a> | ||
</li> | ||
); | ||
} | ||
|
||
export default Peoples; | ||
export default People; |
Oops, something went wrong.