Skip to content

Commit

Permalink
feat: add loading message and todo count
Browse files Browse the repository at this point in the history
  • Loading branch information
espy committed May 14, 2019
1 parent 02cd080 commit 4d79812
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
let newTodoText = ''
let sortByWhat = 'createdAt'
let filterByWhat = ''
let isLoading = true
// All the todos directly from the PouchDB. Sorting and filtering comes later
let todos = []
$: sortedAndFilteredTodos = sortBy(todos, [sortByWhat]).filter((todo) => {
Expand All @@ -37,6 +38,7 @@
include_docs: true
})
todos = allDocs.rows.map(row => row.doc)
isLoading = false
}
// Event handlers for adding, updating and removing todos
Expand Down Expand Up @@ -92,6 +94,22 @@
}
</style>

{#if isLoading}
<h1>
Loading your todos…
</h1>
{:else}
{#if todos.length === 0}
<h1>
Zero Todos! Nice ✊
</h1>
{:else}
<h1>
Showing {sortedAndFilteredTodos.length} of {todos.length} todos
</h1>
{/if}
{/if}

<div>
<label>Sort by:</label>
<select bind:value={sortByWhat}>
Expand Down

0 comments on commit 4d79812

Please sign in to comment.