Files
radicle-desktop/src/components/Link.svelte
T
Sebastian Martinez ffff885ffb Event handlers with the on: directive are deprecated in svelte 5
Also bubbling events from HTML elements to the components have to be
done with `onclick` callback props.
2024-09-10 11:33:09 +02:00

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>