2024-07-08 11:44:39 -04:00
|
|
|
<script lang="ts">
|
|
|
|
import { enhance } from '$app/forms';
|
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
export let data: any;
|
|
|
|
import type { SubmitFunction } from '@sveltejs/kit';
|
|
|
|
|
|
|
|
import DotsHorizontal from '~icons/mdi/dots-horizontal';
|
|
|
|
import WeatherSunny from '~icons/mdi/weather-sunny';
|
|
|
|
import WeatherNight from '~icons/mdi/weather-night';
|
|
|
|
import Forest from '~icons/mdi/forest';
|
|
|
|
import Water from '~icons/mdi/water';
|
|
|
|
import AboutModal from './AboutModal.svelte';
|
2024-09-07 17:39:47 -04:00
|
|
|
import AccountMultiple from '~icons/mdi/account-multiple';
|
2024-07-08 11:44:39 -04:00
|
|
|
import Avatar from './Avatar.svelte';
|
2024-09-06 23:39:37 -04:00
|
|
|
import PaletteOutline from '~icons/mdi/palette-outline';
|
2024-07-17 19:35:02 -04:00
|
|
|
import { page } from '$app/stores';
|
2024-10-28 13:56:57 -04:00
|
|
|
import { t, locale, locales } from 'svelte-i18n';
|
2024-07-17 19:35:02 -04:00
|
|
|
|
|
|
|
let query: string = '';
|
2024-07-08 11:44:39 -04:00
|
|
|
|
|
|
|
let isAboutModalOpen: boolean = false;
|
|
|
|
|
2024-10-28 13:56:57 -04:00
|
|
|
const submitLocaleChange = (event: Event) => {
|
|
|
|
const select = event.target as HTMLSelectElement;
|
|
|
|
const newLocale = select.value;
|
|
|
|
document.cookie = `locale=${newLocale}; path=/`;
|
|
|
|
locale.set(newLocale);
|
|
|
|
window.location.reload();
|
|
|
|
};
|
2024-07-08 11:44:39 -04:00
|
|
|
const submitUpdateTheme: SubmitFunction = ({ action }) => {
|
|
|
|
const theme = action.searchParams.get('theme');
|
|
|
|
console.log('theme', theme);
|
|
|
|
if (theme) {
|
|
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
|
|
}
|
|
|
|
};
|
2024-07-17 19:35:02 -04:00
|
|
|
|
|
|
|
const searchGo = async (e: Event) => {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if ($page.url.pathname === '/search') {
|
2024-08-04 21:50:15 -04:00
|
|
|
let url = new URL(window.location.href);
|
|
|
|
url.searchParams.set('query', query);
|
|
|
|
goto(url.toString(), { invalidateAll: true });
|
2024-07-17 19:35:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (query) {
|
2024-08-04 21:50:15 -04:00
|
|
|
goto(`/search?query=${query}`);
|
2024-07-17 19:35:02 -04:00
|
|
|
}
|
|
|
|
};
|
2024-07-08 11:44:39 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if isAboutModalOpen}
|
|
|
|
<AboutModal on:close={() => (isAboutModalOpen = false)} />
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<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"
|
2024-08-06 12:11:50 -04:00
|
|
|
class="menu dropdown-content mt-3 z-[1] p-2 shadow bg-neutral text-neutral-content rounded-box gap-2 w-96"
|
2024-07-08 11:44:39 -04:00
|
|
|
>
|
|
|
|
{#if data.user}
|
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={() => goto('/adventures')}>{$t('navbar.adventures')}</button>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
2024-07-15 09:36:07 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={() => goto('/collections')}>{$t('navbar.collections')}</button>
|
2024-07-15 09:36:07 -04:00
|
|
|
</li>
|
2024-07-08 11:44:39 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={() => goto('/worldtravel')}>{$t('navbar.worldtravel')}</button>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
2024-07-08 15:04:23 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={() => goto('/map')}>{$t('navbar.map')}</button>
|
2024-07-08 15:04:23 -04:00
|
|
|
</li>
|
2024-09-07 17:39:47 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={() => goto('/users')}>{$t('navbar.users')}</button>
|
2024-09-07 17:39:47 -04:00
|
|
|
</li>
|
2024-07-08 11:44:39 -04:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if !data.user}
|
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-primary" on:click={() => goto('/login')}
|
2024-10-29 10:29:03 -04:00
|
|
|
>{$t('auth.login')}</button
|
2024-10-26 23:03:35 -04:00
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-primary" on:click={() => goto('/signup')}
|
2024-10-29 10:29:03 -04:00
|
|
|
>{$t('auth.signup')}</button
|
2024-10-26 23:03:35 -04:00
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
|
|
|
{/if}
|
2024-07-20 08:39:32 -04:00
|
|
|
|
|
|
|
<form class="flex gap-2">
|
|
|
|
<label class="input input-bordered flex items-center gap-2">
|
2024-10-28 13:56:57 -04:00
|
|
|
<input type="text" bind:value={query} class="grow" placeholder={$t('navbar.search')} />
|
2024-07-20 08:39:32 -04:00
|
|
|
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="currentColor"
|
|
|
|
class="h-4 w-4 opacity-70"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fill-rule="evenodd"
|
|
|
|
d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
|
|
|
|
clip-rule="evenodd"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</label>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={searchGo} type="submit" class="btn btn-primary"
|
|
|
|
>{$t('navbar.search')}</button
|
|
|
|
>
|
2024-07-20 08:39:32 -04:00
|
|
|
</form>
|
2024-07-08 11:44:39 -04:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<a class="btn btn-ghost text-xl" href="/"
|
2024-09-06 19:06:24 -04:00
|
|
|
>AdventureLog <img src="/favicon.png" alt="Map Logo" class="w-10" /></a
|
2024-07-08 11:44:39 -04:00
|
|
|
>
|
|
|
|
</div>
|
|
|
|
<div class="navbar-center hidden lg:flex">
|
|
|
|
<ul class="menu menu-horizontal px-1 gap-2">
|
|
|
|
{#if data.user}
|
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-neutral" on:click={() => goto('/adventures')}
|
|
|
|
>{$t('navbar.adventures')}</button
|
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
2024-07-15 09:36:07 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-neutral" on:click={() => goto('/collections')}
|
|
|
|
>{$t('navbar.collections')}</button
|
|
|
|
>
|
2024-07-15 09:36:07 -04:00
|
|
|
</li>
|
2024-07-08 11:44:39 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-neutral" on:click={() => goto('/worldtravel')}
|
|
|
|
>{$t('navbar.worldtravel')}</button
|
2024-07-08 11:44:39 -04:00
|
|
|
>
|
|
|
|
</li>
|
2024-07-08 15:04:23 -04:00
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-neutral" on:click={() => goto('/map')}>{$t('navbar.map')}</button>
|
2024-07-08 15:04:23 -04:00
|
|
|
</li>
|
2024-09-07 17:39:47 -04:00
|
|
|
<li>
|
|
|
|
<button class="btn btn-neutral" on:click={() => goto('/users')}
|
|
|
|
><AccountMultiple /></button
|
|
|
|
>
|
|
|
|
</li>
|
2024-07-08 11:44:39 -04:00
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if !data.user}
|
|
|
|
<li>
|
2024-10-29 10:29:03 -04:00
|
|
|
<button class="btn btn-primary" on:click={() => goto('/login')}>{$t('auth.login')}</button
|
2024-10-26 23:03:35 -04:00
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
|
|
|
<li>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button class="btn btn-primary" on:click={() => goto('/signup')}
|
2024-10-29 10:29:03 -04:00
|
|
|
>{$t('auth.signup')}</button
|
2024-10-26 23:03:35 -04:00
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
|
|
|
{/if}
|
2024-07-20 08:39:32 -04:00
|
|
|
|
|
|
|
<form class="flex gap-2">
|
|
|
|
<label class="input input-bordered flex items-center gap-2">
|
2024-10-28 13:56:57 -04:00
|
|
|
<input type="text" bind:value={query} class="grow" placeholder={$t('navbar.search')} />
|
2024-07-20 08:39:32 -04:00
|
|
|
|
|
|
|
<svg
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
viewBox="0 0 16 16"
|
|
|
|
fill="currentColor"
|
|
|
|
class="h-4 w-4 opacity-70"
|
|
|
|
>
|
|
|
|
<path
|
|
|
|
fill-rule="evenodd"
|
|
|
|
d="M9.965 11.026a5 5 0 1 1 1.06-1.06l2.755 2.754a.75.75 0 1 1-1.06 1.06l-2.755-2.754ZM10.5 7a3.5 3.5 0 1 1-7 0 3.5 3.5 0 0 1 7 0Z"
|
|
|
|
clip-rule="evenodd"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</label>
|
2024-10-26 23:03:35 -04:00
|
|
|
<button on:click={searchGo} type="submit" class="btn btn-neutral"
|
|
|
|
>{$t('navbar.search')}</button
|
|
|
|
>
|
2024-07-20 08:39:32 -04:00
|
|
|
</form>
|
2024-07-08 11:44:39 -04:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="navbar-end">
|
|
|
|
{#if data.user}
|
|
|
|
<Avatar user={data.user} />
|
|
|
|
{/if}
|
|
|
|
<div class="dropdown dropdown-bottom dropdown-end">
|
|
|
|
<div tabindex="0" role="button" class="btn m-1 ml-4">
|
|
|
|
<DotsHorizontal class="w-6 h-6" />
|
|
|
|
</div>
|
|
|
|
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
|
2024-08-06 12:11:50 -04:00
|
|
|
<ul
|
|
|
|
tabindex="0"
|
|
|
|
class="dropdown-content bg-neutral text-neutral-content z-[1] menu p-2 shadow rounded-box w-52"
|
|
|
|
>
|
2024-10-28 13:56:57 -04:00
|
|
|
<button class="btn" on:click={() => (isAboutModalOpen = true)}>{$t('navbar.about')}</button>
|
2024-08-07 17:56:53 -04:00
|
|
|
<button
|
|
|
|
class="btn btn-sm mt-2"
|
|
|
|
on:click={() => (window.location.href = 'https://docs.adventurelog.app/')}
|
2024-10-28 13:56:57 -04:00
|
|
|
>{$t('navbar.documentation')}</button
|
2024-08-07 17:56:53 -04:00
|
|
|
>
|
2024-09-10 09:30:09 -04:00
|
|
|
<button
|
|
|
|
class="btn btn-sm mt-2"
|
2024-10-28 13:56:57 -04:00
|
|
|
on:click={() => (window.location.href = 'https://discord.gg/wRbQ9Egr8C')}
|
|
|
|
>{$t('navbar.discord')}</button
|
2024-09-10 09:30:09 -04:00
|
|
|
>
|
2024-10-28 13:56:57 -04:00
|
|
|
<p class="font-bold m-4 text-lg">{$t('navbar.theme_selection')}</p>
|
2024-07-08 11:44:39 -04:00
|
|
|
<form method="POST" use:enhance={submitUpdateTheme}>
|
|
|
|
<li>
|
|
|
|
<button formaction="/?/setTheme&theme=light"
|
2024-10-28 13:56:57 -04:00
|
|
|
>{$t('navbar.themes.light')}<WeatherSunny class="w-6 h-6" />
|
2024-07-08 11:44:39 -04:00
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
2024-10-28 13:56:57 -04:00
|
|
|
<button formaction="/?/setTheme&theme=dark"
|
|
|
|
>{$t('navbar.themes.dark')}<WeatherNight class="w-6 h-6" /></button
|
2024-07-08 11:44:39 -04:00
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button formaction="/?/setTheme&theme=night"
|
2024-10-28 13:56:57 -04:00
|
|
|
>{$t('navbar.themes.night')}<WeatherNight class="w-6 h-6" /></button
|
2024-07-08 11:44:39 -04:00
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li>
|
2024-10-28 13:56:57 -04:00
|
|
|
<button formaction="/?/setTheme&theme=forest"
|
|
|
|
>{$t('navbar.themes.forest')}<Forest class="w-6 h-6" /></button
|
|
|
|
>
|
2024-09-06 23:35:48 -04:00
|
|
|
<button formaction="/?/setTheme&theme=aestheticLight"
|
2024-10-28 13:56:57 -04:00
|
|
|
>{$t('navbar.themes.aestetic-light')}<PaletteOutline class="w-6 h-6" /></button
|
2024-09-06 23:35:48 -04:00
|
|
|
>
|
|
|
|
<button formaction="/?/setTheme&theme=aestheticDark"
|
2024-10-28 13:56:57 -04:00
|
|
|
>{$t('navbar.themes.aestetic-dark')}<PaletteOutline class="w-6 h-6" /></button
|
|
|
|
>
|
|
|
|
<button formaction="/?/setTheme&theme=aqua"
|
|
|
|
>{$t('navbar.themes.aqua')}<Water class="w-6 h-6" /></button
|
2024-09-06 23:35:48 -04:00
|
|
|
>
|
2024-07-08 11:44:39 -04:00
|
|
|
</li>
|
2024-11-04 19:41:25 -05:00
|
|
|
<p class="font-bold m-4 text-lg text-center">{$t('navbar.language_selection')}</p>
|
|
|
|
<form method="POST" use:enhance>
|
|
|
|
<select
|
|
|
|
class="select select-bordered w-full max-w-xs bg-base-100 text-base-content"
|
|
|
|
on:change={submitLocaleChange}
|
|
|
|
bind:value={$locale}
|
|
|
|
>
|
|
|
|
{#each $locales as loc}
|
|
|
|
<option value={loc} class="text-base-content">{$t(`languages.${loc}`)}</option>
|
|
|
|
{/each}
|
|
|
|
</select>
|
|
|
|
<input type="hidden" name="locale" value={$locale} />
|
|
|
|
</form>
|
2024-07-08 11:44:39 -04:00
|
|
|
</form>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|