mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Add our own router
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -26,6 +26,9 @@
|
||||
svg {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user