mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-11-12 06:40:40 +08:00
Also bubbling events from HTML elements to the components have to be done with `onclick` callback props.
34 lines
647 B
Svelte
34 lines
647 B
Svelte
<script lang="ts">
|
|
import type { Route } from "@app/lib/router/definitions";
|
|
|
|
import { push, routeToPath } from "@app/lib/router";
|
|
|
|
export let route: Route;
|
|
export let disabled: boolean = false;
|
|
|
|
function navigateToRoute(event: MouseEvent): void {
|
|
event.preventDefault();
|
|
if (disabled) {
|
|
return;
|
|
}
|
|
|
|
void push(route);
|
|
}
|
|
</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 onclick={navigateToRoute} href={routeToPath(route)}>
|
|
<slot />
|
|
</a>
|