Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main #2

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
666c3bc
added much more styling to book box
KJablonski08 Oct 27, 2020
704f130
added toggle buttons for search on author, title, and isbn
KJablonski08 Oct 27, 2020
dd66b11
updated data flow from BookList to App for new Route
KJablonski08 Oct 28, 2020
013a9ab
details page added and working
KJablonski08 Oct 28, 2020
442cf96
added link back to books from bookdetail page
KJablonski08 Oct 28, 2020
f71621d
added purchase link and working
KJablonski08 Oct 28, 2020
a430b1c
updated purchase link to an google info link with purchase option
KJablonski08 Oct 28, 2020
d236d8b
updated bookDetail purchase link
KJablonski08 Oct 28, 2020
ffc88eb
removed yarn.lock to deploy to heroku
KJablonski08 Oct 28, 2020
a9176a6
updated search form from toggle to 3 input boxes
KJablonski08 Oct 29, 2020
87fa433
search bar passing values up to app through props
KJablonski08 Oct 29, 2020
7274c64
search bar working for title and author
KJablonski08 Oct 29, 2020
d37a0e1
updated fetch url parameters for a more optimized search
KJablonski08 Oct 29, 2020
d896c42
added new logic to if no books are found in booklist component
KJablonski08 Oct 29, 2020
06eb4a4
added not found page
KJablonski08 Oct 29, 2020
dd628d1
updated search form to display new books on submit
KJablonski08 Oct 30, 2020
fe6195f
updated css for book items
KJablonski08 Oct 30, 2020
57dc965
removed book box border
KJablonski08 Oct 31, 2020
9802ee5
authors buttons working
KJablonski08 Oct 31, 2020
5f0ee38
author buttons broken out into new component
KJablonski08 Oct 31, 2020
ea5ce7f
added component for new york times bestseller list
KJablonski08 Oct 31, 2020
595f498
best seller list rendering on home component
KJablonski08 Oct 31, 2020
ff686a8
updated new york times fetch to combined fiction
KJablonski08 Nov 1, 2020
a9d0450
nyt list working on click
KJablonski08 Nov 1, 2020
72f4b96
added nonfiction list to home
KJablonski08 Nov 1, 2020
c99149e
loading page working while waiting for fetch
KJablonski08 Nov 1, 2020
d30d87c
updated css to center buttons
KJablonski08 Nov 1, 2020
08ac5a2
created a welcome message on home page
KJablonski08 Nov 1, 2020
c846fab
cleaned up code
KJablonski08 Nov 1, 2020
cac1f18
fixed title bug with category buttons
KJablonski08 Nov 1, 2020
d41d746
updated footer
KJablonski08 Nov 1, 2020
1f1f245
more styling updates
KJablonski08 Nov 1, 2020
62336c7
removed list-name dependency
KJablonski08 Nov 1, 2020
b7b8932
updated search url
KJablonski08 Nov 1, 2020
e48870c
update screen width
KJablonski08 Nov 1, 2020
41c3ad6
added media query for css mobile screens
KJablonski08 Nov 1, 2020
feae89f
updated NYT component to be more accurate
KJablonski08 Nov 2, 2020
bc7f0d7
README
KJablonski08 Nov 2, 2020
9898210
added media query for book detail and book list for easier mobile vie…
KJablonski08 Nov 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 20 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,30 @@
# Getting Started with Create React App
# Book Browser

This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
Book Browser is a search app for choosing your next great read. If you're not sure what you are looking for, the app shows the current New York Times best seller lists for fiction and nonfiction. You can also search one of many popular author choices or use the search bar to find a specific book. Choose a book from the list to read more details and find links to a preview of the chosen book or a purchase link to purchase the e-book.

## Available Scripts
![](book-browser-search.gif)

In the project directory, you can run:
# Technologies Used

### `yarn start`
- HTML
- CSS
- JavaScript
- React.js
- Bootstrap
- Heroku
- New York Times Books API - https://developer.nytimes.com/docs/books-product/1/overview
- Google Books API - https://developers.google.com/books

Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
# Getting Started/Installation Instructions

The page will reload if you make edits.\
You will also see any lint errors in the console.
Link to deployed app on Heroku:
https://kj-book-browser.herokuapp.com/

### `yarn test`
OR

Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
clone this project from GitHub. Open in your preferred text editor and start your live server to run on your local machine.

