Skip to content

Commit

Permalink
🎉 Remove target _self from nav bar links
Browse files Browse the repository at this point in the history
  • Loading branch information
Malte2036 committed Oct 30, 2024
1 parent d690217 commit 30874c2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 33 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"test": "vitest"
},
"dependencies": {
"@malte2036/thw-tools-components": "^0.2.21"
"@malte2036/thw-tools-components": "^0.2.24"
},
"devDependencies": {
"@sveltejs/adapter-node": "^5.2.2",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/lib/icons/ExternalLinkIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-4 w-4 inline-block ml-1"
viewBox="0 0 20 20"
fill="currentColor"
>
<path
d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"
/>
<path d="M5 5a2 2 0 00-2 2v8a2 2 0 002 2h8a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z" />
</svg>
14 changes: 14 additions & 0 deletions src/lib/icons/MenuIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<svg
xmlns="http://www.w3.org/2000/svg"
class="h-6 w-6"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
/>
</svg>
32 changes: 32 additions & 0 deletions src/lib/navigation/NavigationBar.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<script lang="ts">
import { page } from '$app/stores';
import logo from '$lib/icons/thw-mzgw.webp';
const navItems = [
{
title: 'Quiz',
items: [
{ name: 'Grundausbildungs-Quiz', href: '/quiz/ga/listing/' },
{ name: 'Sprechfunk-Quiz', href: '/quiz/radio/listing/' },
{ name: 'Atemschutz-Quiz', href: '/quiz/agt/listing/' },
{ name: 'CBRN-Quiz', href: '/quiz/cbrn/listing/' }
]
},
{
title: 'Tools',
items: [
{ name: 'CBRN-Schutzanzug', href: '/cbrn/protective-suite' },
{ name: 'Finnentest', href: 'https://finnentest.thw-tools.de', external: true },
{ name: 'Elektro Spannungsfall', href: 'https://elektro.thw-tools.de', external: true },
{ name: 'THW Bekleidungs Rechner', href: '/clothing' }
]
}
];
$: currentPath = $page.url.pathname;
$: isHomePage = currentPath === '/';
</script>

{#if !isHomePage}
<thw-navigation-bar logoUrl={logo} title="THW Tools" {navItems} {currentPath} />
{/if}
29 changes: 2 additions & 27 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,37 +1,14 @@
<script lang="ts">
import '@malte2036/thw-tools-components';
import { dev } from '$app/environment';
import { PUBLIC_UMAMI_ENDPOINT, PUBLIC_UMAMI_WEBSITEID } from '$env/static/public';
import '../app.css';
import { page } from '$app/stores';
import Header from './Header.svelte';
import Banner from '$lib/Banner.svelte';
import Dialog from '$lib/Dialog.svelte';
import Button from '$lib/Button.svelte';
import InstallPWADialog from '$lib/InstallPWADialog.svelte';
let title: string | undefined;
$: title = getCurrentTitleByPath($page.url.pathname);
function getCurrentTitleByPath(path: string): string | undefined {
if (path.startsWith('/quiz/ga')) {
return 'Grundausbildungs-Quiz';
} else if (path.startsWith('/quiz/agt')) {
return 'Atemschutz-Quiz';
} else if (path.startsWith('/quiz/cbrn')) {
return 'CBRN-Quiz';
} else if (path.startsWith('/quiz/radio')) {
return 'Sprechfunk-Quiz';
} else if (path.startsWith('/cbrn/protective-suite')) {
return 'CBRN-Schutzanzug';
} else if (path === '/') {
return undefined;
} else {
return 'THW-Tools';
}
}
import NavigationBar from '$lib/navigation/NavigationBar.svelte';
let showFeedback = false;
let showInstallPWAHelp = false;
Expand All @@ -51,9 +28,7 @@
</svelte:head>

<div class="flex flex-col gap-4 justify-between min-h-screen">
{#if title !== undefined}
<Header {title} />
{/if}
<NavigationBar />
<Banner />
<div class="grow">
<slot />
Expand Down

0 comments on commit 30874c2

Please # to comment.