fix(ui): width prop is respected on internal links
This commit is contained in:
parent
2818c3eff3
commit
3f9799fd20
|
@ -35,7 +35,7 @@ const attributes = computed(() => ({
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a v-if="isExternalLink"
|
<component :is="isExternalLink ? 'a' : 'RouterLink'"
|
||||||
v-bind="attributes"
|
v-bind="attributes"
|
||||||
:class="[
|
:class="[
|
||||||
$style.link,
|
$style.link,
|
||||||
|
@ -47,33 +47,15 @@ const attributes = computed(() => ({
|
||||||
isSimple && $style['force-underline'],
|
isSimple && $style['force-underline'],
|
||||||
isSimple && $style['no-spacing'],
|
isSimple && $style['no-spacing'],
|
||||||
]"
|
]"
|
||||||
:href="to.toString()"
|
:href="isExternalLink ? to.toString() : undefined"
|
||||||
target="_blank"
|
:to="isExternalLink ? undefined : to"
|
||||||
|
:target="isExternalLink ? '_blank' : undefined"
|
||||||
>
|
>
|
||||||
<i v-if="icon" :class="['bi', icon]" />
|
<i v-if="icon" :class="['bi', icon]" />
|
||||||
<span>
|
<span>
|
||||||
<slot />
|
<slot />
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</component>
|
||||||
<RouterLink v-else
|
|
||||||
:to="to"
|
|
||||||
v-bind="color(props, ['interactive'])"
|
|
||||||
:class="[
|
|
||||||
$style.link,
|
|
||||||
$style['is-' + width],
|
|
||||||
$style['is-text-aligned-' + (alignText ?? 'left')],
|
|
||||||
$style['is-self-aligned-' + (alignSelf ?? 'auto')],
|
|
||||||
round && $style['is-round'],
|
|
||||||
isIconOnly && $style['is-icon-only'],
|
|
||||||
isSimple && $style['no-spacing'],
|
|
||||||
isSimple && $style['force-underline']
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<i v-if="icon" :class="['bi', icon]" />
|
|
||||||
<span>
|
|
||||||
<slot />
|
|
||||||
</span>
|
|
||||||
</RouterLink>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style module lang="scss">
|
<style module lang="scss">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Link from '~/components/ui/Link.vue'
|
import Link from '~/components/ui/Link.vue'
|
||||||
import Button from '~/components/ui/Button.vue'
|
import Button from '~/components/ui/Button.vue'
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
# Link
|
# Link
|
||||||
|
@ -76,3 +77,44 @@ Instead of a route, you can set the prop `to` to any web address starting with `
|
||||||
<Link primary solid round to="/">
|
<Link primary solid round to="/">
|
||||||
Home
|
Home
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
## Width and alignment
|
||||||
|
|
||||||
|
<Layout flex>
|
||||||
|
|
||||||
|
```vue-html
|
||||||
|
<Link solid primary min-content to="/">min-content</Link>
|
||||||
|
<Link solid primary tiny to="/">tiny</Link>
|
||||||
|
<Link solid primary buttonWidth to="/">buttonWidth</Link>
|
||||||
|
<Link solid primary small to="/">small</Link>
|
||||||
|
<Link solid primary medium to="/">medium</Link>
|
||||||
|
<Link solid primary full to="/">full</Link>
|
||||||
|
<Link solid primary auto to="/">auto</Link>
|
||||||
|
<hr />
|
||||||
|
<Link solid primary alignSelf="start" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignSelf="center" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignSelf="end" to="/">🐌</Link>
|
||||||
|
<hr />
|
||||||
|
<Link solid primary alignText="left" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignText="center" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignText="right" to="/">🐌</Link>
|
||||||
|
```
|
||||||
|
|
||||||
|
<Layout class="preview" stack style="--gap:4px;">
|
||||||
|
<Link solid primary min-content to="/">min-content</Link>
|
||||||
|
<Link solid primary tiny to="/">tiny</Link>
|
||||||
|
<Link solid primary buttonWidth to="/">buttonWidth</Link>
|
||||||
|
<Link solid primary small to="/">small</Link>
|
||||||
|
<Link solid primary medium to="/">medium</Link>
|
||||||
|
<Link solid primary full to="/">full</Link>
|
||||||
|
<Link solid primary auto to="/">auto</Link>
|
||||||
|
<hr />
|
||||||
|
<Link solid primary alignSelf="start" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignSelf="center" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignSelf="end" to="/">🐌</Link>
|
||||||
|
<hr />
|
||||||
|
<Link solid primary alignText="left" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignText="center" to="/">🐌</Link>
|
||||||
|
<Link solid primary alignText="right" to="/">🐌</Link>
|
||||||
|
</Layout>
|
||||||
|
</Layout>
|
||||||
|
|
Loading…
Reference in New Issue