working ProgressCircle

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-05 10:02:48 +02:00
parent 93c0fb2047
commit 5c13d775b8
1 changed files with 28 additions and 19 deletions

View File

@ -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,6 +19,9 @@
let subMask1Style let subMask1Style
let subMask2Style let subMask2Style
$: calculateSubMasks(value)
function calculateSubMasks(value) {
if (value) { if (value) {
let percentage = ((value - minValue) / (maxValue - minValue)) * 100 let percentage = ((value - minValue) / (maxValue - minValue)) * 100
let angle let angle
@ -26,16 +35,16 @@
subMask2Style = `transform: rotate(${angle}deg);` subMask2Style = `transform: rotate(${angle}deg);`
} }
} }
}
export let overBackground export let overBackground
</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">