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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
<script lang="ts">
import type { ComicFilter, FullComicFragment } from '$gql/graphql';
import { CategoryLabel, CensorshipLabel, LanguageLabel, RatingLabel } from '$lib/Enums';
import { href } from '$lib/Navigation';
import { formatListSize, joinText } from '$lib/Utils';
import AssociationPill from '$lib/pills/AssociationPill.svelte';
import TagPill from '$lib/pills/TagPill.svelte';
import { formatDistance, formatISO9075 } from 'date-fns';
import Header from './DetailsHeader.svelte';
import Section from './DetailsSection.svelte';
export let comic: FullComicFragment;
const now = Date.now();
const updatedDate = new Date(comic.updatedAt);
const createdDate = new Date(comic.createdAt);
const title = joinText([
comic.category ? CategoryLabel[comic.category] : '',
formatListSize('page', comic.pages.length)
]);
function filterFor(filter: keyof ComicFilter, id: number | string) {
return href('comics', { filter: { include: { [filter]: { all: [id] } } } });
}
</script>
<div class="flex flex-col gap-4 text-sm">
<Header {title}>
{#if comic.url}
<a href={comic.url} target="_blank" rel="noreferrer" class="btn-slate" title="Open URL">
<span class="icon-base icon-[material-symbols--link]" />
</a>
{/if}
<a href={`/archives/${comic.archive.id}`} class="btn-slate" title="Go to Archive">
<span class="icon-base icon-[material-symbols--folder-zip]" />
</a>
</Header>
<div class="grid grid-cols-3 gap-4">
{#if comic.language}
<Section title="Language">
<span>{LanguageLabel[comic.language]}</span>
</Section>
{/if}
{#if comic.censorship}
<Section title="Censorship">
<span>{CensorshipLabel[comic.censorship]}</span>
</Section>
{/if}
{#if comic.rating}
<Section title="Rating">
<span>{RatingLabel[comic.rating]}</span>
</Section>
{/if}
</div>
<div class="grid grid-cols-3 gap-4">
{#if comic.date}
<Section title="Released">
<span>{formatISO9075(new Date(comic.date), { representation: 'date' })}</span>
</Section>
{/if}
<Section title="Created">
<span title={formatISO9075(createdDate)}>
{formatDistance(createdDate, now, { addSuffix: true })}
</span>
</Section>
<Section title="Updated">
<span title={formatISO9075(updatedDate)}>
{formatDistance(updatedDate, now, { addSuffix: true })}
</span>
</Section>
</div>
{#if comic.artists.length}
<Section title="Artists">
{#each comic.artists as { id, name } (id)}
<a href={filterFor('artists', id)}>
<AssociationPill {name} type="artist" />
</a>
{/each}
</Section>
{/if}
{#if comic.circles.length}
<Section title="Circles">
{#each comic.circles as { id, name } (id)}
<a href={filterFor('circles', id)}>
<AssociationPill {name} type="circle" />
</a>
{/each}
</Section>
{/if}
{#if comic.characters.length}
<Section title="Characters">
{#each comic.characters as { id, name } (id)}
<a href={filterFor('characters', id)}>
<AssociationPill {name} type="character" />
</a>
{/each}
</Section>
{/if}
{#if comic.worlds.length}
<Section title="Worlds">
{#each comic.worlds as { id, name } (id)}
<a href={filterFor('worlds', id)}>
<AssociationPill {name} type="world" />
</a>
{/each}
</Section>
{/if}
{#if comic.tags.length}
<Section title="Tags">
{#each comic.tags as { id, name, description } (id)}
<a href={filterFor('tags', id)}>
<TagPill {name} {description} />
</a>
{/each}
</Section>
{/if}
</div>
|