2021-04-15 15:39:14 +02:00
|
|
|
<script>
|
2021-04-27 16:41:43 +02:00
|
|
|
import "@spectrum-css/progressbar/dist/index-vars.css"
|
|
|
|
import { tweened } from "svelte/motion"
|
|
|
|
import { cubicOut } from "svelte/easing"
|
2021-04-15 15:39:14 +02:00
|
|
|
|
2021-04-27 16:41:43 +02:00
|
|
|
export let value = false
|
|
|
|
export let easing = cubicOut
|
|
|
|
export let duration = 1000
|
|
|
|
export let width = false
|
|
|
|
export let sideLabel = false
|
2021-04-15 15:39:14 +02:00
|
|
|
|
2021-04-27 16:41:43 +02:00
|
|
|
export let size = "M"
|
2021-04-15 15:39:14 +02:00
|
|
|
|
2021-04-27 16:41:43 +02:00
|
|
|
const progress = tweened(0, {
|
|
|
|
duration: duration,
|
|
|
|
easing: easing,
|
|
|
|
})
|
2021-04-15 15:39:14 +02:00
|
|
|
|
2021-04-27 16:41:43 +02:00
|
|
|
$: if (value) $progress = value
|
2021-04-15 15:39:14 +02:00
|
|
|
</script>
|
|
|
|
|
2021-04-27 16:41:43 +02:00
|
|
|
<div
|
|
|
|
class:spectrum-ProgressBar--indeterminate={!value}
|
|
|
|
class:spectrum-ProgressBar--sideLabel={sideLabel}
|
|
|
|
class="spectrum-ProgressBar spectrum-ProgressBar--size{size}"
|
|
|
|
value={$progress}
|
|
|
|
role="progressbar"
|
|
|
|
aria-valuenow={$progress}
|
|
|
|
aria-valuemin="0"
|
|
|
|
aria-valuemax="100"
|
|
|
|
style={width ? `width: ${width}px;` : ""}
|
|
|
|
>
|
|
|
|
{#if $$slots}
|
|
|
|
<div
|
2021-05-04 12:37:53 +02:00
|
|
|
class="spectrum-FieldLabel spectrum-ProgressBar-label spectrum-FieldLabel--size{size}"
|
2021-04-27 16:41:43 +02:00
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#if value}
|
|
|
|
<div
|
2021-05-04 12:37:53 +02:00
|
|
|
class="spectrum-FieldLabel spectrum-ProgressBar-percentage spectrum-FieldLabel--size{size}"
|
2021-04-27 16:41:43 +02:00
|
|
|
>
|
|
|
|
{Math.round($progress)}%
|
2021-04-15 15:39:14 +02:00
|
|
|
</div>
|
2021-04-27 16:41:43 +02:00
|
|
|
{/if}
|
|
|
|
<div class="spectrum-ProgressBar-track">
|
|
|
|
<div
|
|
|
|
class="spectrum-ProgressBar-fill"
|
|
|
|
style={value ? `width: ${$progress}%` : ""}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="spectrum-ProgressBar-label" hidden="" />
|
2021-04-15 15:39:14 +02:00
|
|
|
</div>
|