Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
feat: supports filtering documents
Browse files Browse the repository at this point in the history
  • Loading branch information
liuseen-l committed Jul 6, 2023
1 parent c7c3e25 commit 04af532
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions src/client/pages/documentations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { rpc } from '../logic/rpc'
import type { DocumentInfo } from '../../types'
import { data } from '../logic/documentations'
const rawItems = data
const items = ref(data)
const iframeViewUrl = ref('')
let packagesName
rpc.getPackages().then((res) => {
const packagesName = Object.keys(res.packages)
items.value = items.value.filter(item => packagesName.includes(item.id))
packagesName = Object.keys(res.packages)
items.value = rawItems.filter(item => packagesName.includes(item.id))
})
function navigate(data: DocumentInfo) {
Expand All @@ -17,24 +20,35 @@ function navigate(data: DocumentInfo) {
iframeViewUrl.value = data.website
}
const keywords = ref('')
watch(keywords, () => {
items.value = rawItems.filter(item => packagesName.includes(item.id) && (item.id.includes(keywords.value) || keywords.value.length === 0))
})
function back() {
iframeViewUrl.value = ''
}
</script>

<template>
<div v-if="iframeViewUrl" relative h-screen>
<IframeView :src="iframeViewUrl" />
<teleport to="body">
<span
fixed left-2 top-2 z-1000 h-8 w-8 flex cursor-pointer select-none items-center justify-center rounded-5
bg-base hover="text-primary" @click.prevent.stop="back"
>
<i tabler:arrow-back-up />
</span>
</teleport>
</div>
<div v-else grid grid-cols-minmax-400px h-screen select-none gap3 overflow-scroll p4 class="no-scrollbar">
<DocDetails v-for="(item, index) in items" :key="index" :data="item" @navigate="navigate" />
<div class="overflow-y-scroll">
<div border="b base" flex="~ col gap1" px4 py3 navbar-glass>
<VTextInput v-model="keywords" font-mono icon="carbon:search" placeholder="Filter Documentations" op50 />
</div>
<div v-if="iframeViewUrl">
<IframeView :src="iframeViewUrl" />
<teleport to="body">
<span
fixed left-2 top-2 z-1000 h-8 w-8 flex cursor-pointer select-none items-center justify-center rounded-5
bg-base hover="text-primary" @click.prevent.stop="back"
>
<i tabler:arrow-back-up />
</span>
</teleport>
</div>
<div v-else grid grid-cols-minmax-400px h-screen select-none gap3 overflow-scroll p4 class="no-scrollbar">
<DocDetails v-for="(item, index) in items" :key="index" :data="item" @navigate="navigate" />
</div>
</div>
</template>

0 comments on commit 04af532

Please sign in to comment.