forked from flohansen/hsfl-master-ai-cloud-engineering
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(web-service): add reactive headlines and active state on navbar
- Loading branch information
Dorien Grönwald
committed
Nov 2, 2023
1 parent
7987d6e
commit af0ece8
Showing
10 changed files
with
59 additions
and
28 deletions.
There are no files selected for viewing
51 changes: 26 additions & 25 deletions
51
src/web-service/frontend/src/lib/navigation/NavItem.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
<script lang="ts"> | ||
import Home from "../../assets/svg/Home.svelte"; | ||
import List from "../../assets/svg/List.svelte"; | ||
import Cart from "../../assets/svg/Basket.svelte"; | ||
import Profile from "../../assets/svg/Profile.svelte"; | ||
import Home from "../../assets/svg/Home.svelte"; | ||
import List from "../../assets/svg/List.svelte"; | ||
import Cart from "../../assets/svg/Basket.svelte"; | ||
import Profile from "../../assets/svg/Profile.svelte"; | ||
import { page } from "$app/stores"; | ||
interface NavIcons { | ||
label: string, | ||
href: string, | ||
component: typeof Home | typeof List | typeof Cart | typeof Profile, | ||
ariaLabel: string | ||
} | ||
interface NavIcons { | ||
label: string; | ||
href: string; | ||
component: typeof Home | typeof List | typeof Cart | typeof Profile; | ||
ariaLabel: string; | ||
} | ||
const options: NavIcons[] = [ | ||
{ label: 'home', href: "/", component: Home, ariaLabel: "Zur Startseite" }, | ||
{ label: 'list', href: "/shopping-lists", component: List, ariaLabel: "Zu deinen Einkauftslisten" }, | ||
{ label: 'cart', href: "/", component: Cart, ariaLabel: "Zu allen Händlern und deren Produkte" }, | ||
{ label: 'profile', href: "/", component: Profile, ariaLabel: "Zu deinem Profil" }, | ||
] | ||
const options: NavIcons[] = [ | ||
{ label: 'home', href: "/", component: Home, ariaLabel: "Zur Startseite" }, | ||
{ label: 'list', href: "/shopping-lists", component: List, ariaLabel: "Zu deinen Einkaufslisten" }, | ||
{ label: 'cart', href: "/merchants", component: Cart, ariaLabel: "Zu allen Händlern und deren Produkte" }, | ||
{ label: 'profile', href: "/profile", component: Profile, ariaLabel: "Zu deinem Profil" }, | ||
] | ||
function getOptionByLabel(labelToFind: string): NavIcons { | ||
return options.find(option => option.label === labelToFind) ?? options[0]; | ||
} | ||
function getOptionByLabel(labelToFind: string): NavIcons { | ||
return options.find(option => option.label === labelToFind) ?? options[0]; | ||
} | ||
export let icon = 'home'; | ||
let currentOption = getOptionByLabel(icon); | ||
let isActive: boolean = false; | ||
export let icon = 'home'; | ||
$: currentPath = $page.url.pathname; | ||
$: currentOption = getOptionByLabel(icon); | ||
$: isActive = currentPath === currentOption.href; | ||
</script> | ||
|
||
<a | ||
href="{currentOption.href}" | ||
aria-label="{currentOption.ariaLabel}" | ||
aria-current="{isActive}" | ||
class="{isActive ? 'bg-green-light/25 text-green-dark hover:bg-green-light/50' : ' bg-gray-light text-black hover:bg-gray-dark/25'} | ||
w-14 h-14 rounded-full flex items-center justify-center transition-all ease-in-out duration-300 sm:w-12 sm:h-12"> | ||
aria-current="{isActive ? 'page' : undefined}" | ||
class="{isActive ? 'bg-green-light/25 text-green-dark hover:bg-green-light/50' : ' bg-gray-light text-black hover-bg-gray-dark/25'} w-14 h-14 rounded-full flex items-center justify-center transition-all ease-in-out duration-300 sm:w-12 sm:h-12"> | ||
<svelte:component this="{currentOption.component}" classes="w-6 h-6"/> | ||
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function load(): object { | ||
return { | ||
metaTitle: 'Starseite', | ||
headline: 'Price Whisper', | ||
}; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function load(): object { | ||
return { | ||
metaTitle: 'Auflistung der Supermärkte', | ||
headline: 'Alle verfügbaren Supermärkte', | ||
}; | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function load(): object { | ||
return { | ||
metaTitle: 'Deine Profil-Einstellungen', | ||
headline: 'Dein Profil', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export function load(): object { | ||
return { | ||
metaTitle: 'Auflistung deiner Einkaufslisten', | ||
headline: 'Deine Einkaufslisten', | ||
}; | ||
} |