File tree Expand file tree Collapse file tree 3 files changed +18
-22
lines changed Expand file tree Collapse file tree 3 files changed +18
-22
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<section class =" d-flex justify-content-center align-items-center" >
3
- <dropdown class =" dropdown" tag =" nav" >
3
+ <toggle class =" dropdown" tag =" nav" >
4
4
<button class =" btn btn-primary" >Drop it Down</button >
5
5
6
- <dropdown-menu class =" dropdown-menu show" >
6
+ <target class =" dropdown-menu show" >
7
7
<li class =" dropdown-item" >Whats up!</li >
8
- </dropdown-menu >
9
- </dropdown >
8
+ </target >
9
+ </toggle >
10
10
</section >
11
11
</template >
12
12
13
13
<script >
14
- import Dropdown from ' ./Dropdown ' ;
15
- import DropdownMenu from ' ./DropdownMenu ' ;
14
+ import Toggle from ' ./components/Toggle ' ;
15
+ import Target from ' ./components/Target ' ;
16
16
17
17
export default {
18
- components: {Dropdown, DropdownMenu },
18
+ components: {Toggle, Target },
19
19
};
20
20
</script >
21
21
Original file line number Diff line number Diff line change 1
1
<script >
2
2
export default {
3
- name: ' dropdown-menu ' ,
3
+ name: ' target ' ,
4
4
props: {
5
5
tag: {
6
6
type: String ,
@@ -9,15 +9,15 @@ export default {
9
9
display: {
10
10
type: String ,
11
11
default: ' block' ,
12
- }
12
+ },
13
13
},
14
14
data : () => ({
15
15
active: false ,
16
16
}),
17
17
render (h ) {
18
18
return h (this .tag , {
19
19
style: {
20
- display: this .active ? this . display : ' none' ,
20
+ display: this .active ? ' block ' : ' none' ,
21
21
},
22
22
}, this .$slots .default );
23
23
},
Original file line number Diff line number Diff line change 1
1
<script >
2
2
export default {
3
- name: ' dropdown ' ,
3
+ name: ' toggle ' ,
4
4
props: {
5
5
tag: {
6
6
type: String ,
7
7
default: ' div' ,
8
8
},
9
9
},
10
10
data : () => ({
11
- dropdown : null ,
11
+ target : null ,
12
12
}),
13
13
computed: {
14
14
active () {
15
- return this .dropdown ? this .dropdown .active : false ;
15
+ return this .target ? this .target .active : false ;
16
16
},
17
17
},
18
18
watch: {
@@ -32,21 +32,17 @@ export default {
32
32
}, this .$slots .default );
33
33
},
34
34
mounted () {
35
- this .dropdown = this .$children .find (child => {
36
- return child .$options .name === ' dropdown-menu ' ;
35
+ this .target = this .$children .find (child => {
36
+ return child .$options .name === ' target ' ;
37
37
});
38
38
},
39
39
methods: {
40
- toggle () {
41
- return this .dropdown .toggle ();
40
+ toggle () {
41
+ return this .target .toggle ();
42
42
},
43
43
clickAway (event ) {
44
- if (! this .dropdown .active ) {
45
- return false ;
46
- }
47
-
48
44
if (! event .composedPath ().includes (this .$el )) {
49
- this .dropdown .toggle (false );
45
+ this .target .toggle (false );
50
46
}
51
47
},
52
48
},
You can’t perform that action at this time.
0 commit comments