Skip to content

Commit

Permalink
(#84) Give up on customizing meter element, just use divs and aria
Browse files Browse the repository at this point in the history
  • Loading branch information
Auroratide committed Nov 18, 2024
1 parent f4c02e7 commit 922291e
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/lib/design/ResourceBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
$: status = percentage >= 50 ? "healthy" : percentage >= 20 ? "warning" : "danger"
</script>

<meter class:secondary class="{status}" max="{max}" value="{current}">
<div class="fill" style:width="{percentage}%"></div>
<VisuallyHidden>{current} / {max}</VisuallyHidden>
</meter>
<div role="meter" aria-valuenow="{current}" aria-valuemin="0" aria-valuemax="{max}" aria-valuetext="{current} / {max}" class:secondary class="meter {status}">
<div class="bar" style:inline-size="{Math.max(100 * current / max, 0)}%"></div>
</div>

<style>
meter {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
.meter {
display: block;
background: none;
background-color: var(--skin-bar-bg);
width: 100%;
height: 0.5em;
inline-size: 100%;
block-size: 0.5em;
overflow: hidden;
}
.bar {
background-color: var(--skin-local-fill);
block-size: 0.5em;
}
.healthy {
--skin-local-fill: var(--skin-bar-healthy);
}
Expand All @@ -39,17 +39,7 @@
--skin-local-fill: var(--skin-bar-danger);
}
meter::-moz-meter-bar, meter::-webkit-meter-bar {
background: none;
background-color: var(--skin-local-fill);
}
.fill {
height: 0.5em;
background-color: var(--skin-local-fill);
}
meter.secondary {
.meter.secondary {
--skin-local-fill: var(--skin-bar-secondary);
}
</style>

0 comments on commit 922291e

Please sign in to comment.