Last active
April 14, 2022 07:58
-
-
Save AvocadoVenom/d1a65038a35b2502326af9145197ce91 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| import CircleProgressBar from './CircleProgressBar.svelte' | |
| const progress = Math.random() | |
| </script> | |
| <CircleProgressBar progress={progress} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| export let progress | |
| const angle = 360 * progress | |
| // Adapt the logic according to the approach | |
| const background = `radial-gradient(white 50%, transparent 51%), | |
| conic-gradient(transparent 0deg ${angle}deg, gainsboro ${angle}deg 360deg), | |
| conic-gradient(orange 0deg, yellow 90deg, lightgreen 180deg, green);`; | |
| $: cssVarStyles = `--background:${background}` | |
| </script> | |
| <style> | |
| #progress-circle { | |
| background: var(--background); | |
| border-radius: 50%; | |
| width: 120px; | |
| height: 120px; | |
| transition: all 500ms ease-in; | |
| will-change: transform; | |
| } | |
| </style> | |
| <div id="progress-circle" style="{cssVarStyles}"></div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment