allow snippets on labels
This commit is contained in:
parent
12e9233ace
commit
01704b5a88
1 changed files with 26 additions and 17 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { DaisyColor, DaisySize } from '$lib/types';
|
import type { DaisyColor, DaisySize } from '$lib/types';
|
||||||
|
import type { Snippet } from 'svelte';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
bordered?: boolean;
|
bordered?: boolean;
|
||||||
color?: Omit<DaisyColor, 'neutral'>;
|
color?: Omit<DaisyColor, 'neutral'>;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
error?: string;
|
error?: string | Snippet;
|
||||||
label?: string;
|
label?: string | Snippet;
|
||||||
size?: DaisySize;
|
size?: DaisySize;
|
||||||
};
|
};
|
||||||
let { bordered, color, disabled, error, label, size }: Props = $props();
|
let { bordered, color, disabled, error, label, size }: Props = $props();
|
||||||
|
|
@ -14,7 +15,6 @@
|
||||||
|
|
||||||
<label class="form-control w-full max-w-lg">
|
<label class="form-control w-full max-w-lg">
|
||||||
<div class="label">
|
<div class="label">
|
||||||
{#if label}
|
|
||||||
<span
|
<span
|
||||||
class="label-text"
|
class="label-text"
|
||||||
class:text-primary={color === 'primary'}
|
class:text-primary={color === 'primary'}
|
||||||
|
|
@ -23,12 +23,21 @@
|
||||||
class:text-info={color === 'info'}
|
class:text-info={color === 'info'}
|
||||||
class:text-success={color === 'success'}
|
class:text-success={color === 'success'}
|
||||||
class:text-warning={color === 'warning'}
|
class:text-warning={color === 'warning'}
|
||||||
class:text-error={color === 'error' || error}>{label}</span
|
class:text-error={color === 'error' || error}
|
||||||
>
|
>
|
||||||
|
{#if typeof label === 'string'}
|
||||||
|
{label}
|
||||||
|
{:else if label}
|
||||||
|
{@render label()}
|
||||||
{/if}
|
{/if}
|
||||||
{#if error}
|
</span>
|
||||||
<span class="label-text-alt font-semibold text-error">{error}</span>
|
<span class="label-text-alt font-semibold text-error">
|
||||||
|
{#if typeof error === 'string'}
|
||||||
|
{error}
|
||||||
|
{:else if error}
|
||||||
|
{@render error()}
|
||||||
{/if}
|
{/if}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<textarea
|
<textarea
|
||||||
class="textarea"
|
class="textarea"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue