Skip to content

Commit

Permalink
Merge pull request #55 from seanmorley15/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
seanmorley15 authored May 5, 2024
2 parents 0fc9cc9 + d4c24df commit 25f773e
Show file tree
Hide file tree
Showing 11 changed files with 681 additions and 84 deletions.
8 changes: 8 additions & 0 deletions src/lib/components/AdventureCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
console.log(adventure.id);
goto(`/adventure/${adventure.id}`);
}
function markVisited() {
console.log(adventure.id);
dispatch("markVisited", adventure);
}
</script>

<div
Expand Down Expand Up @@ -77,6 +81,10 @@
>
{/if}
{#if type == "planner"}
<button class="btn btn-success" on:click={markVisited}
><iconify-icon icon="mdi:check-bold" class="text-2xl"
></iconify-icon></button
>
<button class="btn btn-primary" on:click={moreInfo}
><iconify-icon icon="mdi:launch" class="text-2xl"
></iconify-icon></button
Expand Down
15 changes: 5 additions & 10 deletions src/lib/components/CreateNewAdventure.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import type { Adventure } from "$lib/utils/types";
const dispatch = createEventDispatcher();
import { onMount } from "svelte";
import { addActivityType } from "$lib";
let modal: HTMLDialogElement;
onMount(() => {
Expand All @@ -25,7 +26,7 @@
});
function create() {
addActivityType();
activitySetup();
if (newAdventure.name.trim() === "") {
alert("Name is required");
return;
Expand All @@ -46,15 +47,9 @@
let activityInput: string = "";
function addActivityType() {
if (activityInput.trim() !== "") {
const activities = activityInput
.split(" ")
.filter((activity) => activity.trim() !== "");
newAdventure.activityTypes = activities;
activityInput = "";
}
console.log(newAdventure.activityTypes);
function activitySetup() {
newAdventure = addActivityType(activityInput, newAdventure);
activityInput = "";
}
</script>

Expand Down
15 changes: 5 additions & 10 deletions src/lib/components/EditModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { Adventure } from "$lib/utils/types";
const dispatch = createEventDispatcher();
import { onMount } from "svelte";
import { addActivityType } from "$lib";
let modal: HTMLDialogElement;
console.log(adventureToEdit.id);
Expand All @@ -19,7 +20,7 @@
});
function submit() {
addActivityType();
activitySetup();
dispatch("submit", adventureToEdit);
console.log(adventureToEdit);
}
Expand All @@ -36,15 +37,9 @@
let activityInput: string = "";
function addActivityType() {
if (activityInput.trim() !== "") {
const activities = activityInput
.split(",")
.filter((activity) => activity.trim() !== "");
adventureToEdit.activityTypes = activities;
activityInput = "";
}
console.log(adventureToEdit.activityTypes);
function activitySetup() {
adventureToEdit = addActivityType(activityInput, adventureToEdit);
activityInput = "";
}
</script>

Expand Down
169 changes: 169 additions & 0 deletions src/lib/components/Navbar copy.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<script lang="ts">
import { enhance } from "$app/forms";
import { visitCount } from "$lib/utils/stores/visitCountStore";
import { goto } from "$app/navigation";
import type { DatabaseUser } from "$lib/server/auth";
export let user: any;
import UserAvatar from "./UserAvatar.svelte";
import { onMount } from "svelte";
import InfoModal from "./InfoModal.svelte";
import infoIcon from "$lib/assets/info.svg";
import type { SubmitFunction } from "@sveltejs/kit";
async function goHome() {
goto("/");
}
async function goToLog() {
goto("/log");
}
async function goToFeatured() {
goto("/featured");
}
async function toToLogin() {
goto("/login");
}
async function goToSignup() {
goto("/signup");
}
async function goToWorldTravel() {
goto("/worldtravel");
}
const submitUpdateTheme: SubmitFunction = ({ action }) => {
const theme = action.searchParams.get("theme");
if (theme) {
document.documentElement.setAttribute("data-theme", theme);
}
};
let count = 0;
let infoModalOpen = false;
function showModal() {
infoModalOpen = true;
}
function closeModal() {
infoModalOpen = false;
}
// get value from fetch /api/visitcount
$: if (user) {
onMount(async () => {
const res = await fetch("/api/visitcount");
const data = await res.json();
visitCount.set(data.visitCount);
});
}
visitCount.subscribe((value) => {
count = value;
});
// Set the visit count to the number of adventures stored in local storage
const isBrowser = typeof window !== "undefined";
if (isBrowser) {
const storedAdventures = localStorage.getItem("adventures");
}
</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
>
{#if user}
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
>My Log</button
>
<button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={() => goto("/planner")}>Planner</button
>

<!-- <button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={() => goto("/planner")}>Planner</button
> -->
{/if}
<button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={goToWorldTravel}>World Tavel 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>

{#if infoModalOpen}
<InfoModal on:close={closeModal} />
{/if}
<div class="navbar-end flex justify-around md:justify-end mr-4">
{#if !user}
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
<button class="btn btn-primary ml-4" on:click={goToSignup}>Signup</button>
{/if}

{#if user}
<p class="font-bold">Adventures: {count}</p>
<UserAvatar {user} />
{/if}
<button class="btn btn-neutral ml-4 btn-circle" on:click={showModal}
><iconify-icon icon="mdi:information" class="text-xl"
></iconify-icon></button
>
<div class="dropdown dropdown-bottom dropdown-end">
<div tabindex="0" role="button" class="btn m-1 ml-4">
<iconify-icon icon="mdi:theme-light-dark" class="text-xl"
></iconify-icon>
</div>
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<ul
tabindex="0"
class="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-52"
>
<form method="POST" use:enhance={submitUpdateTheme}>
<li>
<button formaction="/?/setTheme&theme=light"
>Light<iconify-icon icon="mdi:weather-sunny" class="text-xl"
></iconify-icon></button
>
</li>
<li>
<button formaction="/?/setTheme&theme=dark"
>Dark<iconify-icon icon="mdi:weather-night" class="text-xl"
></iconify-icon></button
>
</li>
<li>
<button formaction="/?/setTheme&theme=night"
>Night<iconify-icon icon="mdi:weather-night" class="text-xl"
></iconify-icon></button
>
</li>
<!-- <li><button formaction="/?/setTheme&theme=nord">Nord</button></li> -->
<!-- <li><button formaction="/?/setTheme&theme=retro">Retro</button></li> -->
<li>
<button formaction="/?/setTheme&theme=forest"
>Forest<iconify-icon icon="mdi:forest" class="text-xl"
></iconify-icon></button
>
<button formaction="/?/setTheme&theme=garden"
>Garden<iconify-icon icon="mdi:flower" class="text-xl"
></iconify-icon></button
>
<button formaction="/?/setTheme&theme=aqua"
>Aqua<iconify-icon icon="mdi:water" class="text-xl"
></iconify-icon></button
>
</li>
</form>
</ul>
</div>
</div>
</div>
121 changes: 78 additions & 43 deletions src/lib/components/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,55 +68,90 @@
}
</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
>
{#if user}
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
>My Log</button
>
<button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={() => goto("/planner")}>Planner</button
<div class="navbar bg-base-100">
<div class="navbar-start">
<div class="dropdown">
<div tabindex="0" role="button" class="btn btn-ghost lg:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h8m-8 6h16"
/></svg
>
</div>
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<ul
tabindex="0"
class="menu menu-sm dropdown-content mt-3 z-[1] p-2 shadow bg-base-100 rounded-box w-52 gap-2"
>

<!-- <button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={() => goto("/planner")}>Planner</button
> -->
{/if}
<button
class="btn btn-primary my-2 md:my-0 md:mr-4"
on:click={goToWorldTravel}>World Tavel 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">
<li>
<button on:click={() => goto("/log")}>My Log</button>
</li>
<li>
<button on:click={() => goto("/planner")}>Planner</button>
</li>
<li>
<button on:click={() => goto("/worldtravel")}>World Travel</button>
</li>
<li>
<button on:click={() => goto("/featured")}>Featured</button>
</li>
{#if !user}
<li>
<button class="btn btn-primary" on:click={toToLogin}>Login</button>
</li>
<li>
<button class="btn btn-primary" on:click={goToSignup}>Signup</button
>
</li>
{/if}
</ul>
</div>
<a class="btn btn-ghost text-xl" href="/">AdventureLog 🗺️</a>
</div>

{#if infoModalOpen}
<InfoModal on:close={closeModal} />
{/if}
<div class="navbar-end flex justify-around md:justify-end mr-4">
{#if !user}
<button class="btn btn-primary ml-4" on:click={toToLogin}>Login</button>
<button class="btn btn-primary ml-4" on:click={goToSignup}>Signup</button>
{/if}

<div class="navbar-center hidden lg:flex">
<ul class="menu menu-horizontal px-1 gap-2">
<li>
<button class="btn btn-neutral" on:click={() => goto("/log")}
>My Log</button
>
</li>
<li>
<button class="btn btn-neutral" on:click={() => goto("/planner")}
>Planner</button
>
</li>
<li>
<button class="btn btn-neutral" on:click={() => goto("/worldtravel")}
>World Travel</button
>
</li>
<li>
<button class="btn btn-neutral" on:click={() => goto("/featured")}
>Featured</button
>
</li>
{#if !user}
<li>
<button class="btn btn-primary" on:click={toToLogin}>Login</button>
</li>
<li>
<button class="btn btn-primary" on:click={goToSignup}>Signup</button>
</li>
{/if}
</ul>
</div>
<div class="navbar-end">
{#if user}
<p class="font-bold">Adventures: {count}</p>
<UserAvatar {user} />
{/if}
<button class="btn btn-neutral ml-4 btn-circle" on:click={showModal}
><iconify-icon icon="mdi:information" class="text-xl"
></iconify-icon></button
>
<div class="dropdown dropdown-bottom dropdown-end">
<div tabindex="0" role="button" class="btn m-1 ml-4">
<iconify-icon icon="mdi:theme-light-dark" class="text-xl"
Expand Down
Loading

0 comments on commit 25f773e

Please sign in to comment.