7
7
:class =" { active: currentTab === tab }"
8
8
@click =" currentTab = tab"
9
9
>
10
+ <span class =" iconify" :data-icon =" getFileType(tab)" ></span >
10
11
{{ tab }}
11
12
</div >
12
13
</div >
21
22
import CodeBlock from ' ./CodeBlock.vue'
22
23
import { getTemplateFileNames , store } from ' ../store'
23
24
import { computed , ref } from ' vue'
25
+ import ' @iconify/iconify'
24
26
25
27
export default {
26
28
components: { CodeBlock },
27
29
setup () {
28
30
const currentTab = ref (' README.md' )
29
31
const tabs = ref (getTemplateFileNames ())
32
+ // search more file types mapping on
33
+ // https://icones.js.org/collection/vscode-icons
34
+ const fileTypes = {
35
+ py: ' python' ,
36
+ md: ' markdown' ,
37
+ json: ' json' ,
38
+ txt: ' text'
39
+ }
30
40
31
41
const getLang = computed (() => {
32
42
return currentTab .value .split (' .' )[1 ]
33
43
})
44
+ const getFileType = (tab ) => {
45
+ const fileType = tab .split (' .' )[1 ]
46
+ return ` vscode-icons:file-type-${ fileTypes[fileType]} `
47
+ }
34
48
const formattedCode = () => {
35
49
return store .code [currentTab .value ]
36
50
}
37
- return { currentTab, tabs, getLang, formattedCode }
51
+ return { currentTab, tabs, getLang, getFileType, formattedCode }
38
52
}
39
53
}
40
54
</script >
@@ -53,6 +67,8 @@ export default {
53
67
padding-right : 1.5rem ;
54
68
}
55
69
.right-pane-tab {
70
+ display : flex ;
71
+ place-items : center ;
56
72
background-color : var (--c-white );
57
73
cursor : pointer ;
58
74
color : var (--c-text );
@@ -67,6 +83,9 @@ export default {
67
83
color : var (--c-brand-red );
68
84
border-bottom-color : var (--c-brand-red );
69
85
}
86
+ .iconify {
87
+ margin-right : 6px ;
88
+ }
70
89
/* media queries */
71
90
@media (max-width : 768px ) {
72
91
.right-pane-contexts {
0 commit comments