mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
* chore(deps-dev): upgrade carbon-components to v10.27.1 * fix(toolbar-search): omit size prop * feat(progress-bar): add ProgressBar * refactor(text-input): use class directive * chore(deps-dev): rebuild yarn.lock * fix(notification): omit iconDescription from NotificationIcon #672 Fixes #672
36 lines
774 B
Svelte
36 lines
774 B
Svelte
<script>
|
|
import { onMount } from "svelte";
|
|
import { ProgressBar } from "carbon-components-svelte";
|
|
|
|
let max = 328;
|
|
let value = 0;
|
|
let timer = undefined;
|
|
|
|
onMount(() => {
|
|
timer = setTimeout(() => {
|
|
const interval = setInterval(() => {
|
|
const delta = Math.random() * 10;
|
|
|
|
if (value + delta < max) {
|
|
value += delta;
|
|
} else {
|
|
value = max;
|
|
clearInterval(interval);
|
|
}
|
|
}, 20);
|
|
}, 2000);
|
|
|
|
return () => clearTimeout(timer);
|
|
});
|
|
|
|
$: helperText =
|
|
value > 0 ? `${value.toFixed(0)}MB of ${max}MB` : "Preparing upload...";
|
|
$: if (value === max) helperText = "Done";
|
|
</script>
|
|
|
|
<ProgressBar
|
|
labelText="Upload status"
|
|
value="{value}"
|
|
max="{max}"
|
|
helperText="{helperText}"
|
|
/>
|