This is the code that runs https://bandolier.learnjsthehardway.com/ for you to review. It uses the https://git.learnjsthehardway.com/learn-javascript-the-hard-way/bandolier-template to create the documentation for the project.
https://bandolier.learnjsthehardway.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
898 B
37 lines
898 B
2 years ago
|
<script>
|
||
|
export let form = {};
|
||
|
export let field = "";
|
||
|
export let label=field;
|
||
|
/* Use for checkbox where the check needs to be "inline" with the label. */
|
||
|
export let inline = false;
|
||
|
</script>
|
||
|
|
||
|
{#if form}
|
||
|
{#if inline}
|
||
|
{#if !form._valid && form._errors && form._errors[field]}
|
||
|
{#each form._errors[field] as error, i}
|
||
|
<error data-testid="{field}-error-{i}">
|
||
|
{ error }
|
||
|
</error>
|
||
|
{/each}
|
||
|
{/if}
|
||
|
<label for={ field }>
|
||
|
<slot></slot> { label }
|
||
|
</label>
|
||
|
{:else}
|
||
|
<label for={ field }>{ label }</label>
|
||
|
{#if !form._valid && form._errors && form._errors[field]}
|
||
|
{#each form._errors[field] as error, i}
|
||
|
<error data-testid="{field}-error-{i}">
|
||
|
{ error }
|
||
|
</error>
|
||
|
{/each}
|
||
|
{/if}
|
||
|
<slot></slot>
|
||
|
{/if}
|
||
|
{:else}
|
||
|
<callout class="error">
|
||
|
No form property. Check your code.
|
||
|
</callout>
|
||
|
{/if}
|