-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: A new component: CategorySelection
- Loading branch information
1 parent
9ebffa9
commit c7b5814
Showing
2 changed files
with
85 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script> | ||
import { onMount } from "svelte"; | ||
let categories = []; | ||
export let selected; | ||
onMount(async () => { | ||
categories = getCategories(); | ||
}); | ||
async function getCategories() { | ||
const result = await fetch("https://northwind.now.sh/api/categories"); | ||
if (result.ok) return result.json(); | ||
} | ||
</script> | ||
|
||
<div class="select"> | ||
{#await categories} | ||
<progress class="progress is-small is-primary" max="100">15%</progress> | ||
{:then list} | ||
<select bind:value={selected}> | ||
{#each list as item} | ||
<option value={item.id}>{item.name}</option> | ||
{/each} | ||
</select> | ||
{:catch} | ||
Error! | ||
{/await} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters