From 38db5798e9c022e6c6bfef8928e44d6a3afa8d5f Mon Sep 17 00:00:00 2001 From: axelauza Date: Mon, 28 Aug 2023 01:40:00 -0500 Subject: [PATCH] Add slider pages feature --- .../components/components/BookList.js | 10 ++- .../components/components/BookList.module.css | 17 ++++- .../axelauza97/bookshelves-app/pages/index.js | 67 ++++++++++++++++--- .../bookshelves-app/styles/Home.module.css | 58 +++++++++++++++- 4 files changed, 136 insertions(+), 16 deletions(-) diff --git a/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.js b/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.js index 6c2aba649..865746ff6 100644 --- a/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.js +++ b/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.js @@ -10,13 +10,13 @@ function BookList(props) { {/*Disponibles*/} {props.type !== "wish" && props.books != null && - props.books != undefined && + props.books !== undefined && props.books.map( (bookE, i) => bookE.book.visible && (
clickHandler(bookE.book)} > {bookE.book.title} +

{bookE.book.title}

+

{bookE.book.synopsis}

) )} {props.type === "wish" && props.books != null && - props.books != undefined && + props.books !== undefined && props.books.map( (bookE, i) => bookE.book.visible && @@ -48,6 +50,8 @@ function BookList(props) { src={bookE.book.cover} alt={bookE.book.title} /> +

{bookE.book.title}

+

{bookE.book.synopsis}

) )} diff --git a/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.module.css b/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.module.css index 65401b4b5..17c5752a5 100644 --- a/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.module.css +++ b/pruebas/01-reading-list/axelauza97/bookshelves-app/components/components/BookList.module.css @@ -17,16 +17,27 @@ .darken:after { position: absolute; - height: 1rem; - width: 1rem; + /*height: 1rem; + width: 1rem;*/ top: -0.5rem; bottom: 0rem; - left: 7rem; + left: 8rem; right: 0rem; content: "\274c"; color: #fff; } +.title { + font-size: 1rem; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); + padding: 0.25rem; +} + +.synopsis { + font-size: 0.75rem; + text-shadow: 0 1px 1px rgba(255, 255, 255, 0.5); +} + @media screen and (min-width: 700px) { .bookList { margin: 2rem; diff --git a/pruebas/01-reading-list/axelauza97/bookshelves-app/pages/index.js b/pruebas/01-reading-list/axelauza97/bookshelves-app/pages/index.js index bd93b4e14..dafc71942 100644 --- a/pruebas/01-reading-list/axelauza97/bookshelves-app/pages/index.js +++ b/pruebas/01-reading-list/axelauza97/bookshelves-app/pages/index.js @@ -3,9 +3,11 @@ import classes from "@/styles/Home.module.css"; import BookList from "@/components/components/BookList"; import books from "public/books.json"; import { useEffect, useState } from "react"; - +let genre = null; +let pages = null; export default function Home(props) { - const [genre, setGenre] = useState(null); + //const [genre, setGenre] = useState(null); + const [qtyPages, setQtyPages] = useState(0); const [bookFiltered, setbookFiltered] = useState(null); const [selectedValue, setSelectedValue] = useState(""); @@ -25,14 +27,32 @@ export default function Home(props) { return book; }); } + props.setBooks(modifiedBooks); + }, []); + useEffect(() => { const uniqueGenre = new Set(); uniqueGenre.add("Todos"); - props.setBooks(modifiedBooks); - modifiedBooks.map((book) => { + props.booksD.map((book) => { uniqueGenre.add(book.book.genre); }); - setGenre(uniqueGenre); + genre = uniqueGenre; + }, []); + useEffect(() => { + const max = Math.max( + ...props.booksD.map((book) => { + return book.book.pages; + }) + ); + const min = Math.min( + ...props.booksD.map((book) => { + return book.book.pages; + }) + ); + pages = { + max: max, + min: min, + }; }, []); const moveList = (book) => { @@ -59,6 +79,7 @@ export default function Home(props) { }; const handleValueChange = (event) => { let genreSelected = event.target.value; + setQtyPages(0); setSelectedValue(genreSelected); let modifiedBooks; if (genreSelected === "Todos") { @@ -68,7 +89,7 @@ export default function Home(props) { }); } else { modifiedBooks = props.books.map((book) => { - if (book.book.genre !== genreSelected) { + if (!book.book.wish && book.book.genre !== genreSelected) { book.book.visible = false; } else { book.book.visible = true; @@ -79,6 +100,17 @@ export default function Home(props) { props.setBooks(modifiedBooks); }; + const handleQtyChange = (value) => { + setSelectedValue("Todos"); + props.books.map((book) => { + if (!book.book.wish && book.book.pages < value) { + book.book.visible = false; + } else { + book.book.visible = true; + } + }); + }; + return ( <> @@ -115,13 +147,32 @@ export default function Home(props) {
-
+
+ {`Máximo: ${qtyPages}`} + { + const value = e.target.value; + setQtyPages(value); + handleQtyChange(value); + }} + /> +

Filtrar por genero

+
- {genre !== null && Array.from(genre).map((option, index) => (