1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 05:05:17 +02:00

Update AdventureCard component to include viewType property and add radio buttons for card and map views

This commit is contained in:
Sean Morley 2024-04-14 17:44:52 +00:00
parent c6d8730b4c
commit 8133e8e99e
2 changed files with 43 additions and 15 deletions

View file

@ -6,6 +6,8 @@
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { onMount } from "svelte"; import { onMount } from "svelte";
let viewType: String = "cards";
function markVisited(event: { detail: string }) { function markVisited(event: { detail: string }) {
console.log(`Marked ${event.detail} as visited`); console.log(`Marked ${event.detail} as visited`);
fetch("/api/regionvisit", { fetch("/api/regionvisit", {
@ -43,6 +45,10 @@
}); });
} }
function setViewType(type: String) {
viewType = type;
}
onMount(() => { onMount(() => {
console.log(data.visitedRegions); console.log(data.visitedRegions);
}); });
@ -57,6 +63,25 @@
/> />
</h1> </h1>
<div class="join items-center justify-center flex">
<input
class="join-item btn btn-neutral"
type="radio"
name="viewtype"
checked
aria-label="Cards"
on:click={() => setViewType("cards")}
/>
<input
class="join-item btn btn-neutral"
type="radio"
name="viewtype"
aria-label="Map"
on:click={() => setViewType("map")}
/>
</div>
{#if viewType == "cards"}
<div <div
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6" class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6"
> >
@ -73,3 +98,6 @@
/> />
{/each} {/each}
</div> </div>
{/if}
{#if viewType == "map"}{/if}