forked from coracle/flotilla
Fix more stuff, particularly event handlers
This commit is contained in:
@@ -1,13 +1,22 @@
|
||||
<script lang="ts">
|
||||
import type {Snippet} from "svelte"
|
||||
import {stopPropagation} from "svelte/legacy"
|
||||
import {goto} from "$app/navigation"
|
||||
|
||||
interface Props {
|
||||
const {
|
||||
children,
|
||||
href,
|
||||
external = false,
|
||||
replaceState = false,
|
||||
...restProps
|
||||
}: {
|
||||
children: Snippet
|
||||
href: string
|
||||
external: boolean
|
||||
replaceState: boolean
|
||||
}
|
||||
|
||||
let {href, external = false, replaceState = false, ...restProps} = $props()
|
||||
external?: boolean
|
||||
replaceState?: boolean
|
||||
disabled?: boolean
|
||||
class?: string
|
||||
} = $props()
|
||||
|
||||
const go = (e: Event) => {
|
||||
if (!external) {
|
||||
@@ -21,9 +30,9 @@
|
||||
<a
|
||||
{href}
|
||||
{...restProps}
|
||||
on:click|stopPropagation={go}
|
||||
onclick={stopPropagation(go)}
|
||||
class="cursor-pointer {restProps.class}"
|
||||
rel={external ? "noopener noreferer" : ""}
|
||||
target={external ? "_blank" : ""}>
|
||||
<slot />
|
||||
{@render children?.()}
|
||||
</a>
|
||||
|
||||
Reference in New Issue
Block a user