aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Tools/Wrapped/MediaExtras.svelte
blob: 78b89e36fc74183933f836a650cb2e078e2942d6 (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
<script lang="ts">
  import type { TopMedia } from '$lib/Data/AniList/wrapped';
  import proxy from '$lib/Utility/proxy';

  export let topMedia: TopMedia;
  export let updateWidth: () => void;
  export let highestRatedGenreTagPercentage: boolean;
  export let genreTagTitle: string;
</script>

<div class="categories-grid" style="padding-top: 0;">
  {#if topMedia.topGenreMedia && topMedia.genres.length > 0}
    <div class="category-grid pure-category category">
      <div class="grid-item image-grid">
        <a
          href={`https://anilist.co/${topMedia.topGenreMedia.type.toLowerCase()}/${
            topMedia.topGenreMedia.id
          }`}
          target="_blank"
        >
          <img
            src={proxy(topMedia.topGenreMedia.coverImage.extraLarge)}
            alt="Highest Rated Genre Cover"
            class="cover-image"
            onload={updateWidth}
          />
        </a>
        <div>
          <b>{genreTagTitle} Genres</b>
          <ol>
            {#each topMedia.genres as genre}
              <li>
                <a href={`https://anilist.co/search/anime?genres=${genre.genre}`} target="_blank">
                  {genre.genre}{highestRatedGenreTagPercentage ? `: ${genre.averageScore}%` : ''}
                </a>
              </li>
            {/each}
          </ol>
        </div>
      </div>
    </div>
  {/if}
  {#if topMedia.topTagMedia && topMedia.tags.length > 0}
    <div class="category-grid pure-category category">
      <div class="grid-item image-grid">
        <a
          href={`https://anilist.co/${topMedia.topTagMedia.type.toLowerCase()}/${
            topMedia.topTagMedia.id
          }`}
          target="_blank"
        >
          <img
            src={proxy(topMedia.topTagMedia.coverImage.extraLarge)}
            alt="Highest Rated Tag Cover"
            class="cover-image"
            onload={updateWidth}
          />
        </a>
        <div>
          <b>{genreTagTitle} Tags</b>
          <ol>
            {#each topMedia.tags as tag}
              <li>
                <a href={`https://anilist.co/search/anime?genres=${tag.tag}`} target="_blank">
                  {tag.tag}{highestRatedGenreTagPercentage ? `: ${tag.averageScore}%` : ''}
                </a>
              </li>
            {/each}
          </ol>
        </div>
      </div>
    </div>
  {/if}
</div>