first commit
This commit is contained in:
3
.gitignore
vendored
Executable file
3
.gitignore
vendored
Executable file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
yarn.lock
|
||||
.DS_Store
|
||||
3
CONTRIBUTING.md
Executable file
3
CONTRIBUTING.md
Executable file
@@ -0,0 +1,3 @@
|
||||
# How to contribute
|
||||
|
||||
The files in this repository are used in the course videos and are the starting point for all students. Because we want all students to have the same experience going through course, if your pull request alters any of the core files, then it (most likely) will _not_ be merged into the project.
|
||||
92
README.md
Executable file
92
README.md
Executable file
@@ -0,0 +1,92 @@
|
||||
# MyReads Project
|
||||
|
||||
This is the starter template for the final assessment project for Udacity's React Fundamentals course. The goal of this template is to save you time by providing a static example of the CSS and HTML markup that may be used, but without any of the React code that is needed to complete the project. If you choose to start with this template, your job will be to add interactivity to the app by refactoring the static code in this template.
|
||||
|
||||
Of course, you are free to start this project from scratch if you wish! Just be sure to use [Create React App](https://github.com/facebookincubator/create-react-app) to bootstrap the project.
|
||||
|
||||
## TL;DR
|
||||
|
||||
To get started developing right away:
|
||||
|
||||
* install all project dependencies with `npm install`
|
||||
* start the development server with `npm start`
|
||||
|
||||
## What You're Getting
|
||||
```bash
|
||||
├── CONTRIBUTING.md
|
||||
├── README.md - This file.
|
||||
├── SEARCH_TERMS.md # The whitelisted short collection of available search terms for you to use with your app.
|
||||
├── package.json # npm package manager file. It's unlikely that you'll need to modify this.
|
||||
├── public
|
||||
│ ├── favicon.ico # React Icon, You may change if you wish.
|
||||
│ └── index.html # DO NOT MODIFY
|
||||
└── src
|
||||
├── App.css # Styles for your app. Feel free to customize this as you desire.
|
||||
├── App.js # This is the root of your app. Contains static HTML right now.
|
||||
├── App.test.js # Used for testing. Provided with Create React App. Testing is encouraged, but not required.
|
||||
├── BooksAPI.js # A JavaScript API for the provided Udacity backend. Instructions for the methods are below.
|
||||
├── icons # Helpful images for your app. Use at your discretion.
|
||||
│ ├── add.svg
|
||||
│ ├── arrow-back.svg
|
||||
│ └── arrow-drop-down.svg
|
||||
├── index.css # Global styles. You probably won't need to change anything here.
|
||||
└── index.js # You should not need to modify this file. It is used for DOM rendering only.
|
||||
```
|
||||
|
||||
Remember that good React design practice is to create new JS files for each component and use import/require statements to include them where they are needed.
|
||||
|
||||
## Backend Server
|
||||
|
||||
To simplify your development process, we've provided a backend server for you to develop against. The provided file [`BooksAPI.js`](src/BooksAPI.js) contains the methods you will need to perform necessary operations on the backend:
|
||||
|
||||
* [`getAll`](#getall)
|
||||
* [`update`](#update)
|
||||
* [`search`](#search)
|
||||
|
||||
### `getAll`
|
||||
|
||||
Method Signature:
|
||||
|
||||
```js
|
||||
getAll()
|
||||
```
|
||||
|
||||
* Returns a Promise which resolves to a JSON object containing a collection of book objects.
|
||||
* This collection represents the books currently in the bookshelves in your app.
|
||||
|
||||
### `update`
|
||||
|
||||
Method Signature:
|
||||
|
||||
```js
|
||||
update(book, shelf)
|
||||
```
|
||||
|
||||
* book: `<Object>` containing at minimum an `id` attribute
|
||||
* shelf: `<String>` contains one of ["wantToRead", "currentlyReading", "read"]
|
||||
* Returns a Promise which resolves to a JSON object containing the response data of the POST request
|
||||
|
||||
### `search`
|
||||
|
||||
Method Signature:
|
||||
|
||||
```js
|
||||
search(query)
|
||||
```
|
||||
|
||||
* query: `<String>`
|
||||
* Returns a Promise which resolves to a JSON object containing a collection of a maximum of 20 book objects.
|
||||
* These books do not know which shelf they are on. They are raw results only. You'll need to make sure that books have the correct state while on the search page.
|
||||
|
||||
## Important
|
||||
The backend API uses a fixed set of cached search results and is limited to a particular set of search terms, which can be found in [SEARCH_TERMS.md](SEARCH_TERMS.md). That list of terms are the _only_ terms that will work with the backend, so don't be surprised if your searches for Basket Weaving or Bubble Wrap don't come back with any results.
|
||||
|
||||
## Create React App
|
||||
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). You can find more information on how to perform common tasks [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).
|
||||
|
||||
## Contributing
|
||||
|
||||
This repository is the starter code for _all_ Udacity students. Therefore, we most likely will not accept pull requests.
|
||||
|
||||
For details, check out [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
1
SEARCH_TERMS.md
Executable file
1
SEARCH_TERMS.md
Executable file
@@ -0,0 +1 @@
|
||||
'Android', 'Art', 'Artificial Intelligence', 'Astronomy', 'Austen', 'Baseball', 'Basketball', 'Bhagat', 'Biography', 'Brief', 'Business', 'Camus', 'Cervantes', 'Christie', 'Classics', 'Comics', 'Cook', 'Cricket', 'Cycling', 'Desai', 'Design', 'Development', 'Digital Marketing', 'Drama', 'Drawing', 'Dumas', 'Education', 'Everything', 'Fantasy', 'Film', 'Finance', 'First', 'Fitness', 'Football', 'Future', 'Games', 'Gandhi', 'Homer', 'Horror', 'Hugo', 'Ibsen', 'Journey', 'Kafka', 'King', 'Lahiri', 'Larsson', 'Learn', 'Literary Fiction', 'Make', 'Manage', 'Marquez', 'Money', 'Mystery', 'Negotiate', 'Painting', 'Philosophy', 'Photography', 'Poetry', 'Production', 'Programming', 'React', 'Redux', 'River', 'Robotics', 'Rowling', 'Satire', 'Science Fiction', 'Shakespeare', 'Singh', 'Swimming', 'Tale', 'Thrun', 'Time', 'Tolstoy', 'Travel', 'Ultimate', 'Virtual Reality', 'Web Development', 'iOS'
|
||||
8748
package-lock.json
generated
Normal file
8748
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
package.json
Executable file
16
package.json
Executable file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"prop-types": "^15.5.8",
|
||||
"react": "^15.5.4",
|
||||
"react-dom": "^15.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"react-scripts": "0.9.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test --env=jsdom",
|
||||
"eject": "react-scripts eject"
|
||||
}
|
||||
}
|
||||
BIN
public/favicon.ico
Executable file
BIN
public/favicon.ico
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
32
public/index.html
Executable file
32
public/index.html
Executable file
@@ -0,0 +1,32 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
|
||||
<!--
|
||||
Notice the use of %PUBLIC_URL% in the tag above.
|
||||
It will be replaced with the URL of the `public` folder during the build.
|
||||
Only files inside the `public` folder can be referenced from the HTML.
|
||||
|
||||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||
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>MyReads</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `npm start`.
|
||||
To create a production bundle, use `npm run build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
174
src/App.css
Executable file
174
src/App.css
Executable file
@@ -0,0 +1,174 @@
|
||||
html, body, .root {
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
line-height: 1.5;
|
||||
}
|
||||
body, .app {
|
||||
background: white;
|
||||
}
|
||||
|
||||
/* main page */
|
||||
|
||||
.list-books-title {
|
||||
padding: 10px 0;
|
||||
background: #2e7c31;
|
||||
text-align: center;
|
||||
}
|
||||
.list-books-title h1 {
|
||||
font-weight: 400;
|
||||
margin: 0;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.list-books-content {
|
||||
padding: 0 0 80px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.bookshelf {
|
||||
padding: 0 10px 20px;
|
||||
}
|
||||
|
||||
@media (min-width: 600px) {
|
||||
.bookshelf {
|
||||
padding: 0 20px 40px;
|
||||
}
|
||||
}
|
||||
|
||||
.bookshelf-title {
|
||||
border-bottom: 1px solid #dedede;
|
||||
}
|
||||
.bookshelf-books {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.open-search {
|
||||
position: fixed;
|
||||
right: 25px;
|
||||
bottom: 25px;
|
||||
}
|
||||
.open-search a {
|
||||
display: block;
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 50%;
|
||||
background: #2e7d32;
|
||||
background-image: url('./icons/add.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 28px;
|
||||
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
/* search page */
|
||||
|
||||
.search-books-bar {
|
||||
position: fixed;
|
||||
width: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 5;
|
||||
display: flex;
|
||||
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 0 6px rgba(0,0,0,0.23);
|
||||
}
|
||||
.search-books-input-wrapper {
|
||||
flex: 1;
|
||||
background: #e9e;
|
||||
}
|
||||
.search-books-bar input {
|
||||
width: 100%;
|
||||
padding: 15px 10px;
|
||||
font-size: 1.25em;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.close-search {
|
||||
display: block;
|
||||
top: 20px;
|
||||
left: 15px;
|
||||
width: 50px;
|
||||
height: 53px;
|
||||
background: white;
|
||||
background-image: url('./icons/arrow-back.svg');
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 28px;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.search-books-results {
|
||||
padding: 80px 10px 20px;
|
||||
}
|
||||
|
||||
/* books grid */
|
||||
|
||||
.books-grid {
|
||||
list-style-type: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.books-grid li {
|
||||
padding: 10px 15px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.book {
|
||||
width: 140px;
|
||||
}
|
||||
.book-title,
|
||||
.book-authors {
|
||||
font-size: 0.8em;
|
||||
}
|
||||
.book-title {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.book-authors {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.book-top {
|
||||
position: relative;
|
||||
height: 200px;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.book-shelf-changer {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: -10px;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: #60ac5d;
|
||||
background-image: url('./icons/arrow-drop-down.svg');
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: 20px;
|
||||
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
||||
}
|
||||
.book-shelf-changer select {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* book cover */
|
||||
|
||||
.book-cover {
|
||||
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
|
||||
background: #eee;
|
||||
}
|
||||
.book-cover-title {
|
||||
padding: 20px 10px 0;
|
||||
text-align: center;
|
||||
font-size: 0.8em;
|
||||
}
|
||||
206
src/App.js
Executable file
206
src/App.js
Executable file
@@ -0,0 +1,206 @@
|
||||
import React from 'react'
|
||||
// import * as BooksAPI from './BooksAPI'
|
||||
import './App.css'
|
||||
|
||||
class BooksApp extends React.Component {
|
||||
state = {
|
||||
/**
|
||||
* TODO: Instead of using this state variable to keep track of which page
|
||||
* we're on, use the URL in the browser's address bar. This will ensure that
|
||||
* users can use the browser's back and forward buttons to navigate between
|
||||
* pages, as well as provide a good URL they can bookmark and share.
|
||||
*/
|
||||
showSearchPage: false
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="app">
|
||||
{this.state.showSearchPage ? (
|
||||
<div className="search-books">
|
||||
<div className="search-books-bar">
|
||||
<a className="close-search" onClick={() => this.setState({ showSearchPage: false })}>Close</a>
|
||||
<div className="search-books-input-wrapper">
|
||||
{/*
|
||||
NOTES: The search from BooksAPI is limited to a particular set of search terms.
|
||||
You can find these search terms here:
|
||||
https://github.com/udacity/reactnd-project-myreads-starter/blob/master/SEARCH_TERMS.md
|
||||
|
||||
However, remember that the BooksAPI.search method DOES search by title or author. So, don't worry if
|
||||
you don't find a specific author or title. Every search is limited by search terms.
|
||||
*/}
|
||||
<input type="text" placeholder="Search by title or author"/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div className="search-books-results">
|
||||
<ol className="books-grid"></ol>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="list-books">
|
||||
<div className="list-books-title">
|
||||
<h1>MyReads</h1>
|
||||
</div>
|
||||
<div className="list-books-content">
|
||||
<div>
|
||||
<div className="bookshelf">
|
||||
<h2 className="bookshelf-title">Currently Reading</h2>
|
||||
<div className="bookshelf-books">
|
||||
<ol className="books-grid">
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 193, backgroundImage: 'url("http://books.google.com/books/content?id=PGR2AwAAQBAJ&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE73-GnPVEyb7MOCxDzOYF1PTQRuf6nCss9LMNOSWBpxBrz8Pm2_mFtWMMg_Y1dx92HT7cUoQBeSWjs3oEztBVhUeDFQX6-tWlWz1-feexS0mlJPjotcwFqAg6hBYDXuK_bkyHD-y&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">To Kill a Mockingbird</div>
|
||||
<div className="book-authors">Harper Lee</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 188, backgroundImage: 'url("http://books.google.com/books/content?id=yDtCuFHXbAYC&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE72RRiTR6U5OUg3IY_LpHTL2NztVWAuZYNFE8dUuC0VlYabeyegLzpAnDPeWxE6RHi0C2ehrR9Gv20LH2dtjpbcUcs8YnH5VCCAH0Y2ICaKOTvrZTCObQbsfp4UbDqQyGISCZfGN&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">Enders Game</div>
|
||||
<div className="book-authors">Orson Scott Card</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bookshelf">
|
||||
<h2 className="bookshelf-title">Want to Read</h2>
|
||||
<div className="bookshelf-books">
|
||||
<ol className="books-grid">
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 193, backgroundImage: 'url("http://books.google.com/books/content?id=uu1mC6zWNTwC&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE73pGHfBNSsJG9Y8kRBpmLUft9O4BfItHioHolWNKOdLavw-SLcXADy3CPAfJ0_qMb18RmCa7Ds1cTdpM3dxAGJs8zfCfm8c6ggBIjzKT7XR5FIB53HHOhnsT7a0Cc-PpneWq9zX&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">1776</div>
|
||||
<div className="book-authors">David McCullough</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 192, backgroundImage: 'url("http://books.google.com/books/content?id=wrOQLV6xB-wC&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE72G3gA5A-Ka8XjOZGDFLAoUeMQBqZ9y-LCspZ2dzJTugcOcJ4C7FP0tDA8s1h9f480ISXuvYhA_ZpdvRArUL-mZyD4WW7CHyEqHYq9D3kGnrZCNiqxSRhry8TiFDCMWP61ujflB&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">Harry Potter and the Sorcerers Stone</div>
|
||||
<div className="book-authors">J.K. Rowling</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<div className="bookshelf">
|
||||
<h2 className="bookshelf-title">Read</h2>
|
||||
<div className="bookshelf-books">
|
||||
<ol className="books-grid">
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 192, backgroundImage: 'url("http://books.google.com/books/content?id=pD6arNyKyi8C&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE70Rw0CCwNZh0SsYpQTkMbvz23npqWeUoJvVbi_gXla2m2ie_ReMWPl0xoU8Quy9fk0Zhb3szmwe8cTe4k7DAbfQ45FEzr9T7Lk0XhVpEPBvwUAztOBJ6Y0QPZylo4VbB7K5iRSk&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">The Hobbit</div>
|
||||
<div className="book-authors">J.R.R. Tolkien</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 174, backgroundImage: 'url("http://books.google.com/books/content?id=1q_xAwAAQBAJ&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE712CA0cBYP8VKbEcIVEuFJRdX1k30rjLM29Y-dw_qU1urEZ2cQ42La3Jkw6KmzMmXIoLTr50SWTpw6VOGq1leINsnTdLc_S5a5sn9Hao2t5YT7Ax1RqtQDiPNHIyXP46Rrw3aL8&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">Oh, the Places Youll Go!</div>
|
||||
<div className="book-authors">Seuss</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div className="book">
|
||||
<div className="book-top">
|
||||
<div className="book-cover" style={{ width: 128, height: 192, backgroundImage: 'url("http://books.google.com/books/content?id=32haAAAAMAAJ&printsec=frontcover&img=1&zoom=1&imgtk=AFLRE72yckZ5f5bDFVIf7BGPbjA0KYYtlQ__nWB-hI_YZmZ-fScYwFy4O_fWOcPwf-pgv3pPQNJP_sT5J_xOUciD8WaKmevh1rUR-1jk7g1aCD_KeJaOpjVu0cm_11BBIUXdxbFkVMdi&source=gbs_api")' }}></div>
|
||||
<div className="book-shelf-changer">
|
||||
<select>
|
||||
<option value="none" disabled>Move to...</option>
|
||||
<option value="currentlyReading">Currently Reading</option>
|
||||
<option value="wantToRead">Want to Read</option>
|
||||
<option value="read">Read</option>
|
||||
<option value="none">None</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div className="book-title">The Adventures of Tom Sawyer</div>
|
||||
<div className="book-authors">Mark Twain</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="open-search">
|
||||
<a onClick={() => this.setState({ showSearchPage: true })}>Add a book</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default BooksApp
|
||||
16
src/App.test.js
Executable file
16
src/App.test.js
Executable file
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './App'
|
||||
|
||||
/**
|
||||
This course is not designed to teach Test Driven Development.
|
||||
Feel free to use this file to test your application, but it
|
||||
is not required.
|
||||
**/
|
||||
|
||||
it('renders without crashing', () => {
|
||||
const div = document.createElement('div')
|
||||
ReactDOM.render(<App />, div)
|
||||
})
|
||||
|
||||
|
||||
44
src/BooksAPI.js
Executable file
44
src/BooksAPI.js
Executable file
@@ -0,0 +1,44 @@
|
||||
|
||||
const api = "https://reactnd-books-api.udacity.com"
|
||||
|
||||
|
||||
// Generate a unique token for storing your bookshelf data on the backend server.
|
||||
let token = localStorage.token
|
||||
if (!token)
|
||||
token = localStorage.token = Math.random().toString(36).substr(-8)
|
||||
|
||||
const headers = {
|
||||
'Accept': 'application/json',
|
||||
'Authorization': token
|
||||
}
|
||||
|
||||
export const get = (bookId) =>
|
||||
fetch(`${api}/books/${bookId}`, { headers })
|
||||
.then(res => res.json())
|
||||
.then(data => data.book)
|
||||
|
||||
export const getAll = () =>
|
||||
fetch(`${api}/books`, { headers })
|
||||
.then(res => res.json())
|
||||
.then(data => data.books)
|
||||
|
||||
export const update = (book, shelf) =>
|
||||
fetch(`${api}/books/${book.id}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
...headers,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ shelf })
|
||||
}).then(res => res.json())
|
||||
|
||||
export const search = (query) =>
|
||||
fetch(`${api}/search`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...headers,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ query })
|
||||
}).then(res => res.json())
|
||||
.then(data => data.books)
|
||||
3
src/icons/add.svg
Executable file
3
src/icons/add.svg
Executable file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#ffffff" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 133 B |
3
src/icons/arrow-back.svg
Executable file
3
src/icons/arrow-back.svg
Executable file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#888888" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 158 B |
3
src/icons/arrow-drop-down.svg
Executable file
3
src/icons/arrow-drop-down.svg
Executable file
@@ -0,0 +1,3 @@
|
||||
<svg fill="#FFFFFF" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7 10l5 5 5-5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 112 B |
11
src/index.css
Executable file
11
src/index.css
Executable file
@@ -0,0 +1,11 @@
|
||||
html {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*, *:before, *:after {
|
||||
box-sizing: inherit;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
6
src/index.js
Executable file
6
src/index.js
Executable file
@@ -0,0 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom'
|
||||
import App from './App'
|
||||
import './index.css'
|
||||
|
||||
ReactDOM.render(<App />, document.getElementById('root'))
|
||||
Reference in New Issue
Block a user