7
7
<i class =" fa fa-search fa-lg" aria-hidden =" true" />
8
8
</div >
9
9
<div >
10
- <input class =" borderless-search" type =" text" placeholder =" Find pipeline ..." v-model =" search" >
10
+ <input class =" borderless-search" type =" text" placeholder =" Find pipeline ..." v-model =" search" @input =" onChange" >
11
+ <ul id =" autocomplete-results" v-show =" resultsOpen" class =" autocomplete-results" >
12
+ <li class =" autocomplete-result" v-for =" (result, i) in results" :key =" i" >
13
+ <div class =" results-bg" >
14
+ <div class =" box box-bg" >
15
+ <article class =" media" >
16
+ <div class =" media-left" >
17
+ <div class =" avatar" >
18
+ <img src =" ~assets/golang.png" >
19
+ </div >
20
+ </div >
21
+ <div class =" media-content" style =" margin-top : 7px ;" >
22
+ {{ result.name }}
23
+ </div >
24
+ </article >
25
+ </div >
26
+ </div >
27
+ </li >
28
+ </ul >
11
29
</div >
12
30
<div class =" navbar-button" >
13
31
<a class =" button is-primary" @click =" createPipeline" >
@@ -46,7 +64,9 @@ export default {
46
64
47
65
data () {
48
66
return {
49
- search: ' '
67
+ search: ' ' ,
68
+ resultsOpen: false ,
69
+ results: {}
50
70
}
51
71
},
52
72
@@ -66,6 +86,11 @@ export default {
66
86
67
87
mounted () {
68
88
this .reload ()
89
+ document .addEventListener (' click' , this .handleClickOutside )
90
+ },
91
+
92
+ destroyed () {
93
+ document .removeEventListener (' click' , this .handleClickOutside )
69
94
},
70
95
71
96
watch: {
@@ -82,6 +107,29 @@ export default {
82
107
window .location .reload ()
83
108
},
84
109
110
+ onChange () {
111
+ this .$emit (' input' , this .search )
112
+
113
+ // Fake search
114
+ this .results = [
115
+ {
116
+ name: ' Test 1' ,
117
+ id: 1
118
+ },
119
+ {
120
+ name: ' Test 2' ,
121
+ id: 2
122
+ }
123
+ ]
124
+ this .resultsOpen = true
125
+ },
126
+
127
+ handleClickOutside (evt ) {
128
+ if (! this .$el .contains (evt .target )) {
129
+ this .resultsOpen = false
130
+ }
131
+ },
132
+
85
133
logout () {
86
134
this .$router .push (' /' )
87
135
this .$store .commit (' clearIntervals' )
@@ -181,7 +229,7 @@ export default {
181
229
}
182
230
183
231
.app-navbar {
184
- position : static ;
232
+ position : fixed ;
185
233
min-width : 100% ;
186
234
height : 70px ;
187
235
z-index : 1024 - 1 ;
@@ -206,4 +254,38 @@ export default {
206
254
padding-right : 15px ;
207
255
padding-top : 7px ;
208
256
}
257
+
258
+ .autocomplete-results {
259
+ position : absolute ;
260
+ z-index : 2500 ;
261
+ padding : 0 ;
262
+ margin : 0 ;
263
+ left : 210px ;
264
+ max-width : 350px ;
265
+ box-shadow : 20px 0 30px 0 rgba (0 , 0 , 0 , 0.2 ), 0 6px 20px 0 rgba (255 , 255 , 255 , 0.19 );
266
+ height : 177px ;
267
+ overflow : auto ;
268
+ width : 350px ;
269
+ background-color : #2a2735 !important ;
270
+
271
+ }
272
+
273
+ .autocomplete-result {
274
+ list-style : none ;
275
+ text-align : left ;
276
+ padding : 4px 6px ;
277
+ cursor : pointer ;
278
+ }
279
+
280
+ .autocomplete-result.is-active ,
281
+ .autocomplete-result :hover {
282
+ background-color : #51a0f6 ;
283
+ color : black ;
284
+ }
285
+
286
+ .box-bg {
287
+ background-color : #3f3d49 ;
288
+ color : whitesmoke ;
289
+ text-align : center ;
290
+ }
209
291
</style >
0 commit comments