Files
suwayomi-material-you-webui/webUI/react/src/components/MangaCard.tsx

75 lines
2.1 KiB
TypeScript
Raw Normal View History

2020-12-25 17:42:22 +01:00
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Card from '@material-ui/core/Card';
import CardActionArea from '@material-ui/core/CardActionArea';
import CardMedia from '@material-ui/core/CardMedia';
import Typography from '@material-ui/core/Typography';
2021-01-19 20:20:28 +03:30
import { Link } from 'react-router-dom';
2021-01-23 01:58:18 +03:30
import { Grid } from '@material-ui/core';
2020-12-25 17:42:22 +01:00
const useStyles = makeStyles({
root: {
height: '100%',
width: '100%',
display: 'flex',
},
wrapper: {
position: 'relative',
height: '100%',
},
gradient: {
position: 'absolute',
top: 0,
width: '100%',
height: '100%',
background: 'linear-gradient(to bottom, transparent, #000000)',
opacity: 0.5,
},
title: {
position: 'absolute',
bottom: 0,
padding: '0.5em',
color: 'white',
},
image: {
height: '100%',
width: '100%',
},
});
interface IProps {
manga: IManga
}
2021-01-22 21:11:00 +03:30
const MangaCard = React.forwardRef((props: IProps, ref) => {
2020-12-25 17:42:22 +01:00
const {
manga: {
2021-01-19 20:20:28 +03:30
id, title, thumbnailUrl,
2020-12-25 17:42:22 +01:00
},
} = props;
const classes = useStyles();
return (
2021-01-23 01:58:18 +03:30
<Grid item xs={6} sm={4} md={3} lg={2}>
<Link to={`/manga/${id}/`}>
<Card className={classes.root} ref={ref}>
<CardActionArea>
<div className={classes.wrapper}>
<CardMedia
className={classes.image}
component="img"
alt={title}
image={thumbnailUrl}
title={title}
/>
<div className={classes.gradient} />
<Typography className={classes.title} variant="h5" component="h2">{title}</Typography>
</div>
</CardActionArea>
</Card>
</Link>
</Grid>
2020-12-25 17:42:22 +01:00
);
2021-01-22 21:11:00 +03:30
});
export default MangaCard;