Skip to content

Commit 0e780f7

Browse files
authoredJul 2, 2024··
feat(client): improve Vue api icon on CommandPalette (#501)
1 parent 5a4f729 commit 0e780f7

File tree

4 files changed

+27
-9
lines changed

4 files changed

+27
-9
lines changed
 

Diff for: ‎packages/client/data/vue-apis.json

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@
281281
"description": "compile-time-flags",
282282
"url": "https:/vuejs.org/api/compile-time-flags#VUE_PROD_HYDRATION_MISMATCH_DETAILS"
283283
},
284-
null,
285284
{
286285
"id": "doc:component-instance:$data",
287286
"title": "$data",

Diff for: ‎packages/client/src/components/CommandPalette.vue

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ useEventListener('keydown', (e) => {
113113
>
114114
<div
115115
flex="~ gap-2 items-center justify-between" rounded px3 py2
116-
:class="selectedIndex === idx ? 'op100 bg-primary/10 text-primary saturate-100 bg-active' : 'op80'"
116+
:class="selectedIndex === idx ? 'op100 saturate-100 bg-active' : 'op80'"
117117
>
118118
<TabIcon :icon="item.icon" :title="item.title" flex-none text-xl />
119119
<span flex flex-auto items-center gap2 of-hidden>
@@ -136,10 +136,10 @@ useEventListener('keydown', (e) => {
136136
<footer border="t base" flex="~ none justify-between items-center gap-4" pointer-events-none px4 py2>
137137
<div text-xs flex="~ items-center gap2">
138138
<button px1>
139-
<VueIcon icon="carbon-arrow-down" />
139+
<VueIcon icon="i-carbon-arrow-down" />
140140
</button>
141141
<button px1>
142-
<VueIcon icon="carbon-arrow-up" />
142+
<VueIcon icon="i-carbon-arrow-up" />
143143
</button>
144144
<span op75>to navigate</span>
145145
</div>

Diff for: ‎packages/client/src/composables/state-commands.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,33 @@ export function registerCommands(getter: MaybeRefOrGetter<CommandItem[]>) {
130130

131131
let _vueDocsCommands: CommandItem[] | undefined
132132

133+
const apiIconMapping = {
134+
'utility-types': 'i-mdi-language-typescript',
135+
'ssr': 'i-codicon-server-process',
136+
'custom-renderer': 'i-codicon-server-process',
137+
'sfc-script-setup': 'i-material-symbols:magic-button',
138+
'sfc-css-features': 'i-material-symbols-css',
139+
'built-in-directives': 'i-material-symbols-code',
140+
'built-in-special-attributes': 'i-material-symbols-code',
141+
'component-instance': 'i-material-symbols-code',
142+
'composition-api-dependency-injection': 'i-material-symbols-code',
143+
'composition-api-lifecycle': 'i-material-symbols-code',
144+
'general': 'i-material-symbols-code',
145+
'compile-time-flags': 'i-material-symbols-toggle-on',
146+
'reactivity-utilities': 'i-mdi-api',
147+
'reactivity-advanced': 'i-mdi-api',
148+
'render-function': 'i-mdi-api',
149+
'...others': 'i-uim-vuejs',
150+
}
151+
133152
export async function getVueDocsCommands() {
134153
if (!_vueDocsCommands) {
135154
const list = await import('../../data/vue-apis.json').then(i => i.default)
136155
_vueDocsCommands = list.map(i => ({
137-
...i!,
138-
icon: 'i-carbon-api-1',
156+
...i,
157+
icon: apiIconMapping[i.description] ?? apiIconMapping['...others'],
139158
action: () => {
140-
window.open(i!.url, '_blank')
159+
window.open(i.url, '_blank')
141160
},
142161
}))
143162
}

Diff for: ‎scripts/vue-api-manifest.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ const manifest = await Promise.all(files.map(async (file) => {
5959
url: `https:/vuejs.org/api${parentPath}#${path}`,
6060
}
6161
})
62-
})).then(r => r.filter(Boolean))
62+
})).then(r => r.flat(1).filter(Boolean))
6363

6464
const targetDir = fileURLToPath(new URL('../packages/client/data', import.meta.url))
6565

6666
if (!fse.existsSync(targetDir))
6767
fse.mkdirSync(targetDir)
6868

69-
await fse.writeFile(`${targetDir}/vue-apis.json`, JSON.stringify(manifest.flat(1), null, 2))
69+
await fse.writeFile(`${targetDir}/vue-apis.json`, JSON.stringify(manifest, null, 2))

0 commit comments

Comments
 (0)
Please sign in to comment.