working ProgressCircle
This commit is contained in:
parent
91518bdef8
commit
72dd292e17
|
@ -1,11 +1,17 @@
|
||||||
<script>
|
<script>
|
||||||
// WIP! Does not yet work.
|
|
||||||
import "@spectrum-css/progresscircle/dist/index-vars.css"
|
import "@spectrum-css/progresscircle/dist/index-vars.css"
|
||||||
import { tweened } from "svelte/motion"
|
|
||||||
import { cubicOut } from "svelte/easing"
|
|
||||||
|
|
||||||
export let small
|
export let size = "M"
|
||||||
export let large
|
function convertSize(size) {
|
||||||
|
switch (size) {
|
||||||
|
case "S":
|
||||||
|
return "small"
|
||||||
|
case "L":
|
||||||
|
return "large"
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export let value = false
|
export let value = false
|
||||||
export let minValue = 0
|
export let minValue = 0
|
||||||
|
@ -13,17 +19,21 @@
|
||||||
|
|
||||||
let subMask1Style
|
let subMask1Style
|
||||||
let subMask2Style
|
let subMask2Style
|
||||||
if (value) {
|
$: calculateSubMasks(value)
|
||||||
let percentage = ((value - minValue) / (maxValue - minValue)) * 100
|
|
||||||
let angle
|
function calculateSubMasks(value) {
|
||||||
if (percentage > 0 && percentage <= 50) {
|
if (value) {
|
||||||
angle = -180 + (percentage / 50) * 180
|
let percentage = ((value - minValue) / (maxValue - minValue)) * 100
|
||||||
subMask1Style = `transform: rotate(${angle}deg);`
|
let angle
|
||||||
subMask2Style = "transform: rotate(-180deg);"
|
if (percentage > 0 && percentage <= 50) {
|
||||||
} else if (percentage > 50) {
|
angle = -180 + (percentage / 50) * 180
|
||||||
angle = -180 + ((percentage - 50) / 50) * 180
|
subMask1Style = `transform: rotate(${angle}deg);`
|
||||||
subMask1Style = "transform: rotate(0deg);"
|
subMask2Style = "transform: rotate(-180deg);"
|
||||||
subMask2Style = `transform: rotate(${angle}deg);`
|
} else if (percentage > 50) {
|
||||||
|
angle = -180 + ((percentage - 50) / 50) * 180
|
||||||
|
subMask1Style = "transform: rotate(0deg);"
|
||||||
|
subMask2Style = `transform: rotate(${angle}deg);`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,11 +41,10 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
on:click
|
||||||
class:spectrum-ProgressBar--indeterminate={!value}
|
class:spectrum-ProgressBar--indeterminate={!value}
|
||||||
class:spectrum-ProgressCircle--small={small}
|
|
||||||
class:spectrum-ProgressCircle--large={large}
|
|
||||||
class:spectrum-ProgressCircle--overBackground={overBackground}
|
class:spectrum-ProgressCircle--overBackground={overBackground}
|
||||||
class="spectrum-ProgressCircle"
|
class="spectrum-ProgressCircle spectrum-ProgressCircle--{convertSize(size)}"
|
||||||
>
|
>
|
||||||
<div class="spectrum-ProgressCircle-track" />
|
<div class="spectrum-ProgressCircle-track" />
|
||||||
<div class="spectrum-ProgressCircle-fills">
|
<div class="spectrum-ProgressCircle-fills">
|
||||||
|
|
Loading…
Reference in New Issue