mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: input count dynamic color
This commit is contained in:
1 parent
cad6f3b1bf
commit
5c0cec6ed7
2 files changed
+50
-10
No files matched your search
@@ -12,6 +12,8 @@
|
||||
export let readonly = false;
|
||||
export let autofocus = false;
|
||||
export let maxlength: number = null;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let tooltip: string = null;
|
||||
|
||||
let element: HTMLTextAreaElement;
|
||||
let error: string;
|
||||
@@ -37,7 +39,7 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
<Label {required} {tooltip} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
@@ -53,8 +55,33 @@
|
||||
bind:value
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid} />
|
||||
{#if maxlength}
|
||||
<span class="text-counter" data-active={!!value}>
|
||||
<span class="text-counter-count">{value?.length ?? 0}</span>
|
||||
<span class="text-counter-separator" />
|
||||
<span class="text-counter-max">{maxlength}</span>
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
{/if}
|
||||
</FormItem>
|
||||
|
||||
<style class="scss">
|
||||
.text-counter {
|
||||
--p-text-counter-color: var(--color-neutral-50);
|
||||
}
|
||||
|
||||
.text-counter[data-active='true'] {
|
||||
--p-text-counter-color: var(--color-neutral-70);
|
||||
}
|
||||
|
||||
:global(.theme-dark) .text-counter {
|
||||
--p-text-counter-color: var(--color-neutral-70);
|
||||
}
|
||||
|
||||
:global(.theme-dark) .text-counter[data-active='true'] {
|
||||
--p-text-counter-color: var(--color-neutral-50);
|
||||
}
|
||||
</style>
|
||||
+22
-9
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import InputText from '$lib/elements/forms/inputText.svelte';
|
||||
import InputTextarea from '$lib/elements/forms/inputTextarea.svelte';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
|
||||
export let id: string;
|
||||
@@ -9,12 +10,24 @@
|
||||
export let optionalText: string | undefined = undefined;
|
||||
</script>
|
||||
|
||||
<InputText
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
placeholder="Enter string"
|
||||
showLabel={!!label?.length}
|
||||
required={attribute.required}
|
||||
maxlength={attribute.size}
|
||||
bind:value />
|
||||
{#if attribute.size > 64}
|
||||
<InputTextarea
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
placeholder="Enter string"
|
||||
showLabel={!!label?.length}
|
||||
required={attribute.required}
|
||||
maxlength={attribute.size}
|
||||
bind:value />
|
||||
{:else}
|
||||
<InputText
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
placeholder="Enter string"
|
||||
showLabel={!!label?.length}
|
||||
required={attribute.required}
|
||||
maxlength={attribute.size}
|
||||
bind:value />
|
||||
{/if}
|
||||
Reference in new issue
Block a user