bugfix(frontend): added use:link to the logos href to prevent full page reload
Bug: Every click of the logo would consistently do a full page reload - Logo clicking now uses svelte-spa-router's link Apply consistent formatting to Header.svelte: - Add semicolons to all statements - Improve JSX/HTML attribute formatting for better readability - Add link import from svelte-spa-router for SPA navigation - Format multi-line attributes with proper indentation These changes improve code consistency and maintainability without altering any functionality.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Search from "./Search.svelte"
|
import Search from "./Search.svelte";
|
||||||
import {
|
import {
|
||||||
aniListLoggedIn,
|
aniListLoggedIn,
|
||||||
loginToAniList,
|
loginToAniList,
|
||||||
@@ -7,55 +7,81 @@
|
|||||||
loginToSimkl,
|
loginToSimkl,
|
||||||
malLoggedIn,
|
malLoggedIn,
|
||||||
simklLoggedIn,
|
simklLoggedIn,
|
||||||
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import AvatarMenu from "./AvatarMenu.svelte";
|
import AvatarMenu from "./AvatarMenu.svelte";
|
||||||
import logo from "../assets/images/AniTrackLogo.svg"
|
import logo from "../assets/images/AniTrackLogo.svg";
|
||||||
|
import { link } from "svelte-spa-router";
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean;
|
||||||
let isSimklLoggedIn: boolean
|
let isSimklLoggedIn: boolean;
|
||||||
let isMALLoggedIn: boolean
|
let isMALLoggedIn: boolean;
|
||||||
|
|
||||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
aniListLoggedIn.subscribe((value) => (isAniListLoggedIn = value));
|
||||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
simklLoggedIn.subscribe((value) => (isSimklLoggedIn = value));
|
||||||
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
|
malLoggedIn.subscribe((value) => (isMALLoggedIn = value));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav class="border-gray-200 bg-gray-900">
|
<nav class="border-gray-200 bg-gray-900">
|
||||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
<div
|
||||||
|
class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4"
|
||||||
|
>
|
||||||
<div class="flex items-center space-x-3 rtl:space-x-reverse">
|
<div class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||||
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
<a href="/" use:link
|
||||||
|
><img src={logo} class="h-8" alt="AniTrack Logo" /></a
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
<div
|
||||||
|
class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse"
|
||||||
|
>
|
||||||
<div class="min-[950px]:block min-[950px]:mr-4">
|
<div class="min-[950px]:block min-[950px]:mr-4">
|
||||||
<Search />
|
<Search />
|
||||||
</div>
|
</div>
|
||||||
<AvatarMenu/>
|
<AvatarMenu />
|
||||||
<button on:click={() => {
|
<button
|
||||||
let menu = document.querySelector("#navbar-user")
|
on:click={() => {
|
||||||
menu.classList.toggle("hidden")
|
let menu = document.querySelector("#navbar-user");
|
||||||
}} type="button"
|
menu.classList.toggle("hidden");
|
||||||
class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg min-[950px]:hidden focus:outline-none focus:ring-2 text-gray-400 hover:bg-gray-700 focus:ring-gray-600"
|
}}
|
||||||
aria-controls="navbar-user" aria-expanded="false">
|
type="button"
|
||||||
|
class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg min-[950px]:hidden focus:outline-none focus:ring-2 text-gray-400 hover:bg-gray-700 focus:ring-gray-600"
|
||||||
|
aria-controls="navbar-user"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
<span class="sr-only">Open main menu</span>
|
<span class="sr-only">Open main menu</span>
|
||||||
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
<svg
|
||||||
viewBox="0 0 17 14">
|
class="w-5 h-5"
|
||||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
aria-hidden="true"
|
||||||
d="M1 1h15M1 7h15M1 13h15"/>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 17 14"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M1 1h15M1 7h15M1 13h15"
|
||||||
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="hidden items-center justify-between w-full pb-4 min-[950px]:pb-0 min-[950px]:flex min-[950px]:w-auto min-[950px]:order-1 border border-gray-700 min-[950px]:border-0 bg-gray-800 min-[950px]:bg-transparent rounded-lg" id="navbar-user">
|
<div
|
||||||
<ul class="flex flex-col font-medium pb-6 min-[950px]:p-0 mt-4 min-[950px]:space-x-8 rtl:space-x-reverse min-[950px]:flex-row min-[950px]:mt-0">
|
class="hidden items-center justify-between w-full pb-4 min-[950px]:pb-0 min-[950px]:flex min-[950px]:w-auto min-[950px]:order-1 border border-gray-700 min-[950px]:border-0 bg-gray-800 min-[950px]:bg-transparent rounded-lg"
|
||||||
|
id="navbar-user"
|
||||||
|
>
|
||||||
|
<ul
|
||||||
|
class="flex flex-col font-medium pb-6 min-[950px]:p-0 mt-4 min-[950px]:space-x-8 rtl:space-x-reverse min-[950px]:flex-row min-[950px]:mt-0"
|
||||||
|
>
|
||||||
<li>
|
<li>
|
||||||
{#if !isAniListLoggedIn}
|
{#if !isAniListLoggedIn}
|
||||||
<button on:click={loginToAniList}>
|
<button on:click={loginToAniList}>
|
||||||
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
AniList Login
|
AniList Login
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{#if !isMALLoggedIn}
|
{#if !isMALLoggedIn}
|
||||||
<button on:click={loginToMAL}>
|
<button on:click={loginToMAL}>
|
||||||
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
MyAnimeList Login
|
MyAnimeList Login
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -63,14 +89,14 @@
|
|||||||
<li>
|
<li>
|
||||||
{#if !isSimklLoggedIn}
|
{#if !isSimklLoggedIn}
|
||||||
<button on:click={loginToSimkl}>
|
<button on:click={loginToSimkl}>
|
||||||
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
Simkl Login
|
Simkl Login
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="flex justify-center min-[950px]:hidden">
|
<div class="flex justify-center min-[950px]:hidden">
|
||||||
<Search/>
|
<Search />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user