Skip to content

Commit db234b8

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

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

package.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@
1313
"lint": "prettier --check . && pnpm run black:lint && pnpm run isort:lint"
1414
},
1515
"devDependencies": {
16-
"jszip": "^3.6.0",
17-
"file-saver": "^2.0.5",
18-
"prismjs": "^1.23.0",
19-
"vue": "^3.0.11",
16+
"@iconify/iconify": "^2.0.0",
2017
"@types/file-saver": "^2.0.2",
2118
"@types/prismjs": "^1.16.5",
2219
"@vitejs/plugin-vue": "^1.2.2",
2320
"@vue/compiler-sfc": "^3.0.11",
2421
"conventional-changelog-cli": "^2.1.1",
22+
"file-saver": "^2.0.5",
23+
"jszip": "^3.6.0",
2524
"prettier": "^2.2.1",
26-
"vite": "^2.2.3"
25+
"prismjs": "^1.23.0",
26+
"vite": "^2.2.3",
27+
"vue": "^3.0.11"
2728
},
2829
"prettier": {
2930
"semi": false,

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)