Created bookshelf item component

This commit is contained in:
Dmitriy Shishkov 2021-07-14 16:49:25 +05:00
parent 6574fefd36
commit 27d1dbeb52
No known key found for this signature in database
GPG Key ID: 14358F96FCDD8060
3 changed files with 74 additions and 0 deletions

View File

@ -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;
}

View File

@ -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 (
<div className={styles.bookCard}>
<div className={styles.cardHeading}>
<h1>{title}</h1>
<h2>{author}</h2>
</div>
<div className={styles.imageContainer}>
<img
className={styles.image}
src={cover}
alt={title + " cover picture"}
/>
</div>
</div>
);
};

7
src/types/book.ts Normal file
View File

@ -0,0 +1,7 @@
export interface IBook {
title: string;
author: string;
cover?: string;
content: string;
hash?: string;
}