From 27d1dbeb5261fc84a122f06bcd965706083a5ddd Mon Sep 17 00:00:00 2001 From: dm1sh Date: Wed, 14 Jul 2021 16:49:25 +0500 Subject: [PATCH] Created bookshelf item component --- src/Bookshelf/BookItem/BookItem.module.css | 42 ++++++++++++++++++++++ src/Bookshelf/BookItem/index.tsx | 25 +++++++++++++ src/types/book.ts | 7 ++++ 3 files changed, 74 insertions(+) create mode 100644 src/Bookshelf/BookItem/BookItem.module.css create mode 100644 src/Bookshelf/BookItem/index.tsx create mode 100644 src/types/book.ts diff --git a/src/Bookshelf/BookItem/BookItem.module.css b/src/Bookshelf/BookItem/BookItem.module.css new file mode 100644 index 0000000..2a0f524 --- /dev/null +++ b/src/Bookshelf/BookItem/BookItem.module.css @@ -0,0 +1,42 @@ +.bookCard { + width: 300px; + border: 1px lightgray solid; + overflow: hidden; + display: flex; + justify-content: stretch; + flex-direction: column; +} + +.bookCard:hover .imageContainer { + max-height: 100%; +} + +.cardHeading { + flex-grow: 2; + display: flex; + flex-direction: column; + align-items: center; + height: auto; + justify-content: center; + padding: 10px; + transition: height 0.3s; +} + +.cardHeading > * { + width: 100%; +} + +.imageContainer { + max-height: 0%; + transition: max-height 0.3s; + overflow: hidden; + display: flex; +} + +.image { + width: 100%; + max-height: 100%; + align-self: flex-end; + object-fit: cover; + object-position: top; +} diff --git a/src/Bookshelf/BookItem/index.tsx b/src/Bookshelf/BookItem/index.tsx new file mode 100644 index 0000000..8e8cffb --- /dev/null +++ b/src/Bookshelf/BookItem/index.tsx @@ -0,0 +1,25 @@ +import React from "react"; + +import styles from "./BookItem.module.css"; + +import { IBook } from "../../types/book"; + +interface IBookItemProps extends IBook {} + +export const BookItem = ({ author, title, cover }: IBookItemProps) => { + return ( +
+
+

{title}

+

{author}

+
+
+ {title +
+
+ ); +}; diff --git a/src/types/book.ts b/src/types/book.ts new file mode 100644 index 0000000..f4d039e --- /dev/null +++ b/src/types/book.ts @@ -0,0 +1,7 @@ +export interface IBook { + title: string; + author: string; + cover?: string; + content: string; + hash?: string; +}