-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #129 from seanmorley15/development
Development
- Loading branch information
Showing
8 changed files
with
324 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script lang="ts"> | ||
import type { Adventure, Collection } from '$lib/types'; | ||
import { createEventDispatcher } from 'svelte'; | ||
const dispatch = createEventDispatcher(); | ||
import { onMount } from 'svelte'; | ||
import CollectionCard from './CollectionCard.svelte'; | ||
let modal: HTMLDialogElement; | ||
let collections: Collection[] = []; | ||
onMount(async () => { | ||
modal = document.getElementById('my_modal_1') as HTMLDialogElement; | ||
if (modal) { | ||
modal.showModal(); | ||
} | ||
let res = await fetch(`/api/collections/all/`, { | ||
method: 'GET' | ||
}); | ||
let result = await res.json(); | ||
collections = result as Collection[]; | ||
if (result.type === 'success' && result.data) { | ||
collections = result.data.adventures as Collection[]; | ||
} | ||
}); | ||
function close() { | ||
dispatch('close'); | ||
} | ||
function link(event: CustomEvent<number>) { | ||
dispatch('link', event.detail); | ||
} | ||
function handleKeydown(event: KeyboardEvent) { | ||
if (event.key === 'Escape') { | ||
dispatch('close'); | ||
} | ||
} | ||
</script> | ||
|
||
<dialog id="my_modal_1" class="modal"> | ||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions --> | ||
<!-- svelte-ignore a11y-no-noninteractive-tabindex --> | ||
<div class="modal-box w-11/12 max-w-5xl" role="dialog" on:keydown={handleKeydown} tabindex="0"> | ||
<h1 class="text-center font-bold text-4xl mb-6">My Collections</h1> | ||
<div class="flex flex-wrap gap-4 mr-4 justify-center content-center"> | ||
{#each collections as collection} | ||
<CollectionCard {collection} type="link" on:link={link} /> | ||
{/each} | ||
{#if collections.length === 0} | ||
<p class="text-center text-lg">No collections found to add this adventure to.</p> | ||
{/if} | ||
</div> | ||
<button class="btn btn-primary" on:click={close}>Close</button> | ||
</div> | ||
</dialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.