blob: 932e5c1e9f8ef25064789a43c27ba9419b87625c (
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
|
<script lang="ts">
import type { MediaTitle } from '$lib/Data/AniList/media';
import * as tooltipper from '$lib/Tooltip/tooltip';
import { abbreviate as abbreviated } from '$lib/Utility/string';
import settings from '$stores/settings';
import * as wanakana from 'wanakana';
export let title: MediaTitle;
export let abbreviate = false;
export let abbreviateTo = 20;
export let tooltip = false;
</script>
{#if $settings.displayTitleFormat === 'native'}
{#if $settings.displayFurigana}
{@const kana = abbreviate
? abbreviated(wanakana.toKana(title.native), abbreviateTo)
: wanakana.toKana(title.native)}
{@const native = abbreviate ? abbreviated(title.native, abbreviateTo) : title.native}
<span
title={title.english || title.romaji || title.native}
use:tooltipper.default
data-tooltip-disable={!tooltip}
>
{#if kana === native}
{native}
{:else}
<ruby>
{native}
<rt>
{kana}
</rt>
</ruby>
{/if}
</span>
{:else}
<span
title={title.english || title.romaji || title.native}
use:tooltipper.default
data-tooltip-disable={!tooltip}
>
{abbreviate ? abbreviated(title.native, abbreviateTo) : title.native}
</span>
{/if}
{:else if $settings.displayTitleFormat === 'romaji'}
<span
title={title.english || title.romaji || title.native}
use:tooltipper.default
data-tooltip-disable={!tooltip}
>
{abbreviate ? abbreviated(title.romaji, abbreviateTo) : title.romaji}
</span>
{:else}
<span title={title.romaji || title.native} use:tooltipper.default data-tooltip-disable={!tooltip}>
{abbreviate
? abbreviated(title.english || title.romaji || title.native, abbreviateTo)
: title.english || title.romaji || title.native}
</span>
{/if}
|