Cardsizing in const

This commit is contained in:
glax 2025-05-08 05:25:36 +02:00
parent 3ad7fbfad2
commit 03c78f7b6a
2 changed files with 14 additions and 13 deletions

View File

@ -7,6 +7,7 @@ import {useEffect, useState} from "react";
import {ApiUriContext} from "./api/fetchApi.tsx"; import {ApiUriContext} from "./api/fetchApi.tsx";
import Search from './Components/Search.tsx'; import Search from './Components/Search.tsx';
import MangaList from "./Components/MangaList.tsx"; import MangaList from "./Components/MangaList.tsx";
import {CardHeight, CardWidth} from "./Components/Manga.tsx";
export default function App () { export default function App () {
@ -37,7 +38,7 @@ export default function App () {
<Badge invisible sx={{margin: "8px !important"}}> <Badge invisible sx={{margin: "8px !important"}}>
<Card onClick={() => setShowSearch(true)} sx={{height:"fit-content",width:"fit-content"}}> <Card onClick={() => setShowSearch(true)} sx={{height:"fit-content",width:"fit-content"}}>
<CardCover sx={{margin:"var(--Card-padding)"}}> <CardCover sx={{margin:"var(--Card-padding)"}}>
<img src={"/blahaj.png"} style={{height:"300px", width:"200px"}} /> <img src={"/blahaj.png"} style={{height: CardHeight + "px", width: CardWidth + "px"}} />
</CardCover> </CardCover>
<CardCover sx={{ <CardCover sx={{
background: 'rgba(234, 119, 246, 0.14)', background: 'rgba(234, 119, 246, 0.14)',
@ -45,7 +46,7 @@ export default function App () {
webkitBackdropFilter: 'blur(6.9px)', webkitBackdropFilter: 'blur(6.9px)',
}}/> }}/>
<CardContent> <CardContent>
<Box style={{height:"300px", width:"200px"}} > <Box style={{height: CardHeight + "px", width: CardWidth + "px"}} >
<Typography level={"h1"}>Search</Typography> <Typography level={"h1"}>Search</Typography>
</Box> </Box>
</CardContent> </CardContent>

View File

@ -40,6 +40,9 @@ export function MangaFromId({mangaId, children} : { mangaId: string, children?:
return <Manga manga={manga} loading={loading} children={children} /> return <Manga manga={manga} loading={loading} children={children} />
} }
export const CardWidth = 190;
export const CardHeight = 300;
export function Manga({manga, children, loading} : { manga: IManga | undefined, children?: ReactElement<any, any> | ReactElement<any, any>[] | undefined, loading?: boolean}) { export function Manga({manga, children, loading} : { manga: IManga | undefined, children?: ReactElement<any, any> | ReactElement<any, any>[] | undefined, loading?: boolean}) {
const useManga = manga ?? DefaultManga; const useManga = manga ?? DefaultManga;
loading = loading ?? false; loading = loading ?? false;
@ -78,24 +81,21 @@ export function Manga({manga, children, loading} : { manga: IManga | undefined,
CoverRef.current.src = GetMangaCoverImageUrl(apiUri, useManga.mangaId, CoverRef.current); CoverRef.current.src = GetMangaCoverImageUrl(apiUri, useManga.mangaId, CoverRef.current);
}, [useManga, apiUri]) }, [useManga, apiUri])
const width = 200;
const height = 300;
const coverSx : SxProps = { const coverSx : SxProps = {
height: height + "px", height: CardHeight + "px",
width: width + "px", width: CardWidth + "px",
position: "relative", position: "relative",
} }
const descriptionSx : SxProps = { const descriptionSx : SxProps = {
height: height + "px", height: CardHeight + "px",
width: width * 2 + "px", width: CardWidth * 2 + "px",
position: "relative" position: "relative"
} }
const coverCss : CSSProperties = { const coverCss : CSSProperties = {
maxHeight: "calc("+height+"px + 2rem)", maxHeight: "calc("+CardHeight+"px + 2rem)",
maxWidth: "calc("+width+"px + 2rem)", maxWidth: "calc("+CardWidth+"px + 2rem)",
} }
const interactiveElements = ["button", "input", "textarea", "a", "select", "option", "li"]; const interactiveElements = ["button", "input", "textarea", "a", "select", "option", "li"];
@ -129,14 +129,14 @@ export function Manga({manga, children, loading} : { manga: IManga | undefined,
expanded ? expanded ?
<Box sx={descriptionSx}> <Box sx={descriptionSx}>
<Skeleton loading={loading} variant={"text"} level={"title-lg"}> <Skeleton loading={loading} variant={"text"} level={"title-lg"}>
<Stack direction={"row"} flexWrap={"wrap"} spacing={0.5} sx={{maxHeight:height*0.3+"px", overflowY:"auto", scrollbarWidth: "thin"}}> <Stack direction={"row"} flexWrap={"wrap"} spacing={0.5} sx={{maxHeight:CardHeight*0.3+"px", overflowY:"auto", scrollbarWidth: "thin"}}>
{useManga.authorIds.map(authorId => <AuthorTag key={authorId} authorId={authorId} color={"success"} />)} {useManga.authorIds.map(authorId => <AuthorTag key={authorId} authorId={authorId} color={"success"} />)}
{useManga.tags.map(tag => <Chip key={tag} variant={"soft"} size={"md"} color={"primary"}>{tag}</Chip>)} {useManga.tags.map(tag => <Chip key={tag} variant={"soft"} size={"md"} color={"primary"}>{tag}</Chip>)}
{useManga.linkIds.map(linkId => <LinkTag key={linkId} linkId={linkId} color={"warning"} />)} {useManga.linkIds.map(linkId => <LinkTag key={linkId} linkId={linkId} color={"warning"} />)}
</Stack> </Stack>
</Skeleton> </Skeleton>
<Skeleton loading={loading} sx={{maxHeight:"300px"}}> <Skeleton loading={loading} sx={{maxHeight:"300px"}}>
<MarkdownPreview source={useManga.description} style={{backgroundColor: "transparent", color: "black", maxHeight:height*0.7+"px", overflowY:"auto", marginTop:"10px", scrollbarWidth: "thin"}} /> <MarkdownPreview source={useManga.description} style={{backgroundColor: "transparent", color: "black", maxHeight:CardHeight*0.7+"px", overflowY:"auto", marginTop:"10px", scrollbarWidth: "thin"}} />
</Skeleton> </Skeleton>
</Box> </Box>
: null : null