2021-12-30 19:28:43 +01:00
|
|
|
<script lang="ts">
|
2022-02-19 16:57:18 +01:00
|
|
|
export let value: number | undefined = undefined;
|
2021-12-30 19:28:43 +01:00
|
|
|
</script>
|
|
|
|
|
2022-02-19 16:57:18 +01:00
|
|
|
<div
|
|
|
|
class="progress-bar"
|
|
|
|
class:indeterminate={value == undefined}
|
|
|
|
style="--value: {value}%"
|
|
|
|
>
|
2021-12-30 19:28:43 +01:00
|
|
|
<div class="value" />
|
|
|
|
<div class="label">
|
|
|
|
<slot>
|
2022-02-19 16:57:18 +01:00
|
|
|
{#if value}
|
|
|
|
{Math.round(value)}%
|
|
|
|
{/if}
|
2021-12-30 19:28:43 +01:00
|
|
|
</slot>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.progress-bar {
|
|
|
|
width: 100%;
|
|
|
|
height: 1em;
|
|
|
|
background: white;
|
|
|
|
position: relative;
|
|
|
|
}
|
|
|
|
|
|
|
|
.value {
|
2021-12-30 23:24:38 +01:00
|
|
|
background: var(--primary);
|
2021-12-30 19:28:43 +01:00
|
|
|
height: 100%;
|
2022-02-19 16:57:18 +01:00
|
|
|
width: var(--value, 100%);
|
2021-12-30 19:28:43 +01:00
|
|
|
transition: width 0.2s ease;
|
|
|
|
}
|
|
|
|
|
|
|
|
.progress-bar,
|
|
|
|
.value {
|
|
|
|
border-radius: 2px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.label {
|
|
|
|
font-size: 0.8em;
|
|
|
|
color: white;
|
|
|
|
z-index: 9;
|
|
|
|
position: absolute;
|
|
|
|
left: 50%;
|
|
|
|
top: 0;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
text-align: center;
|
|
|
|
font-weight: bold;
|
|
|
|
mix-blend-mode: difference;
|
|
|
|
}
|
2022-02-19 16:57:18 +01:00
|
|
|
|
|
|
|
.progress-bar.indeterminate {
|
|
|
|
.value {
|
|
|
|
animation-name: indeterminate;
|
|
|
|
animation-duration: 2s;
|
|
|
|
animation-iteration-count: infinite;
|
|
|
|
animation-timing-function: ease-in-out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes indeterminate {
|
|
|
|
0% {
|
|
|
|
background-color: var(--primary);
|
|
|
|
}
|
|
|
|
50% {
|
|
|
|
background-color: var(--primary-lighter);
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
background-color: var(--primary);
|
|
|
|
}
|
|
|
|
}
|
2021-12-30 19:28:43 +01:00
|
|
|
</style>
|