<script lang="ts">
  import Ellipsis from './Ellipsis.svelte';
  import Ripple from './Ripple.svelte';
  import Grid from './Grid.svelte';
  import Popup from '$lib/Layout/Popup.svelte';

  export let message: string | undefined = undefined;
  export let loader: 'ellipsis' | 'ripple' | 'grid' = 'ellipsis';
  export let colour = 'var(--fg)';
  export let slot = false;
  export let withReload = false;
  export let fullscreen = true;
</script>

<Popup {fullscreen} locked>
  <div class="message">
    {#if loader === 'ellipsis'}
      <Ellipsis {colour} />
    {:else if loader === 'ripple'}
      <Ripple {colour} />
    {:else if loader === 'grid'}
      <Grid {colour} />
    {/if}

    {#if message}
      <br />

      {message}
    {:else if slot}
      <br />

      <slot />

      {#if withReload}
        Please <a href={'#'} on:click={() => location.reload()}>try again</a> later.
      {/if}
    {/if}
  </div>
</Popup>

<style>
  .message {
    text-align: center;
  }
</style>
