budibase/packages/standard-components/src/Link.svelte

53 lines
913 B
Svelte
Raw Normal View History

2020-02-20 18:06:50 +01:00
<script>
2020-02-25 16:21:23 +01:00
import { cssVars, createClasses } from "./cssVars"
export let url = ""
export let text = ""
export let openInNewTab = false
export let color
export let hoverColor
export let underline = false
export let fontSize
export let _bb
let anchorElement
$: anchorElement && !text && _bb.attachChildren(anchorElement)
$: target = openInNewTab ? "_blank" : "_self"
$: cssVariables = {
hoverColor,
color,
textDecoration: underline ? "underline" : "none",
fontSize,
2020-02-21 12:43:21 +01:00
}
2020-02-25 16:21:23 +01:00
$: classes = createClasses(cssVariables)
2020-02-20 18:06:50 +01:00
</script>
2020-02-25 16:21:23 +01:00
<a
href={url}
bind:this={anchorElement}
2020-02-21 12:43:21 +01:00
class={classes}
2020-02-25 16:21:23 +01:00
{target}
use:cssVars={cssVariables}>
{text}
</a>
2020-02-21 12:43:21 +01:00
<style>
2020-02-25 16:21:23 +01:00
.color {
color: var(--color);
}
2020-02-21 12:43:21 +01:00
2020-02-25 16:21:23 +01:00
.hoverColor:hover {
color: var(--color);
}
2020-02-21 12:43:21 +01:00
2020-02-25 16:21:23 +01:00
.textDecoration {
text-decoration: var(--textDecoration);
}
2020-02-20 18:06:50 +01:00
2020-02-25 16:21:23 +01:00
.fontSize {
font-size: var(--fontSize);
}
2020-02-21 12:43:21 +01:00
</style>