Update startup.sh, +page.server.ts, FeaturedAdventureCard.svelte, and Navbar.svelte

This commit is contained in:
Sean Morley
2024-04-02 18:04:27 +00:00
parent f86151ee5e
commit 4b2306f812
7 changed files with 143 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import locationDot from "$lib/assets/locationDot.svg";
import calendar from "$lib/assets/calendar.svg";
const dispatch = createEventDispatcher();
export let name:String;
export let location:String;
function add() {
dispatch('add', {name, location});
}
</script>
<div class="card min-w-max lg:w-96 md:w-80 sm:w-60 xs:w-40 bg-neutral shadow-xl overflow-hidden">
<div class="card-body">
<h2 class="card-title overflow-ellipsis">{name}</h2>
<p><img src={locationDot} class="inline-block -mt-1 mr-1" alt="Logo" />{location}</p>
<div class="card-actions justify-end">
<button class="btn btn-primary" on:click={add}>Add</button>
</div>
</div>
</div>

View File

@@ -8,16 +8,20 @@
async function goToLog() {
goto('/log');
}
async function goToFeatured() {
goto('/featured');
}
</script>
<div class="navbar bg-base-100 flex flex-col md:flex-row">
<div class="navbar-start flex justify-around md:justify-start">
<button class="btn btn-primary my-2 md:my-0 md:mr-4 md:ml-2" on:click={goHome}>Home</button>
<button class="btn btn-primary my-2 md:my-0" on:click={goToLog}>My Log</button>
<button class="btn btn-primary my-2 md:my-0 md:mr-4 md:ml-2" on:click={goToLog}>My Log</button>
<button class="btn btn-primary my-2 md:my-0" on:click={goToFeatured}>Featured</button>
</div>
<div class="navbar-center flex justify-center md:justify-center">
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
</div>
<div class="navbar-end flex justify-around md:justify-end">
<div class="navbar-end flex justify-around md:justify-end mr-4">
<p>Adventures: {getNumberOfAdventures()} </p>
</div>
</div>

View File

@@ -4,7 +4,7 @@ import type { Adventure } from '$lib/utils/types';
export const load = (async () => {
const result = await db.select().from(featuredAdventures)
const result = await db.select().from(featuredAdventures).orderBy(featuredAdventures.id);
return {
result : result as Adventure[]
};

View File

@@ -1,11 +1,25 @@
<script lang="ts">
export let data
console.log(data.result);
import AdventureCard from '$lib/components/AdventureCard.svelte';
import FeaturedAdventureCard from '$lib/components/FeaturedAdventureCard.svelte';
import type { Adventure } from '$lib/utils/types.js';
import { addAdventure, getNextId } from '../../services/adventureService.js';
function add(event: CustomEvent<{name: string, location: string}>) {
console.log(event.detail);
let newAdventure:Adventure = {
id: getNextId(),
name: event.detail.name,
location: event.detail.location,
created: ""
}
addAdventure(newAdventure);
}
</script>
<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)}
<AdventureCard id={adventure.id} name={adventure.name} location={adventure.location} created={adventure.created} />
<FeaturedAdventureCard on:add={add} name={adventure.name} location={adventure.location} />
{/each}
</div>

View File

@@ -94,6 +94,12 @@
</script>
<div class="flex justify-center items-center w-full mt-4 mb-4">
<article class="prose">
<h2 class="text-center">Add new Location</h2>
</article>
</div>
<div class="flex flex-row items-center justify-center gap-4">
<form on:submit={createNewAdventure} class="flex gap-2">
<input type="text" bind:value={newName} placeholder="Adventure Name" class="input input-bordered w-full max-w-xs" />
@@ -102,6 +108,13 @@
</form>
</div>
<div class="flex justify-center items-center w-full mt-4 mb-4">
<article class="prose">
<h1 class="text-center">My Visited Adventure Locations</h1>
</article>
</div>
{#if isShowingToast}
<SucessToast action={toastAction} />
{/if}
@@ -124,7 +137,7 @@
{/if}
{#if adventures.length != 0}
<div class="flex flex-row items-center justify-center mt-16 gap-4">
<div class="flex flex-row items-center justify-center mt-16 gap-4 mb-4">
<button class="btn btn-neutral" on:click={async () => { window.location.href = exportData(); }}>
<img src={exportFile} class="inline-block -mt-1" alt="Logo" /> Save as File
</button>