File size: 3,379 Bytes
11fcc5a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
<script lang="ts">
import { t } from "$lib/i18n/translations";
import IconArrowDown from "@tabler/icons-svelte/IconArrowDown.svelte";
type Props = {
indeterminate?: boolean;
progress?: number;
expandAction: () => void;
}
let {
indeterminate = false,
progress = $bindable(0),
expandAction
}: Props = $props();
let progressStroke = $derived(`${progress}, 100`);
const indeterminateStroke = "15, 5";
let ariaState = $derived(
progress > 0 && progress < 100
? "ongoing"
: progress >= 100
? "completed"
: "default"
)
</script>
<button
id="processing-status"
onclick={expandAction}
class="button"
class:completed={progress >= 100}
aria-label={$t(`a11y.queue.status.${ariaState}`)}
>
<svg
id="progress-ring"
class:indeterminate
class:progressive={progress > 0 && !indeterminate}
>
<circle
cx="19"
cy="19"
r="16"
fill="none"
stroke-dasharray={indeterminate
? indeterminateStroke
: progressStroke}
/>
</svg>
<div class="icon-holder">
<IconArrowDown />
</div>
</button>
<style>
#processing-status {
pointer-events: all;
padding: 7px;
border-radius: 30px;
filter: drop-shadow(0 0 3px var(--button-elevated-hover));
transition:
background-color 0.2s,
transform 0.2s;
will-change: transform, background-color;
}
#processing-status:focus-visible {
outline: 2px solid var(--secondary);
outline-offset: 2px;
}
#processing-status:active {
transform: scale(0.9);
}
#processing-status.completed {
box-shadow: 0 0 0 2px var(--blue) inset;
}
:global([data-theme="light"]) #processing-status.completed {
background-color: #e0eeff;
}
:global([data-theme="dark"]) #processing-status.completed {
background-color: #1f3249;
}
.icon-holder {
display: flex;
background-color: var(--button-elevated-hover);
padding: 2px;
border-radius: 20px;
transition: background-color 0.2s;
}
.icon-holder :global(svg) {
height: 21px;
width: 21px;
stroke: var(--secondary);
stroke-width: 1.5px;
transition: stroke 0.2s;
}
.completed .icon-holder {
background-color: var(--blue);
}
.completed .icon-holder :global(svg) {
stroke: white;
}
#progress-ring {
position: absolute;
transform: rotate(-90deg);
width: 38px;
height: 38px;
opacity: 0;
transition: opacity 0.2s;
}
#progress-ring circle {
stroke: var(--blue);
stroke-width: 4;
stroke-dashoffset: 0;
}
#progress-ring.progressive circle {
transition: stroke-dasharray 0.2s;
}
#progress-ring.progressive,
#progress-ring.indeterminate {
opacity: 1;
}
#progress-ring.indeterminate {
animation: spinner 3s linear infinite;
will-change: transform;
}
#progress-ring.indeterminate circle {
transition: none;
}
.completed #progress-ring {
opacity: 0;
}
</style>
|