74 lines
1.9 KiB
Vue
74 lines
1.9 KiB
Vue
<script setup>
|
|
// The dropdown the note editor shows while a widget name or a wiki link is being typed. It only
|
|
// draws what it is handed: each entry carries its own `label` and `hint`, and the parent decides
|
|
// when it is open, where it sits and what is selected.
|
|
defineProps(['suggestions', 'selected', 'position']);
|
|
const emit = defineEmits(['select', 'hover']);
|
|
</script>
|
|
|
|
<template>
|
|
<div class="suggestion-menu" :style="position" role="listbox">
|
|
<div
|
|
v-for="(suggestion, index) in suggestions"
|
|
:key="suggestion.key"
|
|
class="suggestion"
|
|
:class="{ selected: index === selected }"
|
|
role="option"
|
|
:aria-selected="index === selected"
|
|
@mousedown.prevent="emit('select', suggestion)"
|
|
@mouseenter="emit('hover', index)"
|
|
>
|
|
<span class="suggestion-label">{{ suggestion.label }}</span>
|
|
<span class="suggestion-hint">{{ suggestion.hint }}</span>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.suggestion-menu {
|
|
position: absolute;
|
|
z-index: 40;
|
|
min-width: 190px;
|
|
max-width: 320px;
|
|
max-height: 240px;
|
|
overflow-y: auto;
|
|
padding: 4px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 2px;
|
|
|
|
border: 1px solid var(--color-border);
|
|
border-radius: 6px;
|
|
background-color: var(--color-background-light);
|
|
box-shadow: 0 6px 18px var(--color-container-shadow);
|
|
}
|
|
|
|
.suggestion {
|
|
display: flex;
|
|
align-items: baseline;
|
|
justify-content: space-between;
|
|
gap: 12px;
|
|
padding: 4px 8px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.suggestion.selected {
|
|
background-color: var(--color-selected);
|
|
}
|
|
|
|
.suggestion-label {
|
|
font-family: monospace;
|
|
color: var(--color-text);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.suggestion-hint {
|
|
font-size: 11px;
|
|
color: var(--color-gray);
|
|
white-space: nowrap;
|
|
}
|
|
</style>
|