impr: use native forms instead of submit events

This commit is contained in:
Xylight committed 2024-11-10 13:34:28 -08:00
1 parent 3ebb46e37d
commit 4771d343e6
6 files changed
+27 -22

No files matched your search

+4 -3
View File
@@ -30,6 +30,7 @@
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { fly } from 'svelte/transition'
import { backOut, expoOut } from 'svelte/easing'
import { goto } from '$app/navigation'
let { data } = $props()
@@ -61,14 +62,14 @@
>
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70 shadow-md shadow-black/5">
<form
onsubmit={preventDefault(() =>
searchParam($page.url, 'q', search, 'page'),
)}
method="get"
action="/communities"
class="flex gap-2 flex-row items-center w-full text-base h-10"
>
<TextInput
bind:value={search}
bind:element={searchElement}
name="q"
aria-label={$t('routes.search.query')}
size="lg"
class="flex-1 !rounded-full h-full"
@@ -47,6 +47,8 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import CommentListVirtualizer from '$lib/components/lemmy/comment/CommentListVirtualizer.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { fly } from 'svelte/transition'
import { expoOut } from 'svelte/easing'
let { data = $bindable() } = $props()
@@ -368,10 +370,19 @@
</div>
</header>
{#await data.comments}
<div class="space-y-4">
{#each new Array(10) as empty}
<div class="animate-pulse flex flex-col gap-2 skeleton w-full">
<div class="w-96 h-4"></div>
<div class="flex flex-col gap-4">
{#each new Array(10) as empty, index}
<div
in:fly|global={{
duration: 500,
easing: expoOut,
y: 8,
delay: index * 25,
}}
class="animate-pulse flex flex-col gap-2 w-full
*:bg-slate-100 *:dark:bg-zinc-800 *:rounded-md"
>
<div class="w-96 h-3"></div>
<div class="w-full h-12"></div>
<div class="w-48 h-4"></div>
</div>
@@ -496,9 +507,3 @@
</EndPlaceholder>
{/if}
</section>
<style lang="postcss">
.skeleton * {
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
}
</style>
+6 -5
View File
@@ -39,13 +39,14 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
import { goto } from '$app/navigation'
type Result = PostView | CommentView | PersonView | CommunityView
let { data = $bindable() } = $props()
let query = $state(data.query || '')
let searchElement: HTMLInputElement = $state()
let searchElement: HTMLInputElement | undefined = $state()
let pageNum = $state(data.page)
@@ -71,14 +72,14 @@
>
<Tabs routes={[]} class="p-2 dark:bg-zinc-925/70">
<form
onsubmit={preventDefault(() =>
searchParam($page.url, 'q', query, 'page'),
)}
method="get"
action="/search"
class="flex gap-2 flex-row items-center w-full text-base h-10"
>
<TextInput
bind:value={query}
bind:element={searchElement}
name="q"
aria-label={$t('routes.search.query')}
size="lg"
class="flex-1 !rounded-full h-full !text-base"
@@ -104,7 +105,7 @@
bind:value={data.type}
on:change={() => searchParam($page.url, 'type', data.type ?? 'All', 'page')}
>
{#snippet label()}
{#snippet customLabel()}
<span class="flex items-center gap-1">
<Icon src={AdjustmentsHorizontal} mini size="15" />
{$t('filter.type')}