@threadlabs/looma 0.26.16 → 0.26.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ui-meter/ui-meter.html +59 -8
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/styles/ui-meter.css +34 -0
- package/vanilla/UiMeter.d.ts +2 -0
- package/vanilla/UiMeter.js +136 -38
- package/vue/UiMeter.d.ts +27 -0
- package/vue/UiMeter.vue +514 -77
- package/vue/chunks/UiMeter.js +271 -57
- package/vue/components.css +49 -24
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
<template component="ui-meter">
|
|
2
2
|
<defs>
|
|
3
|
+
<prop name="variant" type="keyword" values="progress, distribution" default="progress"
|
|
4
|
+
>progress measures one value against max. distribution shows mutually exclusive parts of a whole as a full-width proportional bar; it uses parts rather than
|
|
5
|
+
value/max and is an image, not a progress reading.</prop>
|
|
6
|
+
<prop name="parts" type="list" default="[]">Categories in display order for distribution. Positive finite values determine each share without rounding; zero
|
|
7
|
+
and negative values draw nothing. Supply label and valueText to describe every category, and a visible text legend so colour is never the only
|
|
8
|
+
explanation.
|
|
9
|
+
<prop type="object">
|
|
10
|
+
<prop name="value" required type="number"></prop>
|
|
11
|
+
<prop name="color" required type="string"
|
|
12
|
+
>A CSS category colour, including a theme variable. This names category identity independently of status tones.</prop>
|
|
13
|
+
</prop>
|
|
14
|
+
</prop>
|
|
3
15
|
<prop name="value" type="number" default="0"
|
|
4
16
|
>How far along, from 0 to max. A value outside that range draws at the nearer end: below 0 is an empty track, above max a full bar.</prop>
|
|
5
17
|
<prop name="max" type="number" default="1"
|
|
@@ -25,15 +37,26 @@
|
|
|
25
37
|
<computed name="percent" from="{ true: $amount / $max * 100, false: 0 }[concat($max > 0)]"></computed>
|
|
26
38
|
</defs>
|
|
27
39
|
<span
|
|
28
|
-
role="meter"
|
|
29
|
-
aria-valuemin="0"
|
|
30
|
-
from:aria-valuemax="$max"
|
|
31
|
-
from:aria-valuenow="$amount"
|
|
32
|
-
from:aria-valuetext="{ true: $valueText, false: format($percent / 100, 'percent', { maximumFractionDigits: 0 }) }[concat($valueText != '')]"
|
|
33
|
-
from:aria-label="{ true: $label, false: null }[concat($label != '')]"
|
|
34
|
-
from:data-ui-meter-segments="{ true: $segments, false: null }[concat($segments > 1)]"
|
|
40
|
+
from:role="{ true: 'img', false: 'meter' }[concat($variant = 'distribution')]"
|
|
41
|
+
from:aria-valuemin="{ true: null, false: 0 }[concat($variant = 'distribution')]"
|
|
42
|
+
from:aria-valuemax="{ true: null, false: $max }[concat($variant = 'distribution')]"
|
|
43
|
+
from:aria-valuenow="{ true: null, false: $amount }[concat($variant = 'distribution')]"
|
|
44
|
+
from:aria-valuetext="{ true: null, false: { true: $valueText, false: format($percent / 100, 'percent', { maximumFractionDigits: 0 }) }[concat($valueText != '')] }[concat($variant = 'distribution')]"
|
|
45
|
+
from:aria-label="{ true: { true: concat($label, ': ', $valueText), false: $label }[concat($variant = 'distribution' and $valueText != '')], false: null }[concat($label != '')]"
|
|
46
|
+
from:data-ui-meter-segments="{ true: $segments, false: null }[concat($variant = 'progress' and $segments > 1)]"
|
|
35
47
|
>
|
|
36
|
-
<span class="fill" style:inline-size="concat($percent, '%')"></span>
|
|
48
|
+
<span $if="$variant = 'progress'" class="fill" style:inline-size="concat($percent, '%')"></span>
|
|
49
|
+
<template $if="$variant = 'distribution'">
|
|
50
|
+
<template $each="part of $parts">
|
|
51
|
+
<span
|
|
52
|
+
$if="$part.value > 0 and $part.value - $part.value = 0"
|
|
53
|
+
class="part"
|
|
54
|
+
aria-hidden="true"
|
|
55
|
+
style:flex-grow="$part.value"
|
|
56
|
+
style:background-color="$part.color"
|
|
57
|
+
></span>
|
|
58
|
+
</template>
|
|
59
|
+
</template>
|
|
37
60
|
</span>
|
|
38
61
|
<style>
|
|
39
62
|
/* How far along something is: a track, filled from the start in the tone's colour. The track is a
|
|
@@ -158,6 +181,34 @@
|
|
|
158
181
|
--_meter-gap: var(--ui-space-0-5);
|
|
159
182
|
}
|
|
160
183
|
|
|
184
|
+
/* A categorical distribution uses flex ratios, avoiding rounded percentages and retaining
|
|
185
|
+
identical geometry before hydration. It has no progress mask or growing-value animation. */
|
|
186
|
+
:host([variant="distribution"]) {
|
|
187
|
+
display: flex;
|
|
188
|
+
inline-size: 100%;
|
|
189
|
+
block-size: var(--ui-space-4);
|
|
190
|
+
gap: var(--ui-space-0-5);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
:host([variant="distribution"])[size="sm"] {
|
|
194
|
+
block-size: var(--ui-space-2);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.part {
|
|
198
|
+
flex-basis: 0;
|
|
199
|
+
min-inline-size: 0;
|
|
200
|
+
block-size: 100%;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@media (forced-colors: active) {
|
|
204
|
+
.part {
|
|
205
|
+
forced-color-adjust: none;
|
|
206
|
+
background: CanvasText !important;
|
|
207
|
+
outline: var(--ui-border-width) solid Canvas;
|
|
208
|
+
outline-offset: calc(-1 * var(--ui-border-width));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
161
212
|
/* Forced colours drop backgrounds: draw the fill in the text colour inside the outlined track. */
|
|
162
213
|
@media (forced-colors: active) {
|
|
163
214
|
.fill {
|