5
5
<span >No shortcuts found! Edit <pre >shortcuts.yaml</pre > to get started.</span >
6
6
</div >
7
7
<template v-else >
8
- <article v-for =" group in groups" class =" shortcuts-group" >
9
- <h3 class =" shortucts-group__title" >{{ group.name }}</h3 >
10
- <ul class =" shortcuts-list" >
11
- <li class =" shortcuts-list__item" v-for =" item in group.items" :key =" item.keys + item.name" >
12
- <span >{{ item.name }}</span >
13
- <pre >{{ item.keys }}</pre >
14
- </li >
15
- </ul >
16
- </article >
8
+ <input class =" shortcuts-search" v-model =" search" placeholder =" Search" autofocus />
9
+ <ShortcutGroup v-for =" group in groups" :key =" group.name" :name =" group.name" :items =" filter(group.items)" />
17
10
</template >
18
11
</main >
19
12
</div >
20
13
</template >
21
14
22
15
<script >
16
+ import ShortcutGroup from ' ./ShortcutGroup.vue' ;
17
+
23
18
export default {
19
+ components: {
20
+ ShortcutGroup
21
+ },
24
22
data () {
25
23
return {
24
+ search: ' ' ,
26
25
groups: []
27
- }
26
+ };
28
27
},
29
28
computed: {
30
29
commandOrControl () {
31
30
return window .os === ' darwin' ? ' ⌘' : ' Ctrl' ;
32
- }
31
+ },
33
32
},
34
33
methods: {
35
34
async loadShortcuts () {
@@ -39,12 +38,23 @@ export default {
39
38
},
40
39
async handleEditShortcuts () {
41
40
api .editShortcuts ();
41
+ },
42
+
43
+ filter (items ) {
44
+ const searchTerm = this .search .toLowerCase ();
45
+
46
+ return searchTerm
47
+ ? items .filter ((item ) =>
48
+ item .name .toLowerCase ().includes (searchTerm) ||
49
+ item .keys .toLowerCase ().includes (searchTerm)
50
+ )
51
+ : items;
42
52
}
43
53
},
44
54
async mounted () {
45
55
await this .loadShortcuts ();
46
56
}
47
- }
57
+ };
48
58
</script >
49
59
50
60
<style lang="scss">
@@ -69,6 +79,13 @@ export default {
69
79
font-size : .85rem ;
70
80
font-family : Arial , Helvetica , sans-serif ;
71
81
82
+ .shortcuts-search {
83
+ font-family : inherit ;
84
+ font-size : inherit ;
85
+ width : 100% ;
86
+ padding : .25rem ;
87
+ }
88
+
72
89
.no-shortcuts-config {
73
90
display : flex ;
74
91
justify-content : center ;
@@ -79,58 +96,5 @@ export default {
79
96
display : inline ;
80
97
}
81
98
}
82
-
83
- .shortcuts-group {
84
-
85
- .shortucts-group__title {
86
- margin : 1rem 0 .25rem ;
87
- text-align : center ;
88
- }
89
-
90
- .shortcuts-list {
91
- display : flex ;
92
- flex-direction : row ;
93
- flex-wrap : wrap ;
94
- margin : 0 ;
95
-
96
- .shortcuts-list__item {
97
- display : flex ;
98
- flex-direction : row ;
99
- width : 100% ;
100
- justify-content : space-between ;
101
- align-items : center ;
102
- padding : .25rem .5rem ;
103
-
104
- & :first-child {
105
- border-start-start-radius : 5px ;
106
- border-start-end-radius : 5px ;
107
- }
108
-
109
- & :last-child {
110
- border-end-start-radius : 5px ;
111
- border-end-end-radius : 5px ;
112
- }
113
-
114
- & :nth-child (even ) {
115
- background-color : #efefef ;
116
- }
117
-
118
- & :nth-child (odd ) {
119
- background-color : #dedede ;
120
- }
121
-
122
- > span {
123
- display : block ;
124
- width : auto ;
125
- }
126
-
127
- > pre {
128
- display : block ;
129
- width : auto ;
130
- margin : 0 ;
131
- }
132
- }
133
- }
134
- }
135
99
}
136
100
</style >
0 commit comments