aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Tools/Wrapped/Media.svelte
blob: 08092a282e21a4df4ec0cb1b3fdd2e6e9beb14c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<script lang="ts">
	import type { Media } from '$lib/AniList/media';
	import type { Wrapped } from '$lib/AniList/wrapped';
	import MediaTitleDisplay from '$lib/List/MediaTitleDisplay.svelte';
	import proxy from '$lib/Utility/proxy';

	export let animeList: Media[] | undefined;
	export let mangaList: Media[] | undefined;
	export let wrapped: Wrapped;
	export let updateWidth: () => void;
	export let highestRatedMediaPercentage: boolean;
	export let highestRatedCount: number;
	export let animeMostTitle: string;
	export let mangaMostTitle: string;
</script>

{#if animeList !== undefined || mangaList !== undefined}
	<div class="categories-grid">
		<div class="category-grid pure-category category middle-category">
			<div class="grid-item image-grid">
				<a
					href={animeList && animeList[0] ? `https://anilist.co/anime/${animeList[0].id}` : '#'}
					target="_blank"
				>
					<img
						src={proxy(
							animeList && animeList[0] ? animeList[0].coverImage.extraLarge : wrapped.avatar.large
						)}
						alt="Highest Rated Anime Cover"
						class="cover-image"
						on:load={updateWidth}
					/>
				</a>
				<div>
					<b>{animeMostTitle} Anime</b>
					<ol>
						{#if animeList !== undefined && animeList.length !== 0}
							{#each animeList?.slice(0, highestRatedCount) as anime}
								<li>
									<a href={`https://anilist.co/anime/${anime.id}`} target="_blank">
										<MediaTitleDisplay title={anime.title} />
									</a>{highestRatedMediaPercentage &&
									anime.mediaListEntry &&
									anime.mediaListEntry?.score > 0
										? `: ${anime.mediaListEntry?.score}%`
										: ''}
								</li>
							{/each}
						{:else}
							<li>
								<p style="opacity: 50%;">(⌣_⌣”)</p>
							</li>
						{/if}
					</ol>
				</div>
			</div>
		</div>
		<div class="category-grid pure-category category middle-category">
			<div class="grid-item image-grid">
				<a
					href={mangaList && mangaList[0] ? `https://anilist.co/manga/${mangaList[0].id}` : '#'}
					target="_blank"
				>
					<img
						src={proxy(
							mangaList && mangaList[0] ? mangaList[0].coverImage.extraLarge : wrapped.avatar.large
						)}
						alt="Highest Rated Manga Cover"
						class="cover-image"
						on:load={updateWidth}
					/>
				</a>
				<div>
					<b>{mangaMostTitle} Manga</b>
					<ol>
						{#if mangaList !== undefined && mangaList.length !== 0}
							{#each mangaList?.slice(0, highestRatedCount) as manga}
								<li>
									<a href={`https://anilist.co/manga/${manga.id}`} target="_blank">
										<MediaTitleDisplay title={manga.title} />
									</a>{highestRatedMediaPercentage &&
									manga.mediaListEntry &&
									manga.mediaListEntry?.score > 0
										? `: ${manga.mediaListEntry?.score}%`
										: ''}
								</li>
							{/each}
						{:else}
							<li>
								<p style="opacity: 50%;">(⌣_⌣”)</p>
							</li>
						{/if}
					</ol>
				</div>
			</div>
		</div>
	</div>
{/if}