From c13a65aeb2239394bce007eda607de370ed29b8a Mon Sep 17 00:00:00 2001 From: Troels Agergaard Date: Thu, 22 Oct 2020 12:36:55 +0200 Subject: [PATCH] Add alt attribute to Card.Img component --- app/src/components/bookcard.js | 177 ++++++++++++++++----------------- 1 file changed, 85 insertions(+), 92 deletions(-) diff --git a/app/src/components/bookcard.js b/app/src/components/bookcard.js index 9f19369..597b7f8 100644 --- a/app/src/components/bookcard.js +++ b/app/src/components/bookcard.js @@ -1,102 +1,95 @@ -import PropTypes from "prop-types" -import React, { useState } from "react" -import StarRatings from "react-star-ratings" -import { Card, Row, Col } from "react-bootstrap" +import PropTypes from 'prop-types'; +import React, { useState } from 'react'; +import StarRatings from 'react-star-ratings'; +import { Card, Row, Col } from 'react-bootstrap'; -import AmazonURL from "../components/amazonurl" -import Bookmark from "../components/bookmark" -import GoodReadsImage from "../components/goodreadsimage" +import AmazonURL from '../components/amazonurl'; +import Bookmark from '../components/bookmark'; +import GoodReadsImage from '../components/goodreadsimage'; -const truncateContent = content => { - if (!content) { - return "" - } - return content.length > 350 ? content.substring(0, 350) + "..." : content -} +const truncateContent = (content) => { + if (!content) { + return ''; + } + return content.length > 350 ? content.substring(0, 350) + '...' : content; +}; -const showFullText = content => { - if (!content) { - return "" - } - return content -} +const showFullText = (content) => { + if (!content) { + return ''; + } + return content; +}; const BookCard = ({ book }) => { - const [show, toggleShow] = useState(false) - return ( - - - - - - - - {book.title} - - - {book.author} {book.year ? book.year : null} - - -
-
- {book.amazon_url ? : null} -
-
- - - -
- -
-
-

- {!show && truncateContent(book.description)} - {show && showFullText(book.description)} -

- {!show && ( - - )} - {show && ( - - )} -
- -
-
- ) -} + const [ show, toggleShow ] = useState(false); + return ( + + + + + + + + {book.title} + + + {book.author} {book.year ? book.year : null} + + +
+
+ {book.amazon_url ? : null} +
+
+ + + +
+ +
+
+

+ {!show && truncateContent(book.description)} + {show && showFullText(book.description)} +

+ {!show && ( + + )} + {show && ( + + )} +
+ +
+
+ ); +}; BookCard.propTypes = { - siteTitle: PropTypes.object, -} + siteTitle: PropTypes.object +}; BookCard.defaultProps = { - book: {}, -} + book: {} +}; -export default BookCard +export default BookCard;