Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new Data Table Progress Indicator component
- Loading branch information
Showing
5 changed files
with
109 additions
and
2 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
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
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
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,61 @@ | ||
<DataTable table$aria-label="Todo list" style="width: 100%;"> | ||
<Head> | ||
<Row> | ||
<Cell numeric>ID</Cell> | ||
<Cell style="width: 100%;">Name</Cell> | ||
<Cell>Username</Cell> | ||
<Cell>Email</Cell> | ||
</Row> | ||
</Head> | ||
<Body> | ||
{#each items as item (item.id)} | ||
<Row> | ||
<Cell numeric>{item.id}</Cell> | ||
<Cell>{item.name}</Cell> | ||
<Cell>{item.username}</Cell> | ||
<Cell>{item.email}</Cell> | ||
</Row> | ||
{/each} | ||
</Body> | ||
|
||
<LinearProgress | ||
indeterminate | ||
bind:closed={loaded} | ||
aria-label="Data is being loaded..." | ||
slot="progress" | ||
/> | ||
</DataTable> | ||
|
||
<div style="margin-top: 1em;"> | ||
<Button on:click={() => loadThings(true)}>Do Pretend Loading</Button> | ||
</div> | ||
|
||
<script> | ||
import DataTable, { Head, Body, Row, Cell } from '@smui/data-table'; | ||
import LinearProgress from '@smui/linear-progress'; | ||
import Button from '@smui/button'; | ||
let items = []; | ||
let loaded = false; | ||
loadThings(false); | ||
function loadThings(wait) { | ||
if (typeof fetch !== 'undefined') { | ||
loaded = false; | ||
fetch('https://jsonplaceholder.typicode.com/users') | ||
.then((response) => response.json()) | ||
.then((json) => | ||
setTimeout( | ||
() => { | ||
items = json; | ||
loaded = true; | ||
}, | ||
// Simulate a long load time. | ||
wait ? 2000 : 0 | ||
) | ||
); | ||
} | ||
} | ||
</script> |
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