flotilla/src/routes/people/+page.svelte

50 lines
1.3 KiB
Svelte
Raw Normal View History

2024-10-24 20:11:53 +00:00
<script lang="ts">
import {onMount} from "svelte"
2024-11-15 23:16:06 +00:00
import {createScroller, isMobile} from "@lib/html"
2024-10-24 20:11:53 +00:00
import {profileSearch} from "@welshman/app"
import Icon from "@lib/components/Icon.svelte"
import Page from "@lib/components/Page.svelte"
import ContentSearch from "@lib/components/ContentSearch.svelte"
import PeopleItem from "@app/components/PeopleItem.svelte"
import {getDefaultPubkeys} from "@app/state"
const defaultPubkeys = getDefaultPubkeys()
let term = ""
let limit = 10
let element: Element
$: pubkeys = term ? $profileSearch.searchValues(term) : defaultPubkeys
onMount(() => {
const scroller = createScroller({
element,
onScroll: () => {
limit += 10
},
})
return () => scroller.stop()
})
</script>
<Page>
<ContentSearch>
2024-10-24 22:48:45 +00:00
<label slot="input" class="row-2 input input-bordered">
2024-10-24 20:11:53 +00:00
<Icon icon="magnifer" />
<!-- svelte-ignore a11y-autofocus -->
2024-10-24 22:48:45 +00:00
<input
2024-11-15 23:16:06 +00:00
autofocus={!isMobile}
2024-10-24 22:48:45 +00:00
bind:value={term}
class="grow"
type="text"
placeholder="Search for people..." />
2024-10-24 20:11:53 +00:00
</label>
<div slot="content" class="col-2" bind:this={element}>
{#each pubkeys.slice(0, limit) as pubkey (pubkey)}
<PeopleItem {pubkey} />
{/each}
</div>
</ContentSearch>
</Page>