fix(ui): enable custom props in section links

Flupsi 2025-08-15 18:47:02 +02:00 zatwierdzone przez Arne Bollinger
rodzic 5d2741f2fe
commit 7d7b58b5eb
5 zmienionych plików z 69 dodań i 27 usunięć

Wyświetl plik

@ -90,7 +90,7 @@ const props = defineProps<{
</component>
<div
v-if="$slots.action"
style="align-self: center;"
style="align-self: baseline;"
>
<slot name="action" />
</div>

Wyświetl plik

@ -65,6 +65,7 @@ onMounted(() => {
ref="link"
:autofocus="autofocus || undefined"
:class="[
$attrs.class,
$style.link,
round && $style['is-round'],
isIconOnly && $style['is-icon-only'],

Wyświetl plik

@ -118,18 +118,27 @@ const headingProps = computed(() =>
</template>
<!-- Action! You can either specify `to` or `onClick`. -->
<!-- Note: We cannot simplify with `<component is="action && 'to' in action ? Link : Button"` due to a Vue bug -->
<component
:is="'to' in action ? Link : Button"
v-if="action"
thin-font
min-content
align-self="baseline"
:class="$style.action"
v-bind="action"
>
{{ action?.text }}
</component>
<template v-if="action">
<Link
v-if="'to' in action"
:class="$style.action"
v-bind="action"
>
{{ action.text }}
</Link>
<Button
v-else
thin-font
min-content
align-self="baseline"
:class="$style.action"
v-bind="action"
>
{{ action.text }}
</Button>
</template>
</Layout>
</Layout>

Wyświetl plik

@ -10,6 +10,7 @@ import Spacer from '~/components/ui/Spacer.vue'
import Pill from '~/components/ui/Pill.vue'
import Activity from '~/components/ui/Activity.vue'
import Section from '~/components/ui/Section.vue'
import Link from '~/components/ui/Link.vue'
const alignLeft = ref(true)
@ -220,26 +221,24 @@ The link or button will be shown on the right side of the header. Use `action.te
You can use all [`Link` props](../link.md) or [`Button` props](../button.md) inside the `action` prop! Note that the button or link label will be in line with the heading.
```vue-html
<Spacer />
<Layout stack gap-64>
<Section
<Section
h2="With a link"
:action="{
text: 'My library',
to: '/',
icon: 'bi-star'
}"
/>
<Section
h2="With a button"
:action="{
text: 'Say hello!',
onClick: ()=>console.log('Hello'),
primary: true,
solid: true
}"
/>
</Layout>
/>
<Section
h2="With a button"
:action="{
text: 'Say hello!',
onClick: ()=>console.log('Hello'),
primary: true,
solid: true,
icon: 'bi-save'
}"
/>
```
<Spacer />
@ -258,7 +257,8 @@ You can use all [`Link` props](../link.md) or [`Button` props](../button.md) ins
text: 'Say hello!',
onClick: ()=>console.log('Hello'),
primary: true,
solid: true
solid: true,
icon: 'bi-save'
}"
/>
</Layout>

Wyświetl plik

@ -146,6 +146,38 @@ _Only use on top of solid surfaces, else the text may be unreadable!_
Home
</Link>
## Add an icon
You can use [Bootstrap Icons](https://icons.getbootstrap.com/) in your link component.
::: info
- Icon links shrink down to the icon size if you don't pass any content. If you want to keep the link at full width with just an icon, add `button-width` as a prop.
:::
```vue-html
<Link :to icon="bi-three-dots-vertical" />
<Link :to primary solid round icon="bi-save"/>
<Link :to solid destructive icon="bi-trash">
Delete
</Link :to>
<Link :to low-height icon="bi-chevron-right">
Next
</Link>
```
<Layout flex>
<Link :to icon="bi-three-dots-vertical" />
<Link :to primary solid round icon="bi-save"/>
<Link :to solid destructive icon="bi-trash">
Delete
</Link :to>
<Link :to low-height icon="bi-chevron-right">
Next
</Link>
</Layout>
## Set width and alignment
See [Using width](/using-width) and [Using alignment](/using-alignment).