Add our own router

This commit is contained in:
Rūdolfs Ošiņš
2024-09-03 16:30:12 +02:00
parent 484d0d58ba
commit 8179ed0f3e
14 changed files with 684 additions and 332 deletions
+19 -4
View File
@@ -5,6 +5,8 @@
import Icon from "./Icon.svelte";
import Popover from "./Popover.svelte";
import ThemeSwitch from "./ThemeSwitch.svelte";
export let currentPage: string;
</script>
<style>
@@ -26,17 +28,30 @@
gap: 0.5rem;
padding: 0 0.5rem;
}
.navigation :global(svg:hover) {
display: flex;
color: var(--color-fill-secondary);
}
</style>
<header class="flex-item">
<div class="wrapper flex-item">
<div class="wrapper-left flex-item">
<div class="flex-item" style:gap="0.5rem">
<Icon name="arrow-left" />
<Icon name="arrow-right" />
<div class="flex-item navigation" style:gap="0.5rem">
<Icon
name="arrow-left"
on:click={() => {
window.history.back();
}} />
<Icon
name="arrow-right"
on:click={() => {
window.history.forward();
}} />
</div>
<Fill variant="ghost" stylePadding="0 0.5rem" styleHeight="32px">
Repositories
{currentPage}
</Fill>
<Border variant="ghost" stylePadding="0 0.25rem" styleHeight="32px">
<Icon name="plus" />
+3
View File
@@ -26,6 +26,9 @@
svg {
display: flex;
flex-shrink: 0;
-webkit-touch-callout: none;
-webkit-user-select: none;
user-select: none;
}
</style>
+39
View File
@@ -0,0 +1,39 @@
<script lang="ts" strictEvents>
import type { Route } from "@app/lib/router/definitions";
import { createEventDispatcher } from "svelte";
import { push, routeToPath } from "@app/lib/router";
export let route: Route;
export let disabled: boolean = false;
const dispatch = createEventDispatcher<{
afterNavigate: null;
}>();
function navigateToRoute(event: MouseEvent): void {
event.preventDefault();
if (disabled) {
return;
}
void push(route);
dispatch("afterNavigate");
}
</script>
<style>
a {
color: var(--color-fill-secondary);
text-decoration: none;
}
a:hover {
text-decoration: underline;
text-decoration-thickness: 1px;
text-underline-offset: 2px;
}
</style>
<a on:click={navigateToRoute} href={routeToPath(route)}>
<slot />
</a>