Skip to content

Commit 34adc76

Browse files
author
codewec
committed
feat: tabs icon
1 parent e610afe commit 34adc76

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

app/components/editoro/header/PinnedBadges.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ watch(() => props.badges, async () => {
135135
class="editoro-file-badge"
136136
:class="{ 'editoro-file-badge-current': badge.isCurrent }"
137137
>
138+
<UIcon
139+
:name="badge.icon"
140+
class="editoro-file-badge-leading"
141+
/>
142+
138143
<button
139144
type="button"
140145
class="editoro-file-badge-label"
@@ -214,6 +219,12 @@ watch(() => props.badges, async () => {
214219
background: color-mix(in oklab, var(--ui-primary) 12%, transparent);
215220
}
216221
222+
.editoro-file-badge-leading {
223+
width: 0.875rem;
224+
height: 0.875rem;
225+
flex-shrink: 0;
226+
}
227+
217228
.editoro-file-badge-label {
218229
appearance: none;
219230
border: 0;

app/composables/useEditoroViewModel.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ type ViewModelOptions = {
1818
}
1919

2020
export function useEditoroViewModel(options: ViewModelOptions) {
21+
function getBadgeIcon(path: string, node?: TreeNode) {
22+
if (node?.icon) {
23+
return node.icon
24+
}
25+
26+
if (node?.type === 'directory') {
27+
return 'i-lucide-folder'
28+
}
29+
30+
const extension = getFileExtension(path)
31+
32+
if (extension === 'md' || extension === 'markdown') {
33+
return 'i-simple-icons-markdown'
34+
}
35+
36+
if (isImagePath(path)) {
37+
return 'i-lucide-image'
38+
}
39+
40+
return 'i-lucide-file'
41+
}
42+
2143
const selectedFolder = computed<DirectoryTreeNode | undefined>(() => {
2244
return options.selectedNode.value?.type === 'directory' ? options.selectedNode.value : undefined
2345
})
@@ -70,6 +92,7 @@ export function useEditoroViewModel(options: ViewModelOptions) {
7092
key: `pinned:${path}`,
7193
path,
7294
label: node?.label || getBaseName(path) || path,
95+
icon: getBadgeIcon(path, node),
7396
isCurrent: currentPath === path,
7497
isPinned: true,
7598
canPin: true
@@ -84,6 +107,7 @@ export function useEditoroViewModel(options: ViewModelOptions) {
84107
label: currentNode.type === 'directory'
85108
? currentNode.path
86109
: (currentNode.label || getBaseName(currentNode.path) || currentNode.path),
110+
icon: getBadgeIcon(currentNode.path, currentNode),
87111
isCurrent: true,
88112
isPinned: false,
89113
canPin: true
@@ -93,6 +117,7 @@ export function useEditoroViewModel(options: ViewModelOptions) {
93117
key: 'root',
94118
path: '',
95119
label: options.t('main.root'),
120+
icon: 'i-lucide-house',
96121
isCurrent: true,
97122
isPinned: false,
98123
canPin: false

app/types/editoro.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export type EditorPinnedBadge = {
3434
key: string
3535
path: string
3636
label: string
37+
icon: string
3738
isCurrent: boolean
3839
isPinned: boolean
3940
canPin: boolean

0 commit comments

Comments
 (0)