impr: rewrite PostForm component to be stabler and more sustainable (#684)

* impr: rewrite PostForm component into extracted state class

* fix: use base community as PostFormState

* fix: add else clause to ensure 'unset' unsets the language
This commit is contained in:
xylight authored and GitHub committed 2025-11-15 23:12:52 +00:00
1 parent 6f7501ffc5
commit e4507cbf91
16 files changed
+506 -586

No files matched your search

+6 -2
View File
@@ -26,17 +26,18 @@
})
interface Props {
scope?: string | undefined | null
message?: string
class?: string
}
let { scope = undefined, class: clazz = '' }: Props = $props()
let { scope, message, class: clazz = '' }: Props = $props()
let scopedErrors = $derived(
errors.filter((e) => e.scope == scope || e.scope == 'global'),
)
</script>
{#if scopedErrors.length > 0}
{#if scopedErrors.length > 0 || message}
<div
class={['flex flex-col gap-4', clazz]}
in:slide={{ duration: 400, easing: expoOut }}
@@ -59,6 +60,9 @@
micro
class="inline-block rounded-lg clear-both float-left mr-2"
/>
{#if message}
{message}
{/if}
{#each scopedErrors as error}
<p>{error.message}</p>
{/each}