77 :class =" { active: currentTab === tab }"
88 @click =" currentTab = tab"
99 >
10+ <span class =" iconify" :data-icon =" getFileType(tab)" ></span >
1011 {{ tab }}
1112 </div >
1213 </div >
2122import CodeBlock from ' ./CodeBlock.vue'
2223import { getTemplateFileNames , store } from ' ../store'
2324import { computed , ref } from ' vue'
25+ import ' @iconify/iconify'
2426
2527export default {
2628 components: { CodeBlock },
2729 setup () {
2830 const currentTab = ref (' README.md' )
2931 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+ }
3040
3141 const getLang = computed (() => {
3242 return currentTab .value .split (' .' )[1 ]
3343 })
44+ const getFileType = (tab ) => {
45+ const fileType = tab .split (' .' )[1 ]
46+ return ` vscode-icons:file-type-${ fileTypes[fileType]} `
47+ }
3448 const formattedCode = () => {
3549 return store .code [currentTab .value ]
3650 }
37- return { currentTab, tabs, getLang, formattedCode }
51+ return { currentTab, tabs, getLang, getFileType, formattedCode }
3852 }
3953}
4054 </script >
@@ -53,6 +67,8 @@ export default {
5367 padding-right : 1.5rem ;
5468}
5569.right-pane-tab {
70+ display : flex ;
71+ place-items : center ;
5672 background-color : var (--c-white );
5773 cursor : pointer ;
5874 color : var (--c-text );
@@ -67,6 +83,9 @@ export default {
6783 color : var (--c-brand-red );
6884 border-bottom-color : var (--c-brand-red );
6985}
86+ .iconify {
87+ margin-right : 6px ;
88+ }
7089/* media queries */
7190@media (max-width : 768px ) {
7291 .right-pane-contexts {
0 commit comments