diff --git a/src/App.css b/src/App.css index b780245..67dac78 100644 --- a/src/App.css +++ b/src/App.css @@ -119,6 +119,7 @@ button:active { .search-books-results { padding: 80px 10px 20px; + height: 100vh; } /* books grid */ diff --git a/src/App.js b/src/App.js index 55268a5..366dc71 100644 --- a/src/App.js +++ b/src/App.js @@ -4,15 +4,16 @@ import Navigation from './components/Navigation/Navigation' import Main from './components/Main/Main' import { StoreProvider } from './Store' import { getAll, update } from './BooksAPI' - const BooksApp = () => { const [searchResults, setSearchResults] = useState([]) const [books, setBooks] = useState([]) const [shouldUpdate, setShouldUpdate] = useState(true) + const [darkTheme, setDarkTheme] = useState(true) const currentlyReading = books && books.filter((book) => book.shelf === 'currentlyReading') const wantToRead = books && books.filter((book) => book.shelf === 'wantToRead') const read = books && books.filter((book) => book.shelf === 'read') + const darkStyle = { background: '#313131' } useEffect(() => { if (shouldUpdate) { @@ -49,24 +50,27 @@ const BooksApp = () => { } return ( -
- + +
+ + + {/* Pass books down to make it available for any consumer component within the provider */} - {/* Pass books down to make it available for any consumer component within the provider */} -
- -
+
+ ) } diff --git a/src/components/Book/Book.js b/src/components/Book/Book.js index 10c4510..b17e946 100644 --- a/src/components/Book/Book.js +++ b/src/components/Book/Book.js @@ -5,8 +5,9 @@ import placeholder from '../../assets/book-placeholder.jpeg' const Book = ({ book, search }) => { const { title, authors, shelf, id, imageLinks } = book - - const { books } = useContext(StoreContext) + const { books, darkTheme } = useContext(StoreContext) + const titleDarkStyle = { color: '#7dad7b' } + const authorDarkStyle = { color: '#abb3af' } // if book list coming from search results, check if book is already is in any shelf mybooks const isBook = () => { @@ -34,8 +35,12 @@ const Book = ({ book, search }) => { -
{title}
-
{bookAuthors}
+
+ {title} +
+
+ {bookAuthors} +
) diff --git a/src/components/BookShelf/BookShelf.js b/src/components/BookShelf/BookShelf.js index dcc8b49..888fa00 100644 --- a/src/components/BookShelf/BookShelf.js +++ b/src/components/BookShelf/BookShelf.js @@ -1,9 +1,16 @@ +import { useContext } from 'react' +import { StoreContext } from '../../Store' import BookList from '../BookList/BookList' const BookShelf = ({ name, books }) => { + const { darkTheme } = useContext(StoreContext) + + const darkStyle = { color: '#7dad7b', borderBottomColor: 'rgb(97 92 92' } return (
-

{name && name}

+

+ {name && name} +

diff --git a/src/components/Navigation/Navigation.js b/src/components/Navigation/Navigation.js index 0b88ef0..c23f532 100644 --- a/src/components/Navigation/Navigation.js +++ b/src/components/Navigation/Navigation.js @@ -1,7 +1,24 @@ +import { useContext } from 'react' +import { StoreContext } from '../../Store' + const Navigation = () => { + const { darkTheme, setDarkTheme } = useContext(StoreContext) + const buttonText = darkTheme ? 'Switch to light theme' : 'Switch to dark theme' + + const style = { display: 'flex', justifyContent: 'space-between', padding: '10px 30px' } + const buttonLightStyle = { background: '#554e4e', color: '#f2f2f2' } + + const handleClick = (e) => { + e.target.blur() + setDarkTheme(!darkTheme) + } + return ( -