Skip to content

Commit 79475b7

Browse files
committed
WIP: basic ui logic command bar
1 parent 7cf66b2 commit 79475b7

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

app/app.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ if (import.meta.client) {
6969
<template>
7070
<div class="min-h-screen flex flex-col bg-bg text-fg">
7171
<a href="#main-content" class="skip-link font-mono">{{ $t('common.skip_link') }}</a>
72+
<CommandBar />
7273

7374
<AppHeader :show-logo="!isHomepage" />
7475

app/components/CommandBar.vue

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<div class="fixed inset-0 z-[1000] flex items-center justify-center bg-black/50 backdrop-blur-sm">
3+
<div
4+
class="cmdbar-container flex items-center justify-center border border-border shadow-lg rounded-xl bg-bg p2 flex-col gap-2"
5+
>
6+
<label for="command-input" class="sr-only">command-input</label>
7+
8+
<input
9+
type="text"
10+
label="Enter command..."
11+
v-model="inputVal"
12+
id="command-input"
13+
class="w-96 h-12 px-4 text-fg outline-none bg-bg-subtle border border-border rounded-md"
14+
placeholder="Enter command..."
15+
/>
16+
17+
<div class="w-96 h-48 overflow-auto">
18+
<div
19+
v-for="item in filteredCmdList"
20+
:key="item.id"
21+
class="flex-col items-center justify-between px-4 py-2 not-first:mt-2 hover:bg-bg-subtle select-none cursor-pointer rounded-md"
22+
:class="{ 'bg-bg-subtle': item.id === selected }"
23+
>
24+
<div class="text-fg">{{ item.name }}</div>
25+
<div class="text-fg-subtle">{{ item.description }}</div>
26+
</div>
27+
</div>
28+
</div>
29+
</div>
30+
</template>
31+
32+
<script setup lang="ts">
33+
const cmdList = [
34+
{
35+
id: 'npmx',
36+
name: 'npmx',
37+
description: 'Run npmx commands',
38+
},
39+
{
40+
id: 'npmx-init',
41+
name: 'npmx init',
42+
description: 'Initialize a new npmx project',
43+
},
44+
{
45+
id: 'npmx-install',
46+
name: 'npmx install',
47+
description: 'Install npmx dependencies',
48+
},
49+
{
50+
id: 'npmx-run',
51+
name: 'npmx run',
52+
description: 'Run npmx scripts',
53+
},
54+
]
55+
56+
const selected = ref(cmdList[0]?.id || '')
57+
const inputVal = ref('')
58+
59+
const filteredCmdList = computed(() => {
60+
if (!inputVal.value) {
61+
return cmdList
62+
}
63+
const filter = inputVal.value.trim().toLowerCase()
64+
return cmdList.filter(
65+
item =>
66+
item.name.toLowerCase().includes(filter) ||
67+
item.description.toLowerCase().includes(filter) ||
68+
item.id.includes(filter),
69+
)
70+
})
71+
72+
watch(
73+
() => filteredCmdList.value,
74+
newVal => {
75+
if (newVal.length) {
76+
selected.value = newVal[0]?.id || ''
77+
}
78+
},
79+
)
80+
</script>

0 commit comments

Comments
 (0)