chore: add aria-busy and set valuenow to 0 when not active

This commit is contained in:
Enrico Sacchetti 2023-02-19 12:27:42 -05:00
commit b890a8848c
No known key found for this signature in database
GPG key ID: 3374B89ECA60D796

View file

@ -49,7 +49,16 @@
let helperId = "ccs-" + Math.random().toString(36); let helperId = "ccs-" + Math.random().toString(36);
$: indeterminate = value === undefined && status === "active"; $: indeterminate = value === undefined && status === "active";
$: capped = value > max ? max : value < 0 ? 0 : value; let capped;
$: {
if (status === "error" || value < 0) {
capped = 0;
} else if (value > max) {
capped = max;
} else {
capped = value;
}
}
</script> </script>
<div <div
@ -82,6 +91,7 @@
role="progressbar" role="progressbar"
id="{id}" id="{id}"
class:bx--progress-bar__track="{true}" class:bx--progress-bar__track="{true}"
aria-busy="{status === 'active'}"
aria-valuemin="{indeterminate ? undefined : 0}" aria-valuemin="{indeterminate ? undefined : 0}"
aria-valuemax="{indeterminate ? undefined : max}" aria-valuemax="{indeterminate ? undefined : max}"
aria-valuenow="{indeterminate ? undefined : capped}" aria-valuenow="{indeterminate ? undefined : capped}"