Skip to content

Commit 1b550cc

Browse files
committed
feat: add file icons beside file names (#110)
1 parent f684e45 commit 1b550cc

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"lint": "prettier --check . && pnpm run black:lint && pnpm run isort:lint"
1414
},
1515
"devDependencies": {
16+
"@iconify/iconify": "^2.0.0",
1617
"@types/file-saver": "^2.0.2",
1718
"@types/prismjs": "^1.16.5",
1819
"@vitejs/plugin-vue": "^1.2.2",
1920
"@vue/compiler-sfc": "^3.0.11",
2021
"conventional-changelog-cli": "^2.1.1",
2122
"file-saver": "^2.0.5",
22-
"handlebars": "^4.7.7",
2323
"jszip": "^3.6.0",
2424
"prettier": "^2.2.1",
2525
"prismjs": "^1.23.0",

pnpm-lock.yaml

+28
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/PaneRight.vue

+20-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
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>
@@ -21,20 +22,33 @@
2122
import CodeBlock from './CodeBlock.vue'
2223
import { getTemplateFileNames, store } from '../store'
2324
import { computed, ref } from 'vue'
25+
import '@iconify/iconify'
2426
2527
export 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

Comments
 (0)