Simplify TextInput

Extracts the validation message out of the `TextInput` component.
For a nice and flexible layout we should render the validation message
outside of the `TextInput` component and just do text input.
This commit is contained in:
Sebastian Martinez
2023-12-21 14:05:17 +00:00
committed by Rūdolfs Ošiņš
parent 851a444b5d
commit 2472938bf1
3 changed files with 55 additions and 79 deletions
+13 -1
View File
@@ -79,6 +79,14 @@
width: 100%;
gap: 0.25rem;
}
.validation-message {
display: flex;
align-items: center;
gap: 0.25rem;
color: var(--color-foreground-red);
position: relative;
margin-top: 0.5rem;
}
</style>
<div>
@@ -108,7 +116,6 @@
<div style="width:100%; display: flex; align-items: center;">
<TextInput
{valid}
{validationMessage}
autofocus
disabled={submitInProgress}
bind:value={inputValue}
@@ -126,6 +133,11 @@
<IconSmall name="checkmark" />
</IconButton>
</div>
{#if !valid && validationMessage}
<div class="validation-message">
<IconSmall name="exclamation-circle" />{validationMessage}
</div>
{/if}
{:else}
<Badge
variant="outline"
+13 -2
View File
@@ -68,6 +68,14 @@
flex-direction: row;
gap: 0.5rem;
}
.validation-message {
display: flex;
align-items: center;
gap: 0.25rem;
color: var(--color-foreground-red);
position: relative;
margin-top: 0.5rem;
}
</style>
<div>
@@ -93,9 +101,7 @@
<TextInput
autofocus
{valid}
{validationMessage}
disabled={submitInProgress}
size="small"
placeholder="Add label"
bind:value={inputValue}
on:submit={addLabel} />
@@ -111,6 +117,11 @@
<IconSmall name="checkmark" />
</IconButton>
</div>
{#if !valid && validationMessage}
<div class="validation-message">
<IconSmall name="exclamation-circle" />{validationMessage}
</div>
{/if}
{:else}
<Badge
variant="outline"