hackathon/web_src/lib/components/SubmitModal.svelte

62 lines
2.1 KiB
Svelte

<script>
import { getContext } from 'svelte';
const { close } = getContext('simple-modal');
export let correct = false;
export let points = 0;
export let part = 1;
</script>
<div class="sm:flex sm:items-start pl-3 pt-2">
{#if correct}
<div
class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-green-200 sm:mx-0 sm:h-10 sm:w-10"
>
<!-- prettier-ignore -->
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-green-700" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="3">
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
</svg>
</div>
{:else}
<div
class="mx-auto flex-shrink-0 flex items-center justify-center h-12 w-12 rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10"
>
<!-- prettier-ignore -->
<svg class="h-6 w-6 text-red-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
</div>
{/if}
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left">
<h3 class="text-xl leading-6 font-medium text-gray-900" id="modal-title">
{#if correct}
Correct!
{:else}
Incorrect
{/if}
</h3>
<div class="mt-2">
<p class="text-lg text-gray-500">
{#if correct}
{#if part == 1}
You have completed the first part of the question.
<br />
You earned <strong>{points} points</strong> for part 1.
{:else}
You have completed both parts of the question.
<br />
You earned <strong>{points} points</strong> for part 2.
{/if}
{:else}
The answer you have provided was not correct. Try again!
{/if}
</p>
</div>
</div>
</div>
<div class="px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse gap-4">
<button type="button" class="btn cancel px-2 text-lg md:py-1 rounded" on:click={close}>
Close
</button>
</div>