@threadlabs/looma 0.14.1 → 0.14.2

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.
@@ -0,0 +1,103 @@
1
+ <template component="ui-meter">
2
+ <defs>
3
+ <prop name="value" type="number" default="0"
4
+ >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
+ <prop name="max" type="number" default="1"
6
+ >The value of a full bar, as on a native meter: 1 for a fraction, or the whole amount (a total, a count of items) with value as the part of it. Must be
7
+ above 0; otherwise the bar is empty.</prop>
8
+ <prop name="tone" type="neutral | accent | info | success | warning | danger" default="neutral"
9
+ >Which colour the filled part speaks in, as on Badge: neutral is a quiet grey, accent draws the eye, and info, success, warning, and danger mark a state
10
+ (such as nothing yet, partial, complete, or needs attention). Colour alone says nothing to assistive technology or in forced colours, so say the state in
11
+ valueText or in text beside the meter too.</prop>
12
+ <prop name="size" type="sm | md" default="md"
13
+ >Thickness. sm is a thin bar that sits in a line of text, such as a table cell beside an amount; md stands on its own.</prop>
14
+ <prop name="label" type="string" default=""
15
+ >What the meter measures, as its accessible name ("Collected"). Leave it empty only when aria-labelledby names the meter from visible text.</prop>
16
+ <prop name="valueText" type="string" default=""
17
+ >The value as assistive technology reads it ("$750 of $1,240 collected", "3 of 5 done, overdue"). Empty reads the percentage.</prop>
18
+ <!-- Derived as it renders, so every render path, a server render included, draws the bar and states its value without JavaScript. -->
19
+ <computed name="amount" from="clamp(0, value, max)"></computed>
20
+ <computed name="percent" from="{ true: amount / max * 100, false: 0 }[format('%s', max > 0)]"></computed>
21
+ <!-- percent rounded half up, for the text: round() on a derived number does not compile to Vue yet. -->
22
+ <computed name="whole" from="percent + 0.5 - (percent + 0.5) % 1"></computed>
23
+ </defs>
24
+ <span
25
+ role="meter"
26
+ aria-valuemin="0"
27
+ :aria-valuemax="max"
28
+ :aria-valuenow="amount"
29
+ :aria-valuetext="{ true: valueText, false: format('%s%', whole) }[format('%s', valueText != '')]"
30
+ :aria-label="{ true: label, false: null }[format('%s', label != '')]"
31
+ >
32
+ <span class="fill" style:inline-size="format('%s%', percent)"></span>
33
+ </span>
34
+ <style>
35
+ /* How far along something is: a track, filled from the start in the tone's colour. The track is a
36
+ quiet border colour, so an empty meter still shows; every tone's fill keeps 3:1 against the
37
+ track and the page. */
38
+ @property --ui-meter-inline-size {
39
+ syntax: "*";
40
+ inherits: false;
41
+ }
42
+
43
+ :host {
44
+ --_meter-fill: var(--ui-text-muted);
45
+
46
+ display: inline-block;
47
+ flex: none;
48
+ vertical-align: middle;
49
+ inline-size: var(--ui-meter-inline-size, 8rem);
50
+ max-inline-size: 100%;
51
+ block-size: var(--ui-space-2);
52
+ overflow: hidden;
53
+ border-radius: var(--ui-radius-round);
54
+ background: var(--ui-border);
55
+ /* Unseen until forced colours draw it, where the track's own colour is gone. */
56
+ outline: 1px solid transparent;
57
+ }
58
+
59
+ :host-state([size="sm"]) {
60
+ inline-size: var(--ui-meter-inline-size, 5rem);
61
+ block-size: var(--ui-space-1);
62
+ }
63
+
64
+ .fill {
65
+ display: block;
66
+ block-size: 100%;
67
+ background: var(--_meter-fill);
68
+ }
69
+
70
+ :host-state([tone="accent"]) {
71
+ --_meter-fill: var(--ui-accent-solid);
72
+ }
73
+
74
+ :host-state([tone="info"]) {
75
+ --_meter-fill: var(--ui-info-solid);
76
+ }
77
+
78
+ :host-state([tone="success"]) {
79
+ --_meter-fill: var(--ui-success-solid);
80
+ }
81
+
82
+ :host-state([tone="warning"]) {
83
+ --_meter-fill: var(--ui-warning-solid);
84
+ }
85
+
86
+ :host-state([tone="danger"]) {
87
+ --_meter-fill: var(--ui-danger-solid);
88
+ }
89
+
90
+ /* Forced colours drop backgrounds: draw the fill in the text colour inside the outlined track. */
91
+ @media (forced-colors: active) {
92
+ .fill {
93
+ forced-color-adjust: none;
94
+ background: CanvasText;
95
+ }
96
+ }
97
+
98
+ /* A component that sets its display still honours the hidden attribute on its root. */
99
+ :host[hidden] {
100
+ display: none;
101
+ }
102
+ </style>
103
+ </template>