1
0
Fork 0
mirror of synced 2024-07-08 07:46:10 +12:00
budibase/packages/standard-components/src/Link.svelte

32 lines
625 B
Svelte
Raw Normal View History

2020-02-21 06:06:50 +13:00
<script>
import { getContext } from "svelte"
const { linkable, styleable } = getContext("sdk")
const component = getContext("component")
2020-02-26 04:21:23 +13:00
export let url = ""
export let text = ""
export let openInNewTab = false
2021-02-26 22:58:24 +13:00
export let external = false
2020-02-26 04:21:23 +13:00
$: target = openInNewTab ? "_blank" : "_self"
2020-02-21 06:06:50 +13:00
</script>
2021-02-26 22:58:24 +13:00
{#if external}
<a href={url || "/"} {target} use:styleable={$component.styles}>
2021-02-26 22:58:24 +13:00
{text}
<slot />
</a>
{:else}
<a href={url || "/"} use:linkable {target} use:styleable={$component.styles}>
2021-02-26 22:58:24 +13:00
{text}
<slot />
</a>
{/if}
<style>
a {
color: var(--spectrum-alias-text-color);
}
</style>