@threadlabs/looma 0.26.15 → 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.
@@ -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 {
@@ -1,5 +1,8 @@
1
1
  <template component="ui-text">
2
2
  <defs>
3
+ <prop name="trim" type="boolean" default="false"
4
+ >Removes extra font space above the capital height and below the baseline, for compact headings and labels. Prose keeps its existing line-edge space by
5
+ default. Browsers without text-box-trim retain normal font metrics.</prop>
3
6
  <prop name="grow" type="boolean" default="false">Lets this text use remaining inline space in a flex row, including when truncated.</prop>
4
7
  <prop name="font" type="keyword" values="inherit, sans" default="inherit"
5
8
  >Use sans for UI text rendered outside its original font context; inherit preserves the surrounding typeface.</prop>
@@ -75,6 +78,12 @@
75
78
  line-height: var(--ui-line-height-relaxed);
76
79
  }
77
80
 
81
+ /* Opt in at the text owner; trimming does not inherit from a surrounding layout. */
82
+ :host([trim]) {
83
+ text-box-trim: trim-both;
84
+ text-box-edge: cap alphabetic;
85
+ }
86
+
78
87
  :host([tone="secondary"]) {
79
88
  color: var(--ui-text-secondary);
80
89
  }
@@ -134,6 +143,12 @@
134
143
  white-space: nowrap;
135
144
  }
136
145
 
146
+ /* Trim ends the layout box at the baseline; preserve descending ink while clipping long labels. */
147
+ :host([trim][truncate]) {
148
+ overflow-x: clip;
149
+ overflow-y: visible;
150
+ }
151
+
137
152
  :host([align="center"]) {
138
153
  text-align: center;
139
154
  }