Skip to content

Commit 3686ef8

Browse files
committed
feat: add CNavbarNav component, CNavbar and CNavbarToggle modifications
1 parent 7df8570 commit 3686ef8

File tree

5 files changed

+49
-18
lines changed

5 files changed

+49
-18
lines changed

src/components/Navbar/CNavbar.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ export const props = {
55
type: String,
66
default: 'nav'
77
},
8-
type: {
9-
type: String,
10-
default: 'light'
11-
},
8+
light: Boolean,
129
variant: String,
1310
toggleable: {
1411
type: [Boolean, String],
@@ -34,14 +31,16 @@ export default {
3431
props.tag,
3532
mergeData(data, {
3633
staticClass: 'navbar',
37-
class: {
38-
'd-print': props.print,
39-
'sticky-top': props.sticky,
40-
[`navbar-${props.type}`]: Boolean(props.type),
41-
[`bg-${props.variant}`]: Boolean(props.variant),
42-
[`fixed-${props.fixed}`]: Boolean(props.fixed),
43-
[`${breakpoint}`]: Boolean(breakpoint)
44-
},
34+
class: [
35+
props.light ? 'navbar-light' : 'navbar-dark',
36+
{
37+
'd-print': props.print,
38+
'sticky-top': props.sticky,
39+
[`bg-${props.variant}`]: Boolean(props.variant),
40+
[`fixed-${props.fixed}`]: Boolean(props.fixed),
41+
[`${breakpoint}`]: Boolean(breakpoint)
42+
}
43+
],
4544
attrs: {
4645
role: props.tag === 'nav' ? null : 'navigation'
4746
}

src/components/Navbar/CNavbarNav.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { mergeData } from 'vue-functional-data-merge'
2+
export default {
3+
name: 'CNavbarNav',
4+
functional: true,
5+
props:{
6+
tag: {
7+
type: String,
8+
default: 'ul'
9+
},
10+
fill: Boolean,
11+
justified: Boolean,
12+
},
13+
render (h, { props, data, children }) {
14+
return h(
15+
props.tag,
16+
mergeData(data, {
17+
staticClass: 'navbar-nav',
18+
class: {
19+
'nav-fill': props.fill,
20+
'nav-justified': props.justified
21+
}
22+
}),
23+
children
24+
)
25+
}
26+
}
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
import { mergeData } from 'vue-functional-data-merge'
2+
//todo animation to x
13
export default {
24
name: 'CNavbarToggle',
3-
render (h) {
5+
functional: true,
6+
render (h, {data, slots}) {
47
return h(
58
'button',
6-
{
7-
class: ['navbar-toggler'],
9+
mergeData(data, {
10+
class: [ 'navbar-toggler' ],
811
attrs: {
912
type: 'button',
10-
},
11-
},
12-
[this.$slots.default || h('span', { class: ['navbar-toggler-icon'] })]
13+
}
14+
}),
15+
[ slots().default || h('span', { class: ['navbar-toggler-icon'] })]
1316
)
1417
}
1518
}

src/components/Navbar/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import CNavbar from './CNavbar'
2+
import CNavbarNav from './CNavbarNav'
23
import CNavbarToggle from './CNavbarToggle'
34

45
export {
56
CNavbar,
7+
CNavbarNav,
68
CNavbarToggle
79
}

src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * from './Sidebar'
88
export * from './Widgets'
99
export * from './Charts'
1010
export * from './Nav'
11+
export * from './Navbar'
1112
export * from './Link'
1213
export * from './Badge'
1314
export * from './Progress'

0 commit comments

Comments
 (0)