Skip to content

Commit 3d47ef4

Browse files
committed
Implement to prop on BListGroupItem
1 parent 360e0ea commit 3d47ef4

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

src/components/BListGroup/BListGroupItem.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
:aria-disabled="disabled ? true : null"
88
:target="link ? target : null"
99
:href="!button ? href : null"
10+
:to="!button ? to : null"
1011
v-bind="computedAttrs"
1112
>
1213
<slot />
@@ -16,7 +17,9 @@
1617
<script setup lang="ts">
1718
// import type {BListGroupItemProps} from '../../types/components'
1819
import {computed, inject, useAttrs} from 'vue'
20+
import type {RouteLocationRaw} from 'vue-router'
1921
import type {ColorVariant, LinkTarget} from '../../types'
22+
import BLink from '../BLink/BLink.vue'
2023
import {injectionKey} from './BListGroup.vue'
2124
2225
interface BListGroupItemProps {
@@ -36,7 +39,7 @@ interface BListGroupItemProps {
3639
// routerComponentName?: String
3740
tag?: string
3841
target?: LinkTarget
39-
//to?: string | Record<string, unknown>
42+
to?: RouteLocationRaw
4043
variant?: ColorVariant
4144
}
4245
@@ -53,17 +56,10 @@ const attrs = useAttrs()
5356
5457
const parentData = inject(injectionKey, null)
5558
56-
const link = computed<boolean>(() => !props.button && !!props.href)
59+
const link = computed<boolean>(() => !props.button && (!!props.href || !!props.to))
5760
58-
const tagComputed = computed<string>(
59-
() =>
60-
parentData?.numbered
61-
? 'li'
62-
: props.button
63-
? 'button'
64-
: !link.value
65-
? props.tag
66-
: 'a' /* BLink */
61+
const tagComputed = computed<string | typeof BLink>(() =>
62+
parentData?.numbered ? 'li' : props.button ? 'button' : !link.value ? props.tag : BLink
6763
)
6864
6965
const classes = computed(() => {

src/types/components/BListGroup/BListGroupItem.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type {ColorVariant, LinkTarget} from '../..'
2+
import type {RouteLocationRaw} from 'vue-router'
23

34
// Props
45
export interface Props {
@@ -18,7 +19,7 @@ export interface Props {
1819
// routerComponentName?: String
1920
tag?: string
2021
target?: LinkTarget
21-
//to?: string | Record<string, unknown>
22+
to?: RouteLocationRaw
2223
variant?: ColorVariant
2324
}
2425
// Emits

0 commit comments

Comments
 (0)