Skip to content

Commit 9ee92db

Browse files
author
Pooya Parsa
committed
vue-router support & fixes
1 parent 328935c commit 9ee92db

File tree

5 files changed

+68
-24
lines changed

5 files changed

+68
-24
lines changed

components/button.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
<template>
2-
<button :class="classObject" @click.stop.prevent="click">
2+
<button :class="classObject"
3+
4+
@click.stop.prevent="click"
5+
6+
:is="componentType"
7+
active-class="active"
8+
:to="to"
9+
:exact="exact"
10+
>
311
<slot></slot>
412
</button>
513
</template>
@@ -18,6 +26,9 @@
1826
this.inactive ? 'btn-inactive' : ''
1927
];
2028
},
29+
componentType(){
30+
return this.to ? 'router-link' : 'a';
31+
},
2132
btnBlock() {
2233
return this.block ? `btn-block` : '';
2334
},
@@ -60,10 +71,21 @@
6071
type: String,
6172
default: 'secondary'
6273
},
74+
to: {
75+
type: String,
76+
default: '',
77+
},
78+
exact: {
79+
type: Boolean,
80+
default: false,
81+
},
6382
},
6483
methods: {
6584
click: function () {
6685
this.$emit('click', this.link);
86+
if (this.$router && this.to && this.to.length) {
87+
this.$router.push(this.to);
88+
}
6789
},
6890
},
6991
}

components/form-fieldset.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
return this.state ? `has-${this.state}` : '';
1717
},
1818
labelLayout() {
19-
return this.layout == 'horizontal' ? 'col-xs-2' : 'col-xs-12';
19+
return this.horizontal ? 'col-xs-2' : 'col-xs-12';
2020
},
2121
inputLayout() {
22-
return this.layout == 'horizontal' ? 'col-xs-10' : 'col-xs-12';
22+
return this.horizontal ? 'col-xs-10' : 'col-xs-12';
2323
}
2424
},
2525
props: {
@@ -31,9 +31,9 @@
3131
type: String,
3232
default: null
3333
},
34-
layout: {
35-
type: String,
36-
default: 'horizontal'
34+
horizontal: {
35+
type: Boolean,
36+
default: false
3737
},
3838
label: {
3939
type: String,

components/form-select.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<b-form-fieldset :state="state" :layout="layout" :label="label" :description="description" :feedback="feedback"
2+
<b-form-fieldset :state="state" :horizontal="horizontal" :label="label" :description="description" :feedback="feedback"
33
:id="id">
44

55
<select :class="['custom-select',inputSize]"
@@ -68,9 +68,9 @@
6868
},
6969
7070
// FIELD SET
71-
layout: {
72-
type: String,
73-
default: null
71+
horizontal: {
72+
type: Boolean,
73+
default: true
7474
},
7575
state: {
7676
type: String,

components/nav-item.vue

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,58 @@
11
<template>
2-
<a class="nav-item"
3-
href="#"
4-
@click.stop.prevent="onclick"
5-
:class="classObject">
2+
<component
3+
class="nav-item"
4+
:class="classObject"
5+
6+
@click.stop.prevent="onclick"
7+
8+
:is="componentType"
9+
active-class="active"
10+
:to="to"
11+
:exact="exact"
12+
>
613
<slot></slot>
7-
</a>
14+
</component>
815
</template>
916

1017
<script>
18+
1119
export default {
1220
computed: {
1321
classObject(){
14-
return ['nav-link', this.active ? 'active' : '', this.disabled ? 'disabled' : ''];
15-
}
22+
return [
23+
'nav-link',
24+
this.active ? 'active' : '',
25+
this.disabled ? 'disabled' : ''
26+
];
27+
},
28+
componentType(){
29+
return this.to ? 'router-link' : 'a';
30+
},
1631
},
1732
props: {
18-
link: {
19-
type: String,
20-
default: ''
21-
},
2233
active: {
2334
type: Boolean,
2435
default: false
2536
},
2637
disabled: {
2738
type: Boolean,
2839
default: false
29-
}
40+
},
41+
to: {
42+
type: String,
43+
default: '',
44+
},
45+
exact: {
46+
type: Boolean,
47+
default: false,
48+
},
3049
},
3150
methods: {
3251
onclick: function () {
33-
this.$emit('click', this.link);
52+
this.$emit('click', this.to);
53+
if (this.$router && this.to && this.to.length) {
54+
this.$router.push(this.to);
55+
}
3456
}
3557
}
3658
}

components/nav.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
fill: {
2828
type: Boolean,
29-
default: true
29+
default: false
3030
},
3131
tabs: {
3232
type: Boolean,

0 commit comments

Comments
 (0)