add Unread badges (#48)
* Added conditional unread badges * Better spacing for unread badges * Revert minHeight change as it is not relating to this feature * Change to flexbox
This commit is contained in:
@@ -15,7 +15,7 @@ import { Grid } from '@mui/material';
|
|||||||
import useLocalStorage from 'util/useLocalStorage';
|
import useLocalStorage from 'util/useLocalStorage';
|
||||||
import SpinnerImage from 'components/SpinnerImage';
|
import SpinnerImage from 'components/SpinnerImage';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -41,6 +41,17 @@ const useStyles = makeStyles({
|
|||||||
fontSize: '1.05rem',
|
fontSize: '1.05rem',
|
||||||
textShadow: '0px 0px 3px #000000',
|
textShadow: '0px 0px 3px #000000',
|
||||||
},
|
},
|
||||||
|
badge: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: 2,
|
||||||
|
left: 2,
|
||||||
|
backgroundColor: theme.palette.primary.dark,
|
||||||
|
borderRadius: 5,
|
||||||
|
color: 'white',
|
||||||
|
padding: '0.1em',
|
||||||
|
paddingInline: '0.3em',
|
||||||
|
fontSize: '1.05rem',
|
||||||
|
},
|
||||||
image: {
|
image: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -48,9 +59,10 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
spinner: {
|
spinner: {
|
||||||
minHeight: '400px',
|
minHeight: '400px',
|
||||||
padding: '180px calc(50% - 20px)',
|
display: 'grid',
|
||||||
|
placeItems: 'center',
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
|
|
||||||
const truncateText = (str: string, maxLength: number) => {
|
const truncateText = (str: string, maxLength: number) => {
|
||||||
const ending = '...';
|
const ending = '...';
|
||||||
@@ -69,7 +81,7 @@ interface IProps {
|
|||||||
const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref) => {
|
const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref) => {
|
||||||
const {
|
const {
|
||||||
manga: {
|
manga: {
|
||||||
id, title, thumbnailUrl,
|
id, title, thumbnailUrl, unread_count: unread,
|
||||||
},
|
},
|
||||||
} = props;
|
} = props;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
@@ -82,6 +94,13 @@ const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref)
|
|||||||
<Card className={classes.root} ref={ref}>
|
<Card className={classes.root} ref={ref}>
|
||||||
<CardActionArea>
|
<CardActionArea>
|
||||||
<div className={classes.wrapper}>
|
<div className={classes.wrapper}>
|
||||||
|
{unread
|
||||||
|
? (
|
||||||
|
<Typography className={classes.badge} component="span">
|
||||||
|
{unread}
|
||||||
|
</Typography>
|
||||||
|
)
|
||||||
|
: null}
|
||||||
<SpinnerImage
|
<SpinnerImage
|
||||||
alt={title}
|
alt={title}
|
||||||
src={`${serverAddress}${thumbnailUrl}?useCache=${useCache}`}
|
src={`${serverAddress}${thumbnailUrl}?useCache=${useCache}`}
|
||||||
|
|||||||
2
src/typings.d.ts
vendored
2
src/typings.d.ts
vendored
@@ -34,6 +34,7 @@ interface IMangaCard {
|
|||||||
id: number
|
id: number
|
||||||
title: string
|
title: string
|
||||||
thumbnailUrl: string
|
thumbnailUrl: string
|
||||||
|
unread_count?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IManga {
|
interface IManga {
|
||||||
@@ -56,6 +57,7 @@ interface IManga {
|
|||||||
realUrl: string
|
realUrl: string
|
||||||
|
|
||||||
freshData: boolean
|
freshData: boolean
|
||||||
|
unread_count?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IChapter {
|
interface IChapter {
|
||||||
|
|||||||
Reference in New Issue
Block a user