├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── components ├── BookDetails │ ├── BookDetails.css │ └── BookDetails.jsx ├── BookList │ ├── Book.jsx │ ├── BookList.css │ └── BookList.jsx ├── Header │ ├── Header.css │ └── Header.jsx ├── Loader │ ├── Loader.css │ └── Loader.jsx ├── Navbar │ ├── Navbar.css │ └── Navbar.jsx └── SearchForm │ ├── SearchForm.css │ └── SearchForm.jsx ├── context..js ├── images ├── about-img.jpg ├── cover_not_found.jpg ├── library-img.jpg ├── loader.svg └── logo.png ├── index.css ├── index.js └── pages ├── About ├── About.css └── About.jsx └── Home └── Home.jsx /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | 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. 37 | 38 | 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. 39 | 40 | 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. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | 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) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | 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) 55 | 56 | ### Making a Progressive Web App 57 | 58 | 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) 59 | 60 | ### Advanced Configuration 61 | 62 | 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) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | 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) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "my_app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.4", 7 | "@testing-library/react": "^13.3.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-icons": "^4.4.0", 12 | "react-router-dom": "^6.3.0", 13 | "react-scripts": "5.0.1", 14 | "web-vitals": "^2.1.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/components/BookDetails/BookDetails.css: -------------------------------------------------------------------------------- 1 | .book-details{ 2 | padding: 6rem 0; 3 | } 4 | .back-btn{ 5 | margin-left: 20px; 6 | margin-bottom: 2.6rem; 7 | transition: var(--transition); 8 | } 9 | .back-btn:hover{ 10 | color: var(--purple-color); 11 | } 12 | .back-btn span{ 13 | margin-left: 1rem; 14 | } 15 | .book-details-content{ 16 | gap: 4rem; 17 | } 18 | .book-details-img{ 19 | max-height: 600px; 20 | overflow: hidden; 21 | } 22 | .book-details-img img{ 23 | margin: 0 auto; 24 | width: 100%; 25 | height: 100%; 26 | object-fit: cover; 27 | } 28 | .book-details-item{ 29 | margin-bottom: 1.4rem; 30 | } 31 | .book-details-item.description{ 32 | opacity: 0.8; 33 | } 34 | .book-details-info{ 35 | overflow-y: scroll; 36 | max-height: 600px; 37 | padding: 1.4rem; 38 | } 39 | .book-details-info::-webkit-scrollbar{ 40 | width: 8px; 41 | } 42 | .book-details-info::-webkit-scrollbar-track{ 43 | border-radius: 8px; 44 | box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); 45 | } 46 | .book-details-info::-webkit-scrollbar-thumb{ 47 | background-color: var(--purple-color); 48 | outline: -1px solid slategray; 49 | border-radius: 8px; 50 | } 51 | 52 | @media screen and (min-width: 768px){ 53 | .book-details-content{ 54 | grid-template-columns: 40% 60%; 55 | gap: 0 56 | } 57 | .book-details-img{ 58 | padding: 0 6rem 0 2rem; 59 | } 60 | .book-details-img img{ 61 | max-width: 100%; 62 | } 63 | } -------------------------------------------------------------------------------- /src/components/BookDetails/BookDetails.jsx: -------------------------------------------------------------------------------- 1 | import React, {useState, useEffect} from 'react'; 2 | import { useParams } from 'react-router-dom'; 3 | import Loading from "../Loader/Loader"; 4 | import coverImg from "../../images/cover_not_found.jpg"; 5 | import "./BookDetails.css"; 6 | import {FaArrowLeft} from "react-icons/fa"; 7 | import { useNavigate } from 'react-router-dom'; 8 | 9 | const URL = "https://openlibrary.org/works/"; 10 | 11 | const BookDetails = () => { 12 | const {id} = useParams(); 13 | const [loading, setLoading] = useState(false); 14 | const [book, setBook] = useState(null); 15 | const navigate = useNavigate(); 16 | 17 | useEffect(() => { 18 | setLoading(true); 19 | async function getBookDetails(){ 20 | try{ 21 | const response = await fetch(`${URL}${id}.json`); 22 | const data = await response.json(); 23 | console.log(data); 24 | 25 | if(data){ 26 | const {description, title, covers, subject_places, subject_times, subjects} = data; 27 | const newBook = { 28 | description: description ? description.value : "No description found", 29 | title: title, 30 | cover_img: covers ? `https://covers.openlibrary.org/b/id/${covers[0]}-L.jpg` : coverImg, 31 | subject_places: subject_places ? subject_places.join(", ") : "No subject places found", 32 | subject_times : subject_times ? subject_times.join(", ") : "No subject times found", 33 | subjects: subjects ? subjects.join(", ") : "No subjects found" 34 | }; 35 | setBook(newBook); 36 | } else { 37 | setBook(null); 38 | } 39 | setLoading(false); 40 | } catch(error){ 41 | console.log(error); 42 | setLoading(false); 43 | } 44 | } 45 | getBookDetails(); 46 | }, [id]); 47 | 48 | if(loading) return ; 49 | 50 | return ( 51 |
52 |
53 | 57 | 58 |
59 |
60 | cover img 61 |
62 |
63 |
64 | {book?.title} 65 |
66 |
67 | {book?.description} 68 |
69 |
70 | Subject Places: 71 | {book?.subject_places} 72 |
73 |
74 | Subject Times: 75 | {book?.subject_times} 76 |
77 |
78 | Subjects: 79 | {book?.subjects} 80 |
81 |
82 |
83 |
84 |
85 | ) 86 | } 87 | 88 | export default BookDetails -------------------------------------------------------------------------------- /src/components/BookList/Book.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | import "./BookList.css"; 4 | 5 | const Book = (book) => { 6 | return ( 7 |
8 |
9 | cover 10 |
11 |
12 | 13 |
14 | {book.title} 15 |
16 | 17 | 18 |
19 | Author: 20 | {book.author.join(", ")} 21 |
22 | 23 |
24 | Total Editions: 25 | {book.edition_count} 26 |
27 | 28 |
29 | First Publish Year: 30 | {book.first_publish_year} 31 |
32 |
33 |
34 | ) 35 | } 36 | 37 | export default Book -------------------------------------------------------------------------------- /src/components/BookList/BookList.css: -------------------------------------------------------------------------------- 1 | .booklist, .book-details{ 2 | padding: 3rem 0; 3 | background-color: #f8f9fa; 4 | } 5 | .booklist-content{ 6 | gap: 3rem; 7 | } 8 | .book-item{ 9 | padding: 3rem 2rem; 10 | border-radius: 4px; 11 | background-color: var(--white-color); 12 | box-shadow: rgba(0, 0, 0, 0.05) 0px 5px 15px 0px; 13 | transition: var(--transition); 14 | } 15 | .book-item:hover{ 16 | box-shadow: rgba(0, 0, 0, 0.15) 0px 5px 15px 0px; 17 | } 18 | .book-item-img img{ 19 | max-width: 180px; 20 | margin-right: auto; 21 | margin-left: auto; 22 | } 23 | .book-item-info{ 24 | margin-top: 2rem; 25 | } 26 | .book-item-info-item.title{ 27 | line-height: 1.4; 28 | margin-bottom: 0.8rem; 29 | } 30 | .book-item-info-item.author{ 31 | line-height: 1.4; 32 | margin-bottom: 4px; 33 | } 34 | .book-item-info-item:not(.book-item-info-item.title) span:last-child{ 35 | opacity: 0.8; 36 | } 37 | .book-item-info-item.publish-year{ 38 | opacity: 0.6; 39 | font-style: italic; 40 | font-size: 14px; 41 | } 42 | 43 | @media screen and (min-width: 600px){ 44 | .booklist-content{ 45 | grid-template-columns: repeat(2, 1fr); 46 | } 47 | } 48 | 49 | @media screen and (min-width: 992px){ 50 | .booklist-content{ 51 | grid-template-columns: repeat(3, 1fr); 52 | } 53 | .book-item-img img{ 54 | max-width: 150px; 55 | } 56 | } 57 | 58 | @media screen and (min-width: 992px){ 59 | .booklist-content{ 60 | grid-template-columns: repeat(4, 1fr); 61 | } 62 | .book-item-img img{ 63 | max-width: 120px; 64 | } 65 | } -------------------------------------------------------------------------------- /src/components/BookList/BookList.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { useGlobalContext } from '../../context.'; 3 | import Book from "../BookList/Book"; 4 | import Loading from "../Loader/Loader"; 5 | import coverImg from "../../images/cover_not_found.jpg"; 6 | import "./BookList.css"; 7 | 8 | //https://covers.openlibrary.org/b/id/240727-S.jpg 9 | 10 | const BookList = () => { 11 | const {books, loading, resultTitle} = useGlobalContext(); 12 | const booksWithCovers = books.map((singleBook) => { 13 | return { 14 | ...singleBook, 15 | // removing /works/ to get only id 16 | id: (singleBook.id).replace("/works/", ""), 17 | cover_img: singleBook.cover_id ? `https://covers.openlibrary.org/b/id/${singleBook.cover_id}-L.jpg` : coverImg 18 | } 19 | }); 20 | 21 | if(loading) return ; 22 | 23 | return ( 24 |
25 |
26 |
27 |

{resultTitle}

28 |
29 |
30 | { 31 | booksWithCovers.slice(0, 30).map((item, index) => { 32 | return ( 33 | 34 | ) 35 | }) 36 | } 37 |
38 |
39 |
40 | ) 41 | } 42 | 43 | export default BookList -------------------------------------------------------------------------------- /src/components/Header/Header.css: -------------------------------------------------------------------------------- 1 | .header-content{ 2 | min-height: 75vh; 3 | background: linear-gradient(rgba(141, 39, 174, 0.3), rgba(141, 39, 174, 0.5)), url("../../images/library-img.jpg") center/cover no-repeat; 4 | flex-direction: column; 5 | } 6 | .header-title{ 7 | font-size: 4.2rem; 8 | } 9 | .header-text{ 10 | margin-top: -1.8rem; 11 | margin-bottom: 2.8rem; 12 | opacity: 0.8; 13 | max-width: 770px; 14 | } -------------------------------------------------------------------------------- /src/components/Header/Header.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Navbar from "../Navbar/Navbar"; 3 | import SearchForm from "../SearchForm/SearchForm"; 4 | import "./Header.css"; 5 | 6 | const Header = () => { 7 | return ( 8 |
9 |
10 | 11 |
12 |

find your book of choice.


13 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quam beatae sapiente quibusdam consequatur perspiciatis facere laboriosam non nesciunt at id repudiandae, modi iste? Eligendi, rerum!

14 | 15 |
16 |
17 |
18 | ) 19 | } 20 | 21 | export default Header -------------------------------------------------------------------------------- /src/components/Loader/Loader.css: -------------------------------------------------------------------------------- 1 | .loader{ 2 | padding: 4rem 0; 3 | } 4 | .loader img{ 5 | width: 120px; 6 | } -------------------------------------------------------------------------------- /src/components/Loader/Loader.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import LoaderImg from "../../images/loader.svg"; 3 | import "./Loader.css"; 4 | 5 | const Loader = () => { 6 | return ( 7 |
8 | loader 9 |
10 | ) 11 | } 12 | 13 | export default Loader -------------------------------------------------------------------------------- /src/components/Navbar/Navbar.css: -------------------------------------------------------------------------------- 1 | .navbar{ 2 | padding: 1.8rem 0; 3 | box-shadow: rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px; 4 | } 5 | .navbar-brand{ 6 | width: 90px; 7 | } 8 | .navbar-brand span{ 9 | margin-left: 2rem; 10 | } 11 | .brand-and-toggler{ 12 | width: 100%; 13 | } 14 | .navbar-content{ 15 | display: flex; 16 | width: 100%; 17 | } 18 | .navbar-toggler-btn{ 19 | transition: var(--transition); 20 | z-index: 11; 21 | } 22 | .navbar-collapse{ 23 | position: fixed; 24 | right: 0; 25 | top: 0; 26 | z-index: 10; 27 | background-color: var(--black-color); 28 | height: 100%; 29 | width: 280px; 30 | display: flex; 31 | padding: 10rem 3rem 0 3rem; 32 | transform: translatex(100%); 33 | transition: var(--transition); 34 | } 35 | .show-navbar-collapse{ 36 | transform: translateX(0); 37 | } 38 | .nav-item{ 39 | margin-bottom: 1.4rem; 40 | } 41 | .nav-link{ 42 | transition: var(--transition); 43 | } 44 | .nav-link:hover{ 45 | color: var(--purple-color); 46 | } 47 | 48 | @media screen and (min-width: 992px){ 49 | .navbar-collapse{ 50 | position: relative; 51 | height: auto; 52 | padding: 0; 53 | width: 100%; 54 | background-color: transparent; 55 | transform: translateX(0); 56 | justify-content: flex-end; 57 | } 58 | .navbar-toggler-btn{ 59 | display: none; 60 | } 61 | .nav-item{ 62 | margin-bottom: 0; 63 | margin-left: 2.8rem; 64 | } 65 | .nav-link{ 66 | color: var(--black-color); 67 | font-size: 1.7rem; 68 | font-weight: 500!important; 69 | opacity: 0.8; 70 | } 71 | .navbar-nav{ 72 | display: flex; 73 | } 74 | } -------------------------------------------------------------------------------- /src/components/Navbar/Navbar.jsx: -------------------------------------------------------------------------------- 1 | import React, {useState} from 'react'; 2 | import { Link } from 'react-router-dom'; 3 | import "./Navbar.css"; 4 | import logoImg from "../../images/logo.png"; 5 | import {HiOutlineMenuAlt3} from "react-icons/hi"; 6 | 7 | const Navbar = () => { 8 | const [toggleMenu, setToggleMenu] = useState(false); 9 | const handleNavbar = () => setToggleMenu(!toggleMenu); 10 | 11 | return ( 12 | 38 | ) 39 | } 40 | 41 | export default Navbar -------------------------------------------------------------------------------- /src/components/SearchForm/SearchForm.css: -------------------------------------------------------------------------------- 1 | .search-form{ 2 | width: 100%; 3 | max-width: 680px; 4 | } 5 | .search-form-elem{ 6 | padding: 1.4rem 2.8rem; 7 | border-radius: 3.8rem; 8 | } 9 | .search-form-elem .form-control{ 10 | font-size: 2rem; 11 | padding: 0.6rem; 12 | } 13 | .search-form-elem .form-control::placeholder{ 14 | opacity: 0.9; 15 | } -------------------------------------------------------------------------------- /src/components/SearchForm/SearchForm.jsx: -------------------------------------------------------------------------------- 1 | import React, {useRef, useEffect} from 'react'; 2 | import {FaSearch} from "react-icons/fa"; 3 | import { useNavigate } from 'react-router-dom'; 4 | import { useGlobalContext } from '../../context.'; 5 | import "./SearchForm.css"; 6 | 7 | const SearchForm = () => { 8 | const {setSearchTerm, setResultTitle} = useGlobalContext(); 9 | const searchText = useRef(''); 10 | const navigate = useNavigate(); 11 | 12 | useEffect(() => searchText.current.focus(), []); 13 | const handleSubmit = (e) => { 14 | e.preventDefault(); 15 | let tempSearchTerm = searchText.current.value.trim(); 16 | if((tempSearchTerm.replace(/[^\w\s]/gi,"")).length === 0){ 17 | setSearchTerm("the lost world"); 18 | setResultTitle("Please Enter Something ..."); 19 | } else { 20 | setSearchTerm(searchText.current.value); 21 | } 22 | 23 | navigate("/book"); 24 | }; 25 | 26 | return ( 27 |
28 |
29 |
30 |
31 |
32 | 33 | 36 |
37 |
38 |
39 |
40 |
41 | ) 42 | } 43 | 44 | export default SearchForm -------------------------------------------------------------------------------- /src/context..js: -------------------------------------------------------------------------------- 1 | import React, {useState, useContext, useEffect} from 'react'; 2 | import { useCallback } from 'react'; 3 | const URL = "http://openlibrary.org/search.json?title="; 4 | const AppContext = React.createContext(); 5 | 6 | const AppProvider = ({children}) => { 7 | const [searchTerm, setSearchTerm] = useState("the lost world"); 8 | const [books, setBooks] = useState([]); 9 | const [loading, setLoading] = useState(true); 10 | const [resultTitle, setResultTitle] = useState(""); 11 | 12 | const fetchBooks = useCallback(async() => { 13 | setLoading(true); 14 | try{ 15 | const response = await fetch(`${URL}${searchTerm}`); 16 | const data = await response.json(); 17 | const {docs} = data; 18 | 19 | if(docs){ 20 | const newBooks = docs.slice(0, 20).map((bookSingle) => { 21 | const {key, author_name, cover_i, edition_count, first_publish_year, title} = bookSingle; 22 | 23 | return { 24 | id: key, 25 | author: author_name, 26 | cover_id: cover_i, 27 | edition_count: edition_count, 28 | first_publish_year: first_publish_year, 29 | title: title 30 | } 31 | }); 32 | 33 | setBooks(newBooks); 34 | 35 | if(newBooks.length > 1){ 36 | setResultTitle("Your Search Result"); 37 | } else { 38 | setResultTitle("No Search Result Found!") 39 | } 40 | } else { 41 | setBooks([]); 42 | setResultTitle("No Search Result Found!"); 43 | } 44 | setLoading(false); 45 | } catch(error){ 46 | console.log(error); 47 | setLoading(false); 48 | } 49 | }, [searchTerm]); 50 | 51 | useEffect(() => { 52 | fetchBooks(); 53 | }, [searchTerm, fetchBooks]); 54 | 55 | return ( 56 | 59 | {children} 60 | 61 | ) 62 | } 63 | 64 | export const useGlobalContext = () => { 65 | return useContext(AppContext); 66 | } 67 | 68 | export {AppContext, AppProvider}; -------------------------------------------------------------------------------- /src/images/about-img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/src/images/about-img.jpg -------------------------------------------------------------------------------- /src/images/cover_not_found.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/src/images/cover_not_found.jpg -------------------------------------------------------------------------------- /src/images/library-img.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/src/images/library-img.jpg -------------------------------------------------------------------------------- /src/images/loader.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunil9813/Book-Search-Site/921f68912c7378f18e33991c8e346226d1014595/src/images/logo.png -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap'); 2 | :root{ 3 | --purple-color: #8d27ae; 4 | --pink-color: #d9176d; 5 | --grey-color: #f3f3f3; 6 | --white-color: #fff; 7 | --black-color: #010101;; 8 | --light-black-color: #717171; 9 | --transition: all 300ms ease-in-out; 10 | } 11 | 12 | *{ 13 | padding: 0; 14 | margin: 0; 15 | box-sizing: border-box; 16 | } 17 | html{ 18 | font-size: 10px; 19 | } 20 | body{ 21 | font-size: 1.6rem; 22 | line-height: 1.7; 23 | font-family: 'Poppins', sans-serif; 24 | color: var(--black-color); 25 | } 26 | 27 | /* resets */ 28 | ul{ 29 | list-style-type: none; 30 | } 31 | a{ 32 | text-decoration: none; 33 | color: var(--black-color); 34 | } 35 | button{ 36 | outline: 0; 37 | border: none; 38 | font-family: inherit; 39 | background-color: transparent; 40 | cursor: pointer; 41 | } 42 | img{ 43 | width: 100%; 44 | display: block; 45 | } 46 | input{ 47 | border: none; 48 | outline: 0; 49 | font-family: inherit; 50 | font-size: 1.6rem; 51 | } 52 | .resize-animation-stopper *{ 53 | animation: none!important; 54 | transition: none!important; 55 | } 56 | 57 | /* backgrounds */ 58 | .bg-pink{background-color: var(--pink-color);} 59 | .bg-purple{background-color: var(--purple-color);} 60 | .bg-white{background-color: var(--white-color);} 61 | 62 | /* text */ 63 | .text-black{color: var(--black-color);} 64 | .text-white{color: var(--white-color);} 65 | .text-purple{color: var(--purple-color);} 66 | .text-light-black{color: var(--light-black-color);} 67 | .text-uppercase{text-transform: uppercase;} 68 | .text-center{text-align: center;} 69 | .text-capitalize{text-transform: capitalize;} 70 | .text-italic{font-style: italic;} 71 | 72 | /* font weights */ 73 | .fw-3{font-weight: 300;} 74 | .fw-4{font-weight: 400;} 75 | .fw-5{font-weight: 500;} 76 | .fw-6{font-weight: 600;} 77 | .fw-7{font-weight: 700;} 78 | .fw-8{font-weight: 800;} 79 | .fw-9{font-weight: 900;} 80 | 81 | /* font sizes */ 82 | .fs-15{font-size: 1.5rem;} 83 | .fs-16{font-size: 1.6rem;} 84 | .fs-17{font-size: 1.7rem;} 85 | .fs-18{font-size: 1.8rem;} 86 | .fs-20{font-size: 2rem;} 87 | .fs-22{font-size: 2.2rem;} 88 | .fs-24{font-size: 2.4rem;} 89 | .fs-26{font-size: 2.6rem;} 90 | 91 | /* letter spacing */ 92 | .ls-1{letter-spacing: 1px;} 93 | .ls-2{letter-spacing: 2px;} 94 | 95 | .flex{ 96 | display: flex; 97 | align-items: center; 98 | } 99 | .flex-column{ 100 | flex-direction: column; 101 | } 102 | .flex-sb{ 103 | justify-content: space-between; 104 | } 105 | .flex-c{ 106 | justify-content: center; 107 | } 108 | .grid{ 109 | display: grid; 110 | } 111 | .container{ 112 | max-width: 1200px; 113 | margin: 0 auto; 114 | padding: 0 2rem; 115 | } 116 | 117 | /* section title */ 118 | .section-title h2{ 119 | font-weight: 600; 120 | text-transform: uppercase; 121 | padding: 18px 0 24px 0; 122 | } -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import { 4 | BrowserRouter, Routes, Route 5 | } from 'react-router-dom'; 6 | import { AppProvider } from './context.'; 7 | import './index.css'; 8 | import Home from './pages/Home/Home'; 9 | import About from "./pages/About/About"; 10 | import BookList from "./components/BookList/BookList"; 11 | import BookDetails from "./components/BookDetails/BookDetails"; 12 | 13 | const root = ReactDOM.createRoot(document.getElementById('root')); 14 | root.render( 15 | 16 | 17 | 18 | }> 19 | } /> 20 | } /> 21 | } /> 22 | 23 | 24 | 25 | 26 | ); 27 | 28 | -------------------------------------------------------------------------------- /src/pages/About/About.css: -------------------------------------------------------------------------------- 1 | .about{ 2 | padding: 3rem 0; 3 | } 4 | .about-content{ 5 | gap: 4rem; 6 | } 7 | .about-title{ 8 | margin: 1rem 0; 9 | } 10 | .about-img img{ 11 | max-width: 520px; 12 | } 13 | .about-text p{ 14 | margin: 1.8rem 0; 15 | opacity: 0.8; 16 | } 17 | 18 | @media screen and (min-width: 800px){ 19 | .about-content{ 20 | grid-template-columns: repeat(2, 1fr); 21 | } 22 | .about-title{ 23 | margin-top: 0; 24 | } 25 | .about-img img{ 26 | margin-left: 0; 27 | } 28 | } -------------------------------------------------------------------------------- /src/pages/About/About.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import "./About.css"; 3 | import aboutImg from "../../images/about-img.jpg"; 4 | 5 | const About = () => { 6 | return ( 7 |
8 |
9 |
10 |

About

11 |
12 | 13 |
14 |
15 | 16 |
17 |
18 |

About BookHub

19 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusamus dignissimos consequuntur vero commodi provident maiores, iusto atque corrupti voluptate vel sequi consectetur unde aliquam corporis saepe animi non, tempora reiciendis molestias sed laudantium dolores. Assumenda aperiam fuga quo voluptate commodi ullam aliquam expedita voluptas delectus.

20 |

Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolor, dicta, possimus inventore eveniet atque voluptatibus repellendus aspernatur illo aliquam dignissimos illum. Commodi, porro omnis dolore amet neque modi quas eum!

21 |
22 |
23 |
24 |
25 | ) 26 | } 27 | 28 | export default About 29 | -------------------------------------------------------------------------------- /src/pages/Home/Home.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Header from '../../components/Header/Header'; 3 | import { Outlet } from 'react-router-dom'; 4 | 5 | const Home = () => { 6 | return ( 7 |
8 |
9 | 10 |
11 | ) 12 | } 13 | 14 | export default Home 15 | --------------------------------------------------------------------------------