mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-08-05 05:05:17 +02:00
Add featured adventure locations and fix conditional rendering in log page
This commit is contained in:
parent
ad568bb3fa
commit
9baab4c675
3 changed files with 14 additions and 4 deletions
|
@ -18,6 +18,12 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
|
<article class="prose">
|
||||||
|
<h1 class="text-center">Featured Adventure Locations</h1>
|
||||||
|
</article>
|
||||||
|
</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">
|
<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">
|
||||||
{#each data.result as adventure (adventure.id)}
|
{#each data.result as adventure (adventure.id)}
|
||||||
<FeaturedAdventureCard on:add={add} name={adventure.name} location={adventure.location} />
|
<FeaturedAdventureCard on:add={add} name={adventure.name} location={adventure.location} />
|
||||||
|
|
|
@ -107,13 +107,13 @@
|
||||||
<input class="btn btn-primary" type="submit" value="Add Adventure">
|
<input class="btn btn-primary" type="submit" value="Add Adventure">
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{#if adventures.length != 0}
|
||||||
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
<div class="flex justify-center items-center w-full mt-4 mb-4">
|
||||||
<article class="prose">
|
<article class="prose">
|
||||||
<h1 class="text-center">My Visited Adventure Locations</h1>
|
<h1 class="text-center">My Visited Adventure Locations</h1>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
{#if isShowingToast}
|
{#if isShowingToast}
|
||||||
<SucessToast action={toastAction} />
|
<SucessToast action={toastAction} />
|
||||||
|
|
|
@ -29,9 +29,10 @@ export function addAdventure(adventure: Adventure) {
|
||||||
adventures = [...adventures, adventure];
|
adventures = [...adventures, adventure];
|
||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
localStorage.setItem('adventures', JSON.stringify(adventures));
|
localStorage.setItem('adventures', JSON.stringify(adventures));
|
||||||
|
visitCount.update((n) => n + 1);
|
||||||
}
|
}
|
||||||
console.log(adventures);
|
console.log(adventures);
|
||||||
visitCount.update((n) => n + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAdventures(): Adventure[] {
|
export function getAdventures(): Adventure[] {
|
||||||
|
@ -42,8 +43,9 @@ export function removeAdventure(event: { detail: number; }) {
|
||||||
adventures = adventures.filter(adventure => adventure.id !== event.detail);
|
adventures = adventures.filter(adventure => adventure.id !== event.detail);
|
||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
localStorage.setItem('adventures', JSON.stringify(adventures));
|
localStorage.setItem('adventures', JSON.stringify(adventures));
|
||||||
}
|
|
||||||
visitCount.update((n) => n - 1);
|
visitCount.update((n) => n - 1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function saveEdit(adventure:Adventure) {
|
export function saveEdit(adventure:Adventure) {
|
||||||
|
@ -70,7 +72,9 @@ export function clearAdventures() {
|
||||||
adventures = [];
|
adventures = [];
|
||||||
if (isBrowser) {
|
if (isBrowser) {
|
||||||
localStorage.setItem('adventures', JSON.stringify(adventures));
|
localStorage.setItem('adventures', JSON.stringify(adventures));
|
||||||
|
visitCount.set(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue