Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 3521a85

Browse files
committed
feat(BNavItem): adds linkClasses property.
1 parent f097d76 commit 3521a85

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packages/bootstrap-vue-next/src/components/BNav/BNavItem.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<li class="nav-item">
33
<b-link
4-
class="nav-link"
4+
:class="computedLinkClasses"
55
v-bind="$props"
66
active-class="active"
77
:tabindex="disabledBoolean ? -1 : undefined"
@@ -16,7 +16,7 @@
1616
import BLink, {BLINK_PROPS} from '../BLink/BLink.vue'
1717
import {omit} from '../../utils'
1818
import {useBooleanish} from '../../composables'
19-
import {defineComponent, type SlotsType} from 'vue'
19+
import {computed, defineComponent, type SlotsType} from 'vue'
2020
2121
export default defineComponent({
2222
slots: Object as SlotsType<{
@@ -25,11 +25,14 @@ export default defineComponent({
2525
components: {BLink},
2626
props: {
2727
...omit(BLINK_PROPS, ['event', 'routerTag'] as const),
28+
linkClasses: {type: String, default: null},
2829
},
2930
setup(props) {
3031
const disabledBoolean = useBooleanish(() => props.disabled)
3132
32-
return {disabledBoolean}
33+
const computedLinkClasses = computed(() => ['nav-link', props.linkClasses])
34+
35+
return {disabledBoolean, computedLinkClasses}
3336
},
3437
})
3538
</script>

packages/bootstrap-vue-next/src/components/BNav/nav-item.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ describe('nav-item', () => {
2323
expect($blink.classes()).toContain('nav-link')
2424
})
2525

26+
it("blink has custom-class class when prop link-classes='custom-class'", () => {
27+
const wrapper = mount(BNavItem, {
28+
props: {
29+
linkClasses: 'custom-class',
30+
},
31+
})
32+
const $blink = wrapper.findComponent(BLink)
33+
34+
expect($blink.classes()).toContain('custom-class')
35+
})
36+
2637
it('blink has tabindex -1 when prop disabled', () => {
2738
const wrapper = mount(BNavItem, {
2839
props: {

0 commit comments

Comments
 (0)