2021-04-16 01:39:14 +12:00
|
|
|
<script>
|
2021-04-28 02:41:43 +12:00
|
|
|
import "@spectrum-css/progressbar/dist/index-vars.css"
|
|
|
|
import { tweened } from "svelte/motion"
|
|
|
|
import { cubicOut } from "svelte/easing"
|
2021-04-16 01:39:14 +12:00
|
|
|
|
2021-04-28 02:41:43 +12:00
|
|
|
export let value = false
|
|
|
|
export let easing = cubicOut
|
|
|
|
export let duration = 1000
|
|
|
|
export let width = false
|
|
|
|
export let sideLabel = false
|
2021-04-16 01:39:14 +12:00
|
|
|
|
2021-04-28 02:41:43 +12:00
|
|
|
export let size = "M"
|
2021-04-16 01:39:14 +12:00
|
|
|
|
2021-04-28 02:41:43 +12:00
|
|
|
const progress = tweened(0, {
|
|
|
|
duration: duration,
|
|
|
|
easing: easing,
|
|
|
|
})
|
2021-04-16 01:39:14 +12:00
|
|
|
|
2022-03-16 21:18:09 +13:00
|
|
|
$: if (value || value === 0) $progress = value
|
2021-04-16 01:39:14 +12:00
|
|
|
</script>
|
|
|
|
|
2021-04-28 02:41:43 +12:00
|
|
|
<div
|
2022-03-16 21:18:09 +13:00
|
|
|
class:spectrum-ProgressBar--indeterminate={!value && value !== 0}
|
2021-04-28 02:41:43 +12:00
|
|
|
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"
|
2022-03-20 14:13:54 +13:00
|
|
|
style={width ? `width: ${width};` : ""}
|
2021-04-28 02:41:43 +12:00
|
|
|
>
|
|
|
|
{#if $$slots}
|
|
|
|
<div
|
2021-05-04 22:37:53 +12:00
|
|
|
class="spectrum-FieldLabel spectrum-ProgressBar-label spectrum-FieldLabel--size{size}"
|
2021-04-28 02:41:43 +12:00
|
|
|
>
|
|
|
|
<slot />
|
|
|
|
</div>
|
|
|
|
{/if}
|
2022-03-16 21:18:09 +13:00
|
|
|
{#if value || value === 0}
|
2021-04-28 02:41:43 +12:00
|
|
|
<div
|
2021-05-04 22:37:53 +12:00
|
|
|
class="spectrum-FieldLabel spectrum-ProgressBar-percentage spectrum-FieldLabel--size{size}"
|
2021-04-28 02:41:43 +12:00
|
|
|
>
|
|
|
|
{Math.round($progress)}%
|
2021-04-16 01:39:14 +12:00
|
|
|
</div>
|
2021-04-28 02:41:43 +12:00
|
|
|
{/if}
|
|
|
|
<div class="spectrum-ProgressBar-track">
|
|
|
|
<div
|
|
|
|
class="spectrum-ProgressBar-fill"
|
2022-03-16 21:18:09 +13:00
|
|
|
style={value || value === 0 ? `width: ${$progress}%` : ""}
|
2021-04-28 02:41:43 +12:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div class="spectrum-ProgressBar-label" hidden="" />
|
2021-04-16 01:39:14 +12:00
|
|
|
</div>
|