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

264 lines
10 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
2021-01-26 23:32:12 +03:30
* 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-26 23:32:12 +03:30
2021-09-09 17:51:22 +04:30
import Card from '@mui/material/Card';
import CardActionArea from '@mui/material/CardActionArea';
import Typography from '@mui/material/Typography';
2021-01-19 20:20:28 +03:30
import { Link } from 'react-router-dom';
import { Avatar, Box, CardContent, styled, Tooltip } from '@mui/material';
import { useTranslation } from 'react-i18next';
2023-10-28 00:32:02 +02:00
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { GridLayout, useLibraryOptionsContext } from '@/components/context/LibraryOptionsContext';
2023-10-28 00:32:02 +02:00
import { SpinnerImage } from '@/components/util/SpinnerImage';
2023-10-15 16:03:08 +02:00
import { TPartialManga } from '@/typings.ts';
2020-12-25 17:42:22 +01:00
2021-10-31 21:02:45 +03:30
const BottomGradient = styled('div')({
position: 'absolute',
bottom: 0,
width: '100%',
height: '30%',
background: 'linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 100%)',
});
const BottomGradientDoubledDown = styled('div')({
position: 'absolute',
bottom: 0,
width: '100%',
height: '20%',
background: 'linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,1) 100%)',
});
2021-05-28 19:37:26 +04:30
2021-10-31 21:02:45 +03:30
const MangaTitle = styled(Typography)({
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
lineHeight: '1.5rem',
maxHeight: '3rem',
display: '-webkit-box',
WebkitLineClamp: '2',
WebkitBoxOrient: 'vertical',
overflow: 'hidden',
textOverflow: 'ellipsis',
});
const GridMangaTitle = styled(MangaTitle)({
width: '100%',
2021-10-31 21:02:45 +03:30
position: 'absolute',
bottom: 0,
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
margin: '0.5em 0',
padding: '0 0.5em',
2021-10-31 21:02:45 +03:30
fontSize: '1.05rem',
});
const BadgeContainer = styled('div')({
display: 'flex',
height: 'fit-content',
2021-10-31 21:02:45 +03:30
borderRadius: '5px',
overflow: 'hidden',
'& p': {
color: 'white',
padding: '0.1em',
paddingInline: '0.2em',
fontSize: '1.05rem',
},
});
2020-12-25 17:42:22 +01:00
interface IProps {
2023-10-15 16:03:08 +02:00
manga: TPartialManga;
gridLayout?: GridLayout;
inLibraryIndicator?: boolean;
2020-12-25 17:42:22 +01:00
}
2023-10-28 00:32:02 +02:00
export const MangaCard = (props: IProps) => {
const { t } = useTranslation();
2020-12-25 17:42:22 +01:00
const {
manga: { id, title, thumbnailUrl: tmpThumbnailUrl, downloadCount, unreadCount: unread, inLibrary },
gridLayout,
inLibraryIndicator,
2020-12-25 17:42:22 +01:00
} = props;
const thumbnailUrl = tmpThumbnailUrl ?? 'nonExistingMangaUrl';
const {
options: { showUnreadBadge, showDownloadBadge },
} = useLibraryOptionsContext();
2021-10-31 21:02:45 +03:30
const mangaLinkTo = `/manga/${id}/`;
if (gridLayout !== GridLayout.List) {
return (
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<Link to={mangaLinkTo} style={gridLayout === GridLayout.Comfortable ? { textDecoration: 'none' } : {}}>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
}}
>
<Card
2021-10-31 21:02:45 +03:30
sx={{
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
// force standard aspect ratio of manga covers
aspectRatio: '225/350',
display: 'flex',
2021-10-31 21:02:45 +03:30
}}
>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<CardActionArea
sx={{
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
position: 'relative',
height: '100%',
}}
>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<BadgeContainer
sx={{
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
position: 'absolute',
top: 5,
left: 5,
}}
>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
{inLibraryIndicator && inLibrary && (
<Typography sx={{ backgroundColor: 'primary.dark', zIndex: '1' }}>
{t('manga.button.in_library')}
</Typography>
)}
2023-10-15 16:03:08 +02:00
{showUnreadBadge && (unread ?? 0) > 0 && (
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<Typography sx={{ backgroundColor: 'primary.dark' }}>{unread}</Typography>
)}
2023-10-15 16:03:08 +02:00
{showDownloadBadge && (downloadCount ?? 0) > 0 && (
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<Typography
sx={{
backgroundColor: 'success.dark',
}}
>
{downloadCount}
</Typography>
)}
</BadgeContainer>
<SpinnerImage
alt={title}
src={requestManager.getValidImgUrlFor(thumbnailUrl)}
imgStyle={
inLibraryIndicator && inLibrary
? {
height: '100%',
width: '100%',
objectFit: 'cover',
filter: 'brightness(0.4)',
}
: {
height: '100%',
width: '100%',
objectFit: 'cover',
}
}
spinnerStyle={{
display: 'grid',
placeItems: 'center',
}}
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
/>
{gridLayout !== GridLayout.Comfortable && (
<>
<BottomGradient />
<BottomGradientDoubledDown />
<Tooltip title={title} placement="top">
<GridMangaTitle
sx={{
color: 'white',
textShadow: '0px 0px 3px #000000',
}}
>
{title}
</GridMangaTitle>
</Tooltip>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
</>
)}
</CardActionArea>
</Card>
{gridLayout === GridLayout.Comfortable && (
<Tooltip title={title} placement="top">
<GridMangaTitle
sx={{
position: 'relative',
color: 'text.primary',
height: '3rem',
}}
>
{title}
</GridMangaTitle>
</Tooltip>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
)}
</Box>
</Link>
);
}
return (
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
<Card>
<CardActionArea component={Link} to={mangaLinkTo}>
<CardContent
sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
padding: 2,
position: 'relative',
}}
>
<Avatar
variant="rounded"
sx={
inLibraryIndicator && inLibrary
? {
width: 56,
height: 56,
flex: '0 0 auto',
marginRight: 2,
imageRendering: 'pixelated',
filter: 'brightness(0.4)',
}
: {
width: 56,
height: 56,
flex: '0 0 auto',
marginRight: 2,
imageRendering: 'pixelated',
}
}
src={requestManager.getValidImgUrlFor(thumbnailUrl)}
/>
<Box
sx={{
display: 'flex',
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
flexDirection: 'row',
flexGrow: 1,
width: 'min-content',
}}
>
<Tooltip title={title} placement="top">
<MangaTitle variant="h5">{title}</MangaTitle>
</Tooltip>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
</Box>
<BadgeContainer>
{inLibraryIndicator && inLibrary && (
<Typography sx={{ backgroundColor: 'primary.dark' }}>
{t('manga.button.in_library')}
</Typography>
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
)}
{showUnreadBadge && unread! > 0 && (
<Typography sx={{ backgroundColor: 'primary.dark' }}>{unread}</Typography>
)}
{showDownloadBadge && downloadCount! > 0 && (
<Typography
sx={{
backgroundColor: 'success.dark',
}}
>
{downloadCount}
</Typography>
)}
</BadgeContainer>
</CardContent>
</CardActionArea>
</Card>
2020-12-25 17:42:22 +01:00
);
Feature/virtualize manga grid (#363) * Disable ssr by default for "useMediaQuery" SSR would cause the hook to run once with default values and only after the first render with real values. This can cause issue on rendering when depending on useMediaQuery results like in 8c129f2e08e8c807b57c7eef802556faa2edcf1b * Virtualize manga grids * Remove SourceMangas load more guard Was required due to the previous load more trigger logic from the MangaGrid. Due to using Virtuoso now, load more will be triggered only once when the bottom of the grid was reached and thus won't trigger multiple load more requests * Remove old Library pagination Pagination is handled by virtuoso, thus, the previous pagination can be removed * Increase initial loaded pages to make infinite load work virtuoso requires enough initial items to be rendered, so that actual virtualization takes effect, for it to fire "endReached" * Prevent virtuoso grid scrollbar from jumping around In case the items have a big height difference there is a bug where the scrollbar starts jumping around the moment these new items are rendered * Restore scroll position For some reason the UI jumps around when accessing "document.documentElement" during loading more items. After the items are rendered the loading placeholder gets removed and the previous items jump to the bottom of the viewport. * Limit manga grid titles to two lines * Remove "last page" info from MangaGrid Info is not needed. The only thing the MangaGrid has to do is to trigger a request to load more data
2023-06-17 16:50:17 +02:00
};