mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-28 09:19:37 +02:00
Add popup toggle and card carousel for adventure details in map view
This commit is contained in:
parent
6137411b84
commit
172f07acca
1 changed files with 44 additions and 33 deletions
|
@ -4,6 +4,8 @@
|
||||||
import { t } from 'svelte-i18n';
|
import { t } from 'svelte-i18n';
|
||||||
import type { Adventure, VisitedRegion } from '$lib/types.js';
|
import type { Adventure, VisitedRegion } from '$lib/types.js';
|
||||||
import { getAdventureTypeLabel } from '$lib';
|
import { getAdventureTypeLabel } from '$lib';
|
||||||
|
import CardCarousel from '$lib/components/CardCarousel.svelte';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
export let data;
|
export let data;
|
||||||
|
|
||||||
let createModalOpen: boolean = false;
|
let createModalOpen: boolean = false;
|
||||||
|
@ -39,6 +41,8 @@
|
||||||
let newLongitude: number | null = null;
|
let newLongitude: number | null = null;
|
||||||
let newLatitude: number | null = null;
|
let newLatitude: number | null = null;
|
||||||
|
|
||||||
|
let openPopupId: string | null = null; // Store the ID of the currently open popup
|
||||||
|
|
||||||
function addMarker(e: { detail: { lngLat: { lng: any; lat: any } } }) {
|
function addMarker(e: { detail: { lngLat: { lng: any; lat: any } } }) {
|
||||||
newMarker = null;
|
newMarker = null;
|
||||||
newMarker = { lngLat: e.detail.lngLat };
|
newMarker = { lngLat: e.detail.lngLat };
|
||||||
|
@ -46,17 +50,17 @@
|
||||||
newLatitude = e.detail.lngLat.lat;
|
newLatitude = e.detail.lngLat.lat;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let markers = [];
|
|
||||||
|
|
||||||
// $: {
|
|
||||||
// markers = data.props.markers;
|
|
||||||
// }
|
|
||||||
|
|
||||||
function createNewAdventure(event: CustomEvent) {
|
function createNewAdventure(event: CustomEvent) {
|
||||||
adventures = [...adventures, event.detail];
|
adventures = [...adventures, event.detail];
|
||||||
newMarker = null;
|
newMarker = null;
|
||||||
createModalOpen = false;
|
createModalOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isPopupOpen = false;
|
||||||
|
|
||||||
|
function togglePopup() {
|
||||||
|
isPopupOpen = !isPopupOpen;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1 class="text-center font-bold text-4xl">Adventure Map</h1>
|
<h1 class="text-center font-bold text-4xl">Adventure Map</h1>
|
||||||
|
@ -73,7 +77,6 @@
|
||||||
<span class="label-text mr-1">Planned</span>
|
<span class="label-text mr-1">Planned</span>
|
||||||
<input type="checkbox" bind:checked={showPlanned} class="checkbox checkbox-primary" />
|
<input type="checkbox" bind:checked={showPlanned} class="checkbox checkbox-primary" />
|
||||||
</label>
|
</label>
|
||||||
<!-- <div class="divider divider-horizontal"></div> -->
|
|
||||||
<label for="show-geo">Show Visited Regions</label>
|
<label for="show-geo">Show Visited Regions</label>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
@ -120,11 +123,14 @@
|
||||||
class="grid h-8 w-8 place-items-center rounded-full border border-gray-200 bg-{adventure.is_visited
|
class="grid h-8 w-8 place-items-center rounded-full border border-gray-200 bg-{adventure.is_visited
|
||||||
? 'red'
|
? 'red'
|
||||||
: 'blue'}-300 text-black shadow-2xl focus:outline-2 focus:outline-black"
|
: 'blue'}-300 text-black shadow-2xl focus:outline-2 focus:outline-black"
|
||||||
|
on:click={togglePopup}
|
||||||
>
|
>
|
||||||
<span class="text-xl">
|
<span class="text-xl">
|
||||||
{getAdventureTypeLabel(adventure.type)}
|
{getAdventureTypeLabel(adventure.type)}
|
||||||
</span>
|
</span>
|
||||||
<Popup openOn="click" offset={[0, -10]}>
|
{#if isPopupOpen}
|
||||||
|
<Popup openOn="click" offset={[0, -10]} on:close={() => (isPopupOpen = false)}>
|
||||||
|
<CardCarousel adventures={[adventure]} />
|
||||||
<div class="text-lg text-black font-bold">{adventure.name}</div>
|
<div class="text-lg text-black font-bold">{adventure.name}</div>
|
||||||
<p class="font-semibold text-black text-md">
|
<p class="font-semibold text-black text-md">
|
||||||
{adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')}
|
{adventure.is_visited ? $t('adventures.visited') : $t('adventures.planned')}
|
||||||
|
@ -150,7 +156,12 @@
|
||||||
{/each}
|
{/each}
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
<button
|
||||||
|
class="btn btn-neutral btn-wide btn-sm mt-4"
|
||||||
|
on:click={() => goto(`/adventures/${adventure.id}`)}>View Details</button
|
||||||
|
>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
{/if}
|
||||||
</Marker>
|
</Marker>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue