Files
fnx_web/svelte/src/util/ProgressBar.svelte

47 lines
841 B
Svelte
Raw Normal View History

2021-11-23 14:22:42 +01:00
<script>
export let total = 0
export let used = 0
2022-05-13 17:43:10 +02:00
export let animation = "ease"
export let speed = 1000
2021-11-23 14:22:42 +01:00
let percent = 0
$: {
// Avoid division by 0
if (total === 0) {
total = 1
}
// Don't allow more than 100% progress
if (used / total > 1) {
percent = 100
} else {
percent = (used / total) * 100
}
}
</script>
<div class="progress_bar_outer">
2022-12-24 11:37:02 +01:00
<div
class="progress_bar_inner"
style="width: {percent}%; transition-timing-function: {animation}; transition-duration: {speed}ms;">
</div>
2021-11-23 14:22:42 +01:00
</div>
<style>
.progress_bar_outer {
display: block;
2022-03-29 21:41:46 +02:00
background: var(--background_color);
2021-11-23 14:22:42 +01:00
width: 100%;
2022-05-13 17:43:10 +02:00
height: 6px;
border-radius: 6px;
overflow: hidden;
2021-11-23 14:22:42 +01:00
margin: 6px 0 12px 0;
}
.progress_bar_inner {
2022-03-29 21:41:46 +02:00
background: var(--highlight_background);
2021-11-23 14:22:42 +01:00
height: 100%;
width: 0;
2022-05-13 17:43:10 +02:00
border-radius: 6px;
transition-property: width;
2021-11-23 14:22:42 +01:00
}
</style>