Fixed focus styles and added erase value with esc

This commit is contained in:
Alexis
2023-10-13 18:09:59 +02:00
parent e2e6ab8bf1
commit db2f5c5333

View File

@@ -39,12 +39,15 @@ const filteredMarkers = computed(() => {
}) })
}) })
// Handle shortcut to focus the main search fields // Key Combos
const keys = useMagicKeys() const keys = useMagicKeys()
const shortcutKeyCombo = keys['Shift+Period'] const shortcutKeyCombo = keys['Shift+Period']
const eraseKeyCombo = keys['Escape']
whenever(shortcutKeyCombo, () => { whenever(shortcutKeyCombo, () => {
isFocused.value = true isFocused.value = true
})
whenever(eraseKeyCombo, () => {
q.value = "" q.value = ""
}) })
@@ -89,14 +92,14 @@ onUpdated(() => {
<i class="search-icon ph-fill ph-magnifying-glass"></i> <i class="search-icon ph-fill ph-magnifying-glass"></i>
<input ref="qInput" type="text" v-model="q"> <input ref="qInput" type="text" v-model="q">
<button data-to-players class="player-btn"> <button data-to-players class="player-btn" tabindex="1">
<i class="pin-icon ph-fill ph-map-pin"></i> <i class="pin-icon ph-fill ph-map-pin"></i>
</button> </button>
</div> </div>
<ul class="search-results" v-if="shouldBeActive"> <ul class="search-results" v-if="shouldBeActive">
<li v-for="m in filteredMarkers?.slice(0, 10)" :key="m.title"> <li v-for="m in filteredMarkers?.slice(0, 10)" :key="m.title">
<button class="search-item" :data-to-marker="`${m.markerCoords.x},${m.markerCoords.y}`"> <button class="search-item" :data-to-marker="`${m.markerCoords.x},${m.markerCoords.y}`" tabindex="0">
<span class="title">{{ m.title }}</span> <span class="title">{{ m.title }}</span>
<span class="desc">{{ m.description }}</span> <span class="desc">{{ m.description }}</span>
</button> </button>
@@ -178,9 +181,23 @@ onUpdated(() => {
cursor: pointer; cursor: pointer;
padding: .4rem .25em; padding: .4rem .25em;
width: 100%; width: 100%;
outline-offset: -1px;
&:hover { &:hover {
background-color: var(--slate-100); background-color: var(--slate-100);
.title {
text-decoration: underline;
}
}
&:focus-visible {
outline: 1px dotted var(--slate-500);
outline: 4px auto var(--slate-900);
.title {
text-decoration: underline;
}
} }
.title, .title,
@@ -191,6 +208,7 @@ onUpdated(() => {
.title { .title {
font-weight: 500; font-weight: 500;
text-underline-offset: 2px;
} }
.desc { .desc {
color: var(--slate-500); color: var(--slate-500);