Skip to content

Commit c3d4be5

Browse files
committed
implement #130
1 parent 8003c14 commit c3d4be5

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

exampleVault/Input Fields/Text.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
text: test
2+
text: alnsdksdnfknfnjksdbfhjdf
33
textArea: textArea
44
---
55

@@ -8,6 +8,10 @@ textArea: textArea
88
INPUT[text(showcase):text]
99
```
1010

11+
```meta-bind
12+
INPUT[text(showcase, limit(10)):text]
13+
```
14+
1115
### Text Area
1216
```meta-bind
1317
INPUT[text_area(showcase, class(meta-bind-full-width), class(meta-bind-high)):textArea]

src/inputFields/_new/fields/Text/TextComponent.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,16 @@
77
export function setValue(v: string): void {
88
value = v;
99
}
10+
11+
function getLimitString(length: number, limit: number) {
12+
const limitStr = limit.toString();
13+
const lengthStr = length.toString().padStart(limitStr.length, '0');
14+
return `${lengthStr}/${limitStr}`;
15+
}
1016
</script>
1117

1218
<input type='text' tabindex='0' placeholder={placeholder} bind:value={value} maxlength={limit}
1319
on:input={() => onValueChange(value)}>
20+
{#if limit !== undefined}
21+
<span class={`mb-content-limit-indicator ${value.length > limit ? 'mb-content-limit-indicator-overflow' : ''}`} >{getLimitString(value.length, limit)}</span>
22+
{/if}

styles.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ div.mb-view-wrapper {
5858
color: var(--text-muted);
5959
}
6060

61+
/* Text Input */
62+
.mb-content-limit-indicator {
63+
color: var(--text-muted);
64+
font-size: var(--font-ui-small);
65+
}
66+
67+
.mb-content-limit-indicator-overflow {
68+
color: var(--color-red);
69+
}
70+
6171
/* Select Input */
6272
.mb-select-input-element {
6373
cursor: pointer;

0 commit comments

Comments
 (0)