flotilla/src/lib/components/Field.svelte

35 lines
736 B
Svelte
Raw Normal View History

2025-02-04 00:37:14 +00:00
<script lang="ts">
2025-02-05 18:47:56 +00:00
import type {Snippet} from "svelte"
2025-02-04 00:37:14 +00:00
interface Props {
2025-02-05 18:47:56 +00:00
label?: Snippet
2025-05-13 21:31:34 +00:00
secondary?: Snippet
2025-02-05 18:47:56 +00:00
input?: Snippet
info?: Snippet
2025-02-04 00:37:14 +00:00
[key: string]: any
}
2025-05-13 21:31:34 +00:00
const {label, secondary, input, info, ...props}: Props = $props()
2025-02-04 00:37:14 +00:00
</script>
<div class="flex flex-col gap-2 {props.class}">
2025-05-13 21:31:34 +00:00
<div class="flex items-center justify-between">
{#if label}
<label class="flex items-center gap-2 font-bold">
{@render label()}
</label>
{/if}
{#if secondary}
<label class="flex items-center gap-2">
{@render secondary()}
</label>
{/if}
</div>
2025-02-05 18:47:56 +00:00
{@render input?.()}
{#if info}
2025-09-06 00:20:12 +00:00
<p class="text-sm opacity-50">
2025-02-05 18:47:56 +00:00
{@render info()}
2024-10-17 22:21:22 +00:00
</p>
{/if}
2024-08-08 21:02:46 +00:00
</div>