Skip to content

Commit 5aeb507

Browse files
committed
feat: support rendering iconify icon
1 parent f7f05ea commit 5aeb507

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

packages/core/playground/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default defineConfig({
3535
setup(ctx) {
3636
ctx.docks.register({
3737
title: 'Local',
38-
icon: 'https://upload.wikimedia.org/wikipedia/commons/9/95/Vue.js_Logo_2.svg',
38+
icon: 'logos:vue',
3939
id: 'local',
4040
type: 'iframe',
4141
url: 'https://antfu.me',
@@ -50,7 +50,7 @@ export default defineConfig({
5050
}),
5151
id: 'local2',
5252
title: 'Local2',
53-
icon: 'https://upload.wikimedia.org/wikipedia/commons/9/95/Vue.js_Logo_2.svg',
53+
icon: 'material-symbols-light:add-alert',
5454
})
5555
},
5656
},

packages/core/src/client/webcomponents/components/DockEntries.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { DevToolsDockEntry } from '@vitejs/devtools-kit'
33
import { toRefs } from 'vue'
4+
import DockIcon from './DockIcon.vue'
45
56
const props = defineProps<{
67
selected?: DevToolsDockEntry
@@ -40,12 +41,7 @@ function toggleDockEntry(dock: DevToolsDockEntry) {
4041
class="flex items-center justify-center p1.5 rounded-xl hover:bg-[#8881] hover:scale-120 transition-all duration-300 relative"
4142
@click="toggleDockEntry(dock)"
4243
>
43-
<img
44-
:src="dock.icon"
45-
:alt="dock.title"
46-
class="w-5 h-5 select-none"
47-
draggable="false"
48-
>
44+
<DockIcon :icon="dock.icon" :title="dock.title" class="w-5 h-5 select-none" />
4945
</button>
5046
<div class="vite-devtools-dock-label text-xs group-hover:opacity-100 opacity-0 transition-opacity duration-300 w-max bg-glass border border-base z-10 rounded px2 absolute p1">
5147
{{ dock.title }}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script setup lang="ts">
2+
defineProps<{
3+
icon: string
4+
title?: string
5+
}>()
6+
7+
function getIconUrl(str: string, color: 'dark' | 'light') {
8+
if (str.includes('/'))
9+
return str
10+
const match = str.match(/^([\w-]+):([\w-]+)$/)
11+
if (match) {
12+
const [, collection, icon] = match
13+
return `https://api.iconify.design/${collection}/${icon}.svg${color === 'dark' ? '?color=%23eee' : '?color=%23111'}`
14+
}
15+
return str
16+
}
17+
</script>
18+
19+
<template>
20+
<img
21+
:src="getIconUrl(icon, 'dark')"
22+
:alt="title"
23+
draggable="false"
24+
>
25+
</template>

0 commit comments

Comments
 (0)