items per row setting (#165)

* items per row setting

self explanatory

* make it better for user
This commit is contained in:
robo
2022-04-02 01:34:10 +01:00
committed by GitHub
parent 6215ad4663
commit 9ac66d08ef
3 changed files with 133 additions and 20 deletions

View File

@@ -71,6 +71,7 @@ const truncateText = (str: string, maxLength: number) => {
interface IProps {
manga: IMangaCard
gridLayout: number | undefined
dimensions: number
}
const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref) => {
const {
@@ -79,15 +80,19 @@ const MangaCard = React.forwardRef<HTMLDivElement, IProps>((props: IProps, ref)
id, title, thumbnailUrl, downloadCount, unreadCount: unread, inLibrary,
},
gridLayout,
dimensions,
} = props;
const { options: { showUnreadBadge, showDownloadBadge } } = useLibraryOptionsContext();
const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
const [useCache] = useLocalStorage<boolean>('useCache', true);
const [ItemWidth] = useLocalStorage<number>('ItemWidth', 300);
if (gridLayout !== 2) {
const colomns = Math.round(dimensions / ItemWidth);
return (
<Grid item xs={6} sm={4} md={3} lg={2}>
// @ts-ignore gridsize type isnt allowed to be a decimal but it works fine
<Grid item lg={12 / colomns}>
<Link to={`/manga/${id}/`} style={(gridLayout === 1) ? { textDecoration: 'none' } : {}}>
<Box
sx={{