fix: input text missing text counter

This commit is contained in:
tglide committed 2023-03-20 19:22:55 +00:00
1 parent 25d5ab173f
commit a160506a74
3 files changed
+32 -28

No files matched your search

+2 -5
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { FormItem, Helper, Label } from '.';
import TextCounter from './textCounter.svelte';
export let label: string;
export let optionalText: string | undefined = undefined;
@@ -62,11 +63,7 @@
bind:this={element}
on:invalid={handleInvalid} />
{#if maxlength}
<span class="text-counter">
<span class="text-counter-count">{value?.length ?? 0}</span>
<span class="text-counter-separator" />
<span class="text-counter-max">{maxlength}</span>
</span>
<TextCounter max={maxlength} count={value?.length ?? 0} />
{/if}
</div>
{#if error}
+2 -23
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { FormItem, Helper, Label } from '.';
import TextCounter from './textCounter.svelte';
export let label: string;
export let showLabel = true;
@@ -56,32 +57,10 @@
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>
<TextCounter max={maxlength} count={value?.length ?? 0} />
{/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>
+28
View File
@@ -0,0 +1,28 @@
<script lang="ts">
export let count: number;
export let max: number;
</script>
<span class="text-counter" class:active={count > 0}>
<span class="text-counter-count">{count}</span>
<span class="text-counter-separator" />
<span class="text-counter-max">{max}</span>
</span>
<style lang="scss">
.text-counter {
--p-text-counter-color: var(--color-neutral-50);
&.active {
--p-text-counter-color: var(--color-neutral-70);
}
}
:global(.theme-dark) .text-counter {
--p-text-counter-color: var(--color-neutral-70);
&.active {
--p-text-counter-color: var(--color-neutral-50);
}
}
</style>