2021-03-23 00:20:55 +01:00
|
|
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2021-03-26 00:47:02 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 21:02:12 +01:00
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2021-01-19 17:50:28 +01:00
|
|
|
import React from 'react';
|
2021-05-13 15:16:40 +02:00
|
|
|
import { makeStyles, useTheme } from '@material-ui/core/styles';
|
2021-01-19 17:50:28 +01:00
|
|
|
import Card from '@material-ui/core/Card';
|
|
|
|
import CardContent from '@material-ui/core/CardContent';
|
2021-05-13 15:16:40 +02:00
|
|
|
import IconButton from '@material-ui/core/IconButton';
|
|
|
|
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
2021-01-19 17:50:28 +01:00
|
|
|
import Typography from '@material-ui/core/Typography';
|
2021-03-23 00:20:55 +01:00
|
|
|
import { Link, useHistory } from 'react-router-dom';
|
2021-05-13 15:16:40 +02:00
|
|
|
import Menu from '@material-ui/core/Menu';
|
|
|
|
import MenuItem from '@material-ui/core/MenuItem';
|
2021-01-19 17:50:28 +01:00
|
|
|
|
|
|
|
const useStyles = makeStyles((theme) => ({
|
|
|
|
root: {
|
|
|
|
display: 'flex',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
padding: 16,
|
|
|
|
},
|
|
|
|
bullet: {
|
|
|
|
display: 'inline-block',
|
|
|
|
margin: '0 2px',
|
|
|
|
transform: 'scale(0.8)',
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
fontSize: 14,
|
|
|
|
},
|
|
|
|
pos: {
|
|
|
|
marginBottom: 12,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
width: theme.spacing(7),
|
|
|
|
height: theme.spacing(7),
|
|
|
|
flex: '0 0 auto',
|
|
|
|
marginRight: 16,
|
|
|
|
},
|
|
|
|
}));
|
|
|
|
|
2021-01-19 18:32:57 +01:00
|
|
|
interface IProps{
|
|
|
|
chapter: IChapter
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function ChapterCard(props: IProps) {
|
2021-01-19 17:50:28 +01:00
|
|
|
const classes = useStyles();
|
2021-03-18 19:16:24 +01:00
|
|
|
const history = useHistory();
|
2021-05-13 15:16:40 +02:00
|
|
|
const theme = useTheme();
|
2021-01-19 18:32:57 +01:00
|
|
|
const { chapter } = props;
|
2021-01-19 17:50:28 +01:00
|
|
|
|
2021-05-11 16:15:53 +02:00
|
|
|
const dateStr = chapter.uploadDate && new Date(chapter.uploadDate).toISOString().slice(0, 10);
|
2021-01-19 21:34:12 +01:00
|
|
|
|
2021-05-13 15:16:40 +02:00
|
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
|
|
|
|
|
|
const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
|
|
|
|
setAnchorEl(event.currentTarget);
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleClose = () => {
|
|
|
|
setAnchorEl(null);
|
|
|
|
};
|
|
|
|
|
2021-01-19 17:50:28 +01:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<li>
|
|
|
|
<Card>
|
|
|
|
<CardContent className={classes.root}>
|
2021-03-23 00:20:55 +01:00
|
|
|
<Link
|
|
|
|
to={`/manga/${chapter.mangaId}/chapter/${chapter.chapterIndex}`}
|
2021-05-13 15:16:40 +02:00
|
|
|
style={{
|
|
|
|
textDecoration: 'none',
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
}}
|
2021-03-23 00:20:55 +01:00
|
|
|
>
|
2021-05-13 15:16:40 +02:00
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
2021-03-23 00:20:55 +01:00
|
|
|
|
2021-05-13 15:16:40 +02:00
|
|
|
<Typography variant="h5" component="h2">
|
|
|
|
{chapter.name}
|
|
|
|
{chapter.chapterNumber > 0 && ` : ${chapter.chapterNumber}`}
|
|
|
|
</Typography>
|
|
|
|
<Typography variant="caption" display="block" gutterBottom>
|
|
|
|
{chapter.scanlator}
|
|
|
|
{chapter.scanlator && ' '}
|
|
|
|
{dateStr}
|
|
|
|
</Typography>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-23 00:20:55 +01:00
|
|
|
</Link>
|
|
|
|
|
2021-05-13 15:16:40 +02:00
|
|
|
<IconButton aria-label="more" onClick={handleClick}>
|
|
|
|
<MoreVertIcon />
|
|
|
|
</IconButton>
|
|
|
|
<Menu
|
|
|
|
anchorEl={anchorEl}
|
|
|
|
keepMounted
|
|
|
|
open={Boolean(anchorEl)}
|
|
|
|
onClose={handleClose}
|
|
|
|
>
|
|
|
|
{/* <MenuItem onClick={handleClose}>Download</MenuItem> */}
|
|
|
|
<MenuItem onClick={handleClose}>Bookmark</MenuItem>
|
|
|
|
<MenuItem onClick={handleClose}>Mark as Read</MenuItem>
|
|
|
|
<MenuItem onClick={handleClose}>Mark previous as Read</MenuItem>
|
|
|
|
</Menu>
|
2021-01-19 17:50:28 +01:00
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</li>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|