Skip to content

Commit 3d8fd2f

Browse files
committed
refactor: rename CNavbarToggle to CNavbarToggler
- add tag prop, - enable type change
1 parent b943d04 commit 3d8fd2f

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

src/components/Navbar/CNavbarToggle.vue renamed to src/components/Navbar/CNavbarToggler.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<script>
22
import { mergeData } from 'vue-functional-data-merge'
3-
//todo animation to x
43
export default {
5-
name: 'CNavbarToggle',
4+
name: 'CNavbarToggler',
65
functional: true,
7-
render (h, {data, slots}) {
6+
props: {
7+
tag: String
8+
},
9+
render (h, { data, props, slots }) {
810
return h(
9-
'button',
10-
mergeData(data, {
11-
class: [ 'navbar-toggler' ],
11+
props.tag || 'button',
12+
mergeData({
13+
class: 'navbar-toggler',
1214
attrs: {
1315
type: 'button',
1416
}
15-
}),
17+
}, data),
1618
[ slots().default || h('span', { class: ['navbar-toggler-icon'] })]
1719
)
1820
}

src/components/Navbar/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import CNavbar from './CNavbar'
22
import CNavbarNav from './CNavbarNav'
3-
import CNavbarToggle from './CNavbarToggle'
3+
import CNavbarToggler from './CNavbarToggler'
44
import CNavbarBrand from './CNavbarBrand'
55

66
export {
77
CNavbar,
88
CNavbarNav,
9-
CNavbarToggle,
9+
CNavbarToggler,
1010
CNavbarBrand
1111
}

src/components/Navbar/tests/CNavbarToggle.spec.js renamed to src/components/Navbar/tests/CNavbarToggler.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { mount } from '@vue/test-utils'
2-
import Component from '../CNavbarToggle'
2+
import Component from '../CNavbarToggler'
33

4-
const ComponentName = 'CNavbar'
4+
const ComponentName = 'CNavbarToggler'
55
const defaultWrapper = mount(Component)
66
const customWrapper = mount(Component, {
7-
propsData: {
8-
fill: true,
9-
justified: true,
10-
pills: true,
11-
vertical: true
7+
props: {
8+
tag: 'div'
9+
},
10+
attrs: {
11+
type: 'submit'
1212
},
1313
slots: {
1414
default: 'CNavbar items'
@@ -17,7 +17,7 @@ const customWrapper = mount(Component, {
1717

1818
describe(ComponentName, () => {
1919
it('has a name', () => {
20-
expect(Component.name).toMatch(ComponentName)
20+
expect(Component.name).toBe(ComponentName)
2121
})
2222
it('renders correctly', () => {
2323
expect(defaultWrapper.element).toMatchSnapshot()

src/components/Navbar/tests/__snapshots__/CNavbarToggle.spec.js.snap renamed to src/components/Navbar/tests/__snapshots__/CNavbarToggler.spec.js.snap

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`CNavbar renders correctly 1`] = `
3+
exports[`CNavbarToggler renders correctly 1`] = `
44
<button
55
class="navbar-toggler"
66
type="button"
@@ -11,14 +11,10 @@ exports[`CNavbar renders correctly 1`] = `
1111
</button>
1212
`;
1313

14-
exports[`CNavbar renders correctly 2`] = `
14+
exports[`CNavbarToggler renders correctly 2`] = `
1515
<button
1616
class="navbar-toggler"
17-
fill="true"
18-
justified="true"
19-
pills="true"
20-
type="button"
21-
vertical="true"
17+
type="submit"
2218
>
2319
CNavbar items
2420
</button>

src/components/index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,9 @@ export declare class CNavbarNav extends Vue {
414414
tag: string
415415
}
416416

417-
export declare class CNavbarToggle extends Vue {}
417+
export declare class CNavbarToggler extends Vue {
418+
tag: string
419+
}
418420

419421
export declare class CPagination extends Vue {
420422
activePage: number

0 commit comments

Comments
 (0)