### `yarn build`
# Contribution Guidelines:

Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `yarn eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

To learn React, check out the [React documentation](https://reactjs.org/).

### Code Splitting

This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)

### Analyzing the Bundle Size

This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)

### Making a Progressive Web App

This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)

### Advanced Configuration

This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)

### Deployment

This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)

### `yarn build` fails to minify

This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
I welcome any feedback on this app. Please let me know if you have any ideas that would improve on this project - I am especially open to new features suggestions and input on making the currrent code run more efficiently.
If you would like to contribute, please fork/clone this repo, make you changes, and submit a pull request.
Binary file added book-browser-search.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>Book Browser</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
70 changes: 64 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,79 @@
import React from 'react';
import { Route } from 'react-router-dom';
import React, { useState, useEffect } from 'react';
import { Route, Switch } from 'react-router-dom';
import Nav from './components/Nav';
import Home from './components/Home';
import BookList from './components/BookList';
import SearchForm from './components/SearchForm';
import BookDetail from './components/BookDetail';
import NotFound from './components/NotFound';
import Footer from './components/Footer';

const App = () => {
let [books, setBooks] = useState(null);
const [searchObj, setSearchObj] = useState({
title: '',
author: '',
isbn: '',
});
useEffect(() => {
fetch(
`https://www.googleapis.com/books/v1/volumes?&maxResults=25&q=${
searchObj.title ? `intitle:${searchObj.title}&` : ''
}
${searchObj.author ? `inauthor:${searchObj.author}&` : ''}
${searchObj.isbn ? `isbn:${searchObj.isbn}&` : ''}
key=${process.env.REACT_APP_KEY}`
)
.then((res) => res.json())
.then((res) => {
setBooks(res.items);
})
.catch(console.error);
}, [searchObj.title, searchObj.author, searchObj.isbn]);
return (
<div>
<header>
<Nav />
<SearchForm />
</header>
<main>
<Route exact path='/' component={Home} />
<Route path='/books' component={BookList} />
<Switch>
<Route
exact
path='/'
render={(routerProps) => {
return (
<Home
searchObj={searchObj}
setSearchObj={setSearchObj}
history={routerProps.history}
/>
);
}}
/>
<Route
exact
path='/books'
render={() => {
return (
<BookList
books={books}
searchObj={searchObj}
setSearchObj={setSearchObj}
/>
);
}}
/>
<Route
path='/books/:book'
render={(routerProps) => {
return <BookDetail match={routerProps.match} />;
}}
/>
<Route component={NotFound} />
</Switch>
</main>
<footer>
<Footer />
</footer>
</div>
);
};
Expand Down
108 changes: 108 additions & 0 deletions src/components/BookDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React, { useState, useEffect } from 'react';
import { Card, Button, Spinner } from 'react-bootstrap';
import { Link } from 'react-router-dom';

const BookDetail = ({ match }) => {
const [book, setBook] = useState(null);
useEffect(() => {
fetch(
`https://www.googleapis.com/books/v1/volumes?q=isbn:${match.params.book}&key=${process.env.REACT_APP_KEY}`
)
.then((res) => res.json())
.then((res) => {
setBook(res.items[0]);
})
.catch(console.error);
}, []);
if (book === null) {
return (
<div className='margin'>
<br />
<div className='d-flex justify-content-center'>
<Spinner animation='border' variant='primary' />
</div>
<div>
<h6>Loading... Please Wait</h6>
<p>
If your book does not load in a few seconds - please navigate back
to home and try your search again
</p>
<Link to={'/'}>
<Button variant='dark'>Home</Button>
</Link>
</div>
</div>
);
}
return (
<div>
<br />
<p className='d-flex justify-content-center'>
Click book for text preview
</p>
<Card className='book-box card-cascade-narrower detail'>
{book.volumeInfo.previewLink && book.volumeInfo.imageLinks && (
<a
target='_blank'
rel='noreferrer'
href={book.volumeInfo.previewLink}>
<Card.Img
className='book-image'
src={book.volumeInfo.imageLinks.thumbnail}
/>
</a>
)}
<Card.Title>{book.volumeInfo.title}</Card.Title>
{book.volumeInfo.authors &&
book.volumeInfo.authors.map((author, i) => {
return (
<Card.Subtitle key={i} className='mb-2 text-muted'>
{author}
</Card.Subtitle>
);
})}
{book.volumeInfo.categories && (
<Card.Subtitle variant='secondary' size='sm'>
{book.volumeInfo.categories[0]}
</Card.Subtitle>
)}
<hr />
{book.volumeInfo.description && (
<Card.Text>{book.volumeInfo.description}</Card.Text>
)}
{book.volumeInfo.publisher && (
<Card.Text variant='secondary' size='sm'>
Publisher: {book.volumeInfo.publisher}
</Card.Text>
)}
{book.volumeInfo.publishedDate && (
<Card.Text variant='secondary' size='sm'>
Published Date: {book.volumeInfo.publishedDate}
</Card.Text>
)}
<Card.Text variant='secondary' size='sm'>
Page Count: {book.volumeInfo.pageCount}
</Card.Text>
<hr />
{book.volumeInfo.infoLink && (
<a
target='_blank'
rel='noreferrer'
href={book.volumeInfo.infoLink}
className='d-flex justify-content-center'>
<Button variant='light'>Purchase Now</Button>
</a>
)}
<br />
</Card>
<br />
<div className='d-flex justify-content-center'>
<Link to={'/books'}>
<Button variant='dark'>BookList</Button>
</Link>
</div>
</div>
);
};

export default BookDetail;
Loading