feat: search (#285)

This commit is contained in:
wheat 2022-12-17 16:35:07 -05:00 committed by GitHub
parent 5ff0900108
commit c1d1138742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 252 additions and 6 deletions

View file

@ -0,0 +1,26 @@
<script setup lang="ts">
import type { SearchResult } from './types'
const props = defineProps<{ result: SearchResult; active: boolean }>()
const el = ref<HTMLElement>()
watch(() => props.active, (active) => {
const _el = unrefElement(el)
if (active && _el)
_el.scrollIntoView({ block: 'nearest', inline: 'start' })
})
const onActivate = () => {
(document.activeElement as HTMLElement).blur()
}
</script>
<template>
<RouterLink ref="el" :to="result.to" py2 block px2 :aria-selected="active" :class="{ 'bg-active': active }" hover:bg-active @click="() => onActivate()">
<SearchHashtagInfo v-if="result.type === 'hashtag'" :hashtag="result.hashtag" />
<AccountInfo v-else-if="result.type === 'account'" :account="result.account" />
<div v-else-if="result.type === 'action'" text-center>
{{ result.action!.label }}
</div>
</RouterLink>
</template>