2021-04-15 18:06:22 +02:00
|
|
|
<script>
|
2021-05-04 12:04:42 +02:00
|
|
|
import "@spectrum-css/progresscircle/dist/index-vars.css"
|
2021-04-15 18:06:22 +02:00
|
|
|
|
2021-05-05 10:02:48 +02:00
|
|
|
export let size = "M"
|
|
|
|
function convertSize(size) {
|
|
|
|
switch (size) {
|
|
|
|
case "S":
|
|
|
|
return "small"
|
|
|
|
case "L":
|
|
|
|
return "large"
|
|
|
|
default:
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
2021-04-15 18:06:22 +02:00
|
|
|
|
2021-09-16 17:53:34 +02:00
|
|
|
export let value = null
|
2021-05-05 09:30:52 +02:00
|
|
|
export let minValue = 0
|
2021-05-05 09:43:01 +02:00
|
|
|
export let maxValue = 100
|
2021-05-05 09:30:52 +02:00
|
|
|
|
|
|
|
let subMask1Style
|
|
|
|
let subMask2Style
|
2021-05-05 10:02:48 +02:00
|
|
|
$: calculateSubMasks(value)
|
|
|
|
|
|
|
|
function calculateSubMasks(value) {
|
|
|
|
if (value) {
|
|
|
|
let percentage = ((value - minValue) / (maxValue - minValue)) * 100
|
|
|
|
let angle
|
|
|
|
if (percentage > 0 && percentage <= 50) {
|
|
|
|
angle = -180 + (percentage / 50) * 180
|
|
|
|
subMask1Style = `transform: rotate(${angle}deg);`
|
|
|
|
subMask2Style = "transform: rotate(-180deg);"
|
|
|
|
} else if (percentage > 50) {
|
|
|
|
angle = -180 + ((percentage - 50) / 50) * 180
|
|
|
|
subMask1Style = "transform: rotate(0deg);"
|
|
|
|
subMask2Style = `transform: rotate(${angle}deg);`
|
|
|
|
}
|
2021-05-05 09:30:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-04 12:04:42 +02:00
|
|
|
export let overBackground
|
2021-04-15 18:06:22 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-04 12:04:42 +02:00
|
|
|
<div
|
2021-05-05 10:02:48 +02:00
|
|
|
on:click
|
2021-09-10 09:25:14 +02:00
|
|
|
class:spectrum-ProgressCircle--indeterminate={value == null}
|
2021-05-05 09:43:01 +02:00
|
|
|
class:spectrum-ProgressCircle--overBackground={overBackground}
|
2021-05-05 10:02:48 +02:00
|
|
|
class="spectrum-ProgressCircle spectrum-ProgressCircle--{convertSize(size)}"
|
2021-05-04 12:04:42 +02:00
|
|
|
>
|
|
|
|
<div class="spectrum-ProgressCircle-track" />
|
|
|
|
<div class="spectrum-ProgressCircle-fills">
|
|
|
|
<div class="spectrum-ProgressCircle-fillMask1">
|
2021-05-05 09:30:52 +02:00
|
|
|
<div class="spectrum-ProgressCircle-fillSubMask1" style={subMask1Style}>
|
2021-05-04 12:04:42 +02:00
|
|
|
<div class="spectrum-ProgressCircle-fill" />
|
2021-04-15 18:06:22 +02:00
|
|
|
</div>
|
2021-05-04 12:04:42 +02:00
|
|
|
</div>
|
|
|
|
<div class="spectrum-ProgressCircle-fillMask2">
|
2021-05-05 09:30:52 +02:00
|
|
|
<div class="spectrum-ProgressCircle-fillSubMask2" style={subMask2Style}>
|
2021-05-04 12:04:42 +02:00
|
|
|
<div class="spectrum-ProgressCircle-fill" />
|
2021-04-15 18:06:22 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-05-04 12:04:42 +02:00
|
|
|
</div>
|