|
| 1 | +import { Badge, createStyles, Divider, Grid, Group, Image, Text, Title, Tooltip } from '@mantine/core'; |
| 2 | +import { Prisma } from '@prisma/client'; |
| 3 | + |
| 4 | +const useStyles = createStyles((_theme) => ({ |
| 5 | + root: {}, |
| 6 | + placeHolder: { |
| 7 | + alignItems: 'start !important', |
| 8 | + justifyContent: 'flex-start !important', |
| 9 | + }, |
| 10 | +})); |
| 11 | + |
| 12 | +const mangaWithMetadataAndChapters = Prisma.validator<Prisma.MangaArgs>()({ |
| 13 | + include: { metadata: true, chapters: true }, |
| 14 | +}); |
| 15 | + |
| 16 | +export type MangaWithMetadataAndChapters = Prisma.MangaGetPayload<typeof mangaWithMetadataAndChapters>; |
| 17 | + |
| 18 | +export function MangaDetail({ manga }: { manga: MangaWithMetadataAndChapters }) { |
| 19 | + const { classes } = useStyles(); |
| 20 | + |
| 21 | + return ( |
| 22 | + <Grid className={classes.root}> |
| 23 | + <Grid.Col span="auto" style={{ maxWidth: 300 }}> |
| 24 | + <Image |
| 25 | + classNames={{ |
| 26 | + placeholder: classes.placeHolder, |
| 27 | + }} |
| 28 | + sx={(theme) => ({ |
| 29 | + width: 210, |
| 30 | + boxShadow: theme.shadows.xl, |
| 31 | + })} |
| 32 | + withPlaceholder |
| 33 | + placeholder={ |
| 34 | + <Image |
| 35 | + sx={(theme) => ({ |
| 36 | + width: 210, |
| 37 | + boxShadow: theme.shadows.xl, |
| 38 | + })} |
| 39 | + src="/cover-not-found.jpg" |
| 40 | + alt={manga.title} |
| 41 | + /> |
| 42 | + } |
| 43 | + src={manga.metadata.cover} |
| 44 | + /> |
| 45 | + </Grid.Col> |
| 46 | + <Grid.Col span="auto"> |
| 47 | + <Divider mb="xs" labelPosition="left" label={<Title order={3}>{manga.title}</Title>} /> |
| 48 | + <Group spacing="xs"> |
| 49 | + {manga.metadata.synonyms.map((synonym) => ( |
| 50 | + <Tooltip label={synonym} key={synonym}> |
| 51 | + <div style={{ maxWidth: 100 }}> |
| 52 | + <Badge color="blue" variant="filled" size="sm" fullWidth> |
| 53 | + {synonym} |
| 54 | + </Badge> |
| 55 | + </div> |
| 56 | + </Tooltip> |
| 57 | + ))} |
| 58 | + </Group> |
| 59 | + <Divider variant="dashed" my="xs" label="Status" /> |
| 60 | + <Badge color="cyan" variant="filled" size="sm"> |
| 61 | + {manga.metadata.status} |
| 62 | + </Badge> |
| 63 | + |
| 64 | + <Divider variant="dashed" my="xs" label="Chapters" /> |
| 65 | + <Text> |
| 66 | + There are |
| 67 | + <Badge color="teal" variant="outline" size="lg"> |
| 68 | + {manga.chapters.length} |
| 69 | + </Badge> |
| 70 | + chapters |
| 71 | + </Text> |
| 72 | + <Divider variant="dashed" my="xs" label="Summary" /> |
| 73 | + <Text size="sm">{manga.metadata.summary || 'No summary...'}</Text> |
| 74 | + <Divider variant="dashed" my="xs" label="Genres" /> |
| 75 | + <Group spacing="xs"> |
| 76 | + {manga.metadata.genres.map((genre) => ( |
| 77 | + <Tooltip label={genre} key={genre}> |
| 78 | + <div style={{ maxWidth: 100 }}> |
| 79 | + <Badge color="indigo" variant="light" size="xs" fullWidth> |
| 80 | + {genre} |
| 81 | + </Badge> |
| 82 | + </div> |
| 83 | + </Tooltip> |
| 84 | + ))} |
| 85 | + </Group> |
| 86 | + <Divider variant="dashed" my="xs" label="Tags" /> |
| 87 | + <Group spacing="xs"> |
| 88 | + {manga.metadata.tags.map((tag) => ( |
| 89 | + <Tooltip label={tag} key={tag}> |
| 90 | + <div style={{ maxWidth: 100 }}> |
| 91 | + <Badge color="violet" variant="light" size="xs" fullWidth> |
| 92 | + {tag} |
| 93 | + </Badge> |
| 94 | + </div> |
| 95 | + </Tooltip> |
| 96 | + ))} |
| 97 | + </Group> |
| 98 | + </Grid.Col> |
| 99 | + </Grid> |
| 100 | + ); |
| 101 | +} |
0 commit comments