2023-04-21 16:02:36 +02:00
|
|
|
<script lang="ts">
|
2023-09-21 15:29:34 +02:00
|
|
|
import type { FullWikipediaDetails } from "../../Logic/Web/Wikipedia"
|
|
|
|
|
import { Store } from "../../Logic/UIEventSource"
|
|
|
|
|
import FromHtml from "../Base/FromHtml.svelte"
|
|
|
|
|
import Loading from "../Base/Loading.svelte"
|
|
|
|
|
import Tr from "../Base/Tr.svelte"
|
|
|
|
|
import Translations from "../i18n/Translations"
|
2023-12-01 15:23:28 +01:00
|
|
|
import Wikipedia from "../../assets/svg/Wikipedia.svelte"
|
2024-07-11 16:59:10 +02:00
|
|
|
import Wikidatapreview from "./Wikidatapreview.svelte"
|
2024-07-11 19:01:32 +02:00
|
|
|
import AccordionSingle from "../Flowbite/AccordionSingle.svelte"
|
2023-04-21 16:02:36 +02:00
|
|
|
|
|
|
|
|
/**
|
2023-09-20 01:47:32 +02:00
|
|
|
* Shows a wikipedia-article + wikidata preview for the given item
|
2023-04-21 16:02:36 +02:00
|
|
|
*/
|
2023-09-21 15:29:34 +02:00
|
|
|
export let wikipediaDetails: Store<FullWikipediaDetails>
|
2024-06-16 16:06:26 +02:00
|
|
|
let titleOnly = wikipediaDetails.mapD(
|
|
|
|
|
(details) => Object.keys(details).length === 1 && details.title !== undefined
|
|
|
|
|
)
|
2023-04-21 16:02:36 +02:00
|
|
|
</script>
|
|
|
|
|
|
2024-07-11 19:01:32 +02:00
|
|
|
<div class="low-interaction border-gray-300 border-dashed rounded-xl p-2 flex flex-col">
|
|
|
|
|
{#if $titleOnly}
|
|
|
|
|
<Loading>{$wikipediaDetails.title}</Loading>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2023-09-20 01:47:32 +02:00
|
|
|
|
2024-07-11 19:01:32 +02:00
|
|
|
{#if $wikipediaDetails.wikidata}
|
|
|
|
|
<Wikidatapreview wikidata={$wikipediaDetails.wikidata} />
|
|
|
|
|
{/if}
|
2023-09-20 01:47:32 +02:00
|
|
|
|
2024-07-11 19:01:32 +02:00
|
|
|
{#if $wikipediaDetails.articleUrl}
|
|
|
|
|
{#if $wikipediaDetails.firstParagraph === "" || $wikipediaDetails.firstParagraph === undefined}
|
|
|
|
|
<Loading>
|
|
|
|
|
<Tr t={Translations.t.general.wikipedia.loading} />
|
|
|
|
|
</Loading>
|
|
|
|
|
{:else}
|
|
|
|
|
<FromHtml clss="wikipedia-article" src={$wikipediaDetails.firstParagraph} />
|
|
|
|
|
{#if $wikipediaDetails.articleUrl}
|
|
|
|
|
<a class="flex self-end my-2" href={$wikipediaDetails.articleUrl} rel="noreferrer" target="_blank">
|
|
|
|
|
<Wikipedia class="h-6 w-6" />
|
|
|
|
|
<Tr t={Translations.t.general.wikipedia.fromWikipedia} />
|
|
|
|
|
</a>
|
|
|
|
|
{/if}
|
|
|
|
|
<AccordionSingle>
|
|
|
|
|
<Tr slot="header" t={Translations.t.general.wikipedia.readMore} />
|
2023-12-19 22:08:00 +01:00
|
|
|
<FromHtml clss="wikipedia-article" src={$wikipediaDetails.restOfArticle} />
|
2024-07-11 19:01:32 +02:00
|
|
|
</AccordionSingle>
|
|
|
|
|
{/if}
|
2023-09-19 14:29:11 +02:00
|
|
|
{/if}
|
2024-07-11 19:01:32 +02:00
|
|
|
</div>
|