Skip to content

Commit

Permalink
add error highlighting to select class
Browse files Browse the repository at this point in the history
  • Loading branch information
MaHaWo committed Sep 5, 2024
1 parent c1cd3f1 commit eb5e659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/lib/components/DataInput/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import { Label, Select } from 'flowbite-svelte';
export let value: string;
export let valid: Boolean = true;
export let valid: Boolean;
export let cls: String = '';
export function validate(value: unknown): void {
if (value !== undefined && value !== null && value !== '') {
Expand All @@ -20,7 +21,9 @@
<div>
<Select
size="lg"
class="mb-3 font-normal leading-tight text-gray-700 dark:text-gray-400"
class={(!valid && $$props.required === true
? 'border-6 border-primary-600 text-white dark:border-primary-600'
: '') + cls}
items={$$props.items.map((v) => {
return {
name: String(v),
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/UserDataInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
<form class="m-1 mx-auto w-full flex-col space-y-6">
{#each data as element, i}
{#if 'items' in element}
<Select {...element} bind:value={inputValues[i]} />
<Select {...element} bind:value={inputValues[i]} valid={!missingValues[i]} />
{:else}
<Input {element} bind:value={inputValues[i]} valid={!missingValues[i]} />
{/if}
Expand Down

0 comments on commit eb5e659

Please sign in to comment.