Skip to content
Snippets Groups Projects
SingleDialogComponent.svelte 674 B
Newer Older
Jonas Zohren's avatar
Jonas Zohren committed
<script lang="ts">
  import type { DialogOption } from "./types";
  import { createEventDispatcher } from "svelte";

  const dispatch = createEventDispatcher();

  export let imageUrl: string;
  export let title: string | undefined;
  export let text: string;
  export let options: DialogOption[];
</script>

{#if typeof title === "string"}
Jonas Zohren's avatar
Jonas Zohren committed
    {title}
Jonas Zohren's avatar
Jonas Zohren committed
{/if}

<img src={imageUrl} alt="Portrait" />

<div>
  {#each text.split("\n\n") as para}
    <p>{para}</p>
  {/each}
Jonas Zohren's avatar
Jonas Zohren committed
</div>
<hr />
<div>
  {#each options as option}
    <button on:click={() => dispatch("switchToDialog", option.linksToDialog)}
      >{option.text}</button
    >
    <br />
Jonas Zohren's avatar
Jonas Zohren committed
  {/each}
</div>