Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(b-tabs): add newtabs-before andtabs-after slots#6487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Istador wants to merge6 commits intobootstrap-vue:dev
base:dev
Choose a base branch
Loading
fromIstador:new-b-tabs-slots
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletionssrc/components/tabs/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -572,4 +572,28 @@ It is recommended to use the `disabled` attribute on the `<b-tab>` component ins
<!-- b-tabs-dynamic.vue -->
```

### Card title using tabs-before slot

```html
<template>
<div>
<b-card no-body>
<b-tabs card>
<template #tabs-before>
<b-card-title>Card Title</b-card-title>
</template>
<b-tab title="Tab 1">
Tab contents 1
</b-tab>
<b-tab title="Tab 2">
Tab contents 1
</b-tab>
</b-tabs>
</b-card>
</div>
</template>

<!-- b-tabs-card-title.vue -->
```

<!-- Component reference added automatically from component package.json -->
8 changes: 8 additions & 0 deletionssrc/components/tabs/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -141,6 +141,14 @@
"name": "empty",
"description": "Renders this slot if no tabs are present"
},
{
"name": "tabs-after",
"description": "Content to place after the content tab buttons"
},
{
"name": "tabs-before",
"description": "Content to place before the content tab buttons"
},
{
"name": "tabs-end",
"description": "Additional tab buttons without tab content placed after content tab buttons"
Expand Down
8 changes: 7 additions & 1 deletionsrc/components/tabs/tabs.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,6 +27,8 @@ import {
} from '../../constants/props'
import {
SLOT_NAME_EMPTY,
SLOT_NAME_TABS_AFTER,
SLOT_NAME_TABS_BEFORE,
SLOT_NAME_TABS_END,
SLOT_NAME_TABS_START,
SLOT_NAME_TITLE
Expand DownExpand Up@@ -635,7 +637,11 @@ export const BTabs = /*#__PURE__*/ Vue.extend({
],
key: 'bv-tabs-nav'
},
[$nav]
[
this.normalizeSlot(SLOT_NAME_TABS_BEFORE) || h(),
$nav,
this.normalizeSlot(SLOT_NAME_TABS_AFTER) || h()
]
)

const $children = this.normalizeSlot() || []
Expand Down
54 changes: 54 additions & 0 deletionssrc/components/tabs/tabs.spec.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -687,6 +687,60 @@ describe('tabs', () => {
wrapper.destroy()
})

it('tabs-before slot is injected at the right place', async () => {
const wrapper = mount(BTabs, {
slots: {
default: [BTab, BTab],
'tabs-before': '<span class="test-tabs-before">foobar</span>'
}
})
expect(wrapper).toBeDefined()
expect(wrapper.findAllComponents(BTab).length).toBe(2)

// check existance
const spans = wrapper.findAll('span.test-tabs-before')
expect(spans).toBeDefined()
expect(spans.length).toBe(1)
expect(spans.at(0).text()).toBe('foobar')

// check order
const childs = wrapper.findAll('div.tabs > div:first-of-type > *')
expect(childs.length).toBe(2)
expect(childs.at(0).classes().length).toBe(1)
expect(childs.at(0).classes()).toContain('test-tabs-before')
expect(childs.at(0).text()).toBe('foobar')
expect(childs.at(1).classes().length).toBe(2)
expect(childs.at(1).classes()).toContain('nav')
expect(childs.at(1).classes()).toContain('nav-tabs')
})

it('tabs-after slot is injected at the right place', async () => {
const wrapper = mount(BTabs, {
slots: {
default: [BTab, BTab],
'tabs-after': '<span class="test-tabs-after">foobar</span>'
}
})
expect(wrapper).toBeDefined()
expect(wrapper.findAllComponents(BTab).length).toBe(2)

// check existance
const spans = wrapper.findAll('span.test-tabs-after')
expect(spans).toBeDefined()
expect(spans.length).toBe(1)
expect(spans.at(0).text()).toBe('foobar')

// check order
const childs = wrapper.findAll('div.tabs > div:first-of-type > *')
expect(childs.length).toBe(2)
expect(childs.at(0).classes().length).toBe(2)
expect(childs.at(0).classes()).toContain('nav')
expect(childs.at(0).classes()).toContain('nav-tabs')
expect(childs.at(1).classes().length).toBe(1)
expect(childs.at(1).classes()).toContain('test-tabs-after')
expect(childs.at(1).text()).toBe('foobar')
})

it('"active-nav-item-class" is applied to active nav item', async () => {
const activeNavItemClass = 'text-success'
const App = {
Expand Down
2 changes: 2 additions & 0 deletionssrc/constants/slots.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -54,6 +54,8 @@ export const SLOT_NAME_ROW_DETAILS = 'row-details'
export const SLOT_NAME_TABLE_BUSY = 'table-busy'
export const SLOT_NAME_TABLE_CAPTION = 'table-caption'
export const SLOT_NAME_TABLE_COLGROUP = 'table-colgroup'
export const SLOT_NAME_TABS_AFTER = 'tabs-after'
export const SLOT_NAME_TABS_BEFORE = 'tabs-before'
export const SLOT_NAME_TABS_END = 'tabs-end'
export const SLOT_NAME_TABS_START = 'tabs-start'
export const SLOT_NAME_TEXT = 'text'
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp