@threadlabs/looma 0.14.2 → 0.14.4
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 +83 -0
- package/components/ui-text/ui-text.html +11 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/styles/ui-meter.css +90 -0
- package/styles/ui-text.css +10 -0
- package/vanilla/UiMeter.d.ts +1 -0
- package/vanilla/UiMeter.js +1 -1
- package/vanilla/UiText.d.ts +1 -1
- package/vanilla/UiText.js +1 -1
- package/vue/UiMeter.d.ts +2 -0
- package/vue/UiMeter.vue +85 -0
- package/vue/UiText.d.ts +2 -2
- package/vue/UiText.vue +9 -1
- package/vue/chunks/UiMeter.js +7 -1
- package/vue/chunks/UiText.js +1 -1
- package/vue/components.css +107 -29
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
valueText or in text beside the meter too.</prop>
|
|
12
12
|
<prop name="size" type="sm | md" default="md"
|
|
13
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="segments" type="number" default="0"
|
|
15
|
+
>How many equal segments to draw the bar as, from 2 to 12, for a count of steps: set max to the same number and value to the steps done, so whole segments
|
|
16
|
+
fill, and say the step in valueText ("Shipped, step 4 of 6"). A value between steps fills part of a segment. 0 draws one continuous bar, as does any other
|
|
17
|
+
number.</prop>
|
|
14
18
|
<prop name="label" type="string" default=""
|
|
15
19
|
>What the meter measures, as its accessible name ("Collected"). Leave it empty only when aria-labelledby names the meter from visible text.</prop>
|
|
16
20
|
<prop name="valueText" type="string" default=""
|
|
@@ -28,6 +32,7 @@
|
|
|
28
32
|
:aria-valuenow="amount"
|
|
29
33
|
:aria-valuetext="{ true: valueText, false: format('%s%', whole) }[format('%s', valueText != '')]"
|
|
30
34
|
:aria-label="{ true: label, false: null }[format('%s', label != '')]"
|
|
35
|
+
:data-ui-meter-segments="{ true: segments, false: null }[format('%s', segments > 1)]"
|
|
31
36
|
>
|
|
32
37
|
<span class="fill" style:inline-size="format('%s%', percent)"></span>
|
|
33
38
|
</span>
|
|
@@ -87,12 +92,90 @@
|
|
|
87
92
|
--_meter-fill: var(--ui-danger-solid);
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
/* Segments: the track and its fill show through a mask of equal segments with a gap between them.
|
|
96
|
+
A mask over the whole meter, rather than one element per segment, because the expression
|
|
97
|
+
language has no range to render N elements from, and one mask lines the fill up with the track
|
|
98
|
+
for free. Each period is a segment and the gap after it; N periods span the track plus one
|
|
99
|
+
trailing gap, so the segments sit symmetrically and right to left needs nothing of its own.
|
|
100
|
+
The count arrives as an attribute, not an inline custom property (which would add a style
|
|
101
|
+
attribute to every meter), so a continuous meter renders exactly as before, and the rules below
|
|
102
|
+
turn it into a number. That caps it at 12, until attr() with a type reads any count in every engine. */
|
|
103
|
+
:host[data-ui-meter-segments="2"] {
|
|
104
|
+
--_segments: 2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host[data-ui-meter-segments="3"] {
|
|
108
|
+
--_segments: 3;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
:host[data-ui-meter-segments="4"] {
|
|
112
|
+
--_segments: 4;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
:host[data-ui-meter-segments="5"] {
|
|
116
|
+
--_segments: 5;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
:host[data-ui-meter-segments="6"] {
|
|
120
|
+
--_segments: 6;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:host[data-ui-meter-segments="7"] {
|
|
124
|
+
--_segments: 7;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host[data-ui-meter-segments="8"] {
|
|
128
|
+
--_segments: 8;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
:host[data-ui-meter-segments="9"] {
|
|
132
|
+
--_segments: 9;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
:host[data-ui-meter-segments="10"] {
|
|
136
|
+
--_segments: 10;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host[data-ui-meter-segments="11"] {
|
|
140
|
+
--_segments: 11;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
:host[data-ui-meter-segments="12"] {
|
|
144
|
+
--_segments: 12;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
:host[data-ui-meter-segments] {
|
|
148
|
+
--_meter-gap: var(--ui-space-1);
|
|
149
|
+
--_meter-period: calc((100% + var(--_meter-gap)) / var(--_segments));
|
|
150
|
+
--_meter-segment: calc(var(--_meter-period) - var(--_meter-gap));
|
|
151
|
+
|
|
152
|
+
mask-image: repeating-linear-gradient(to right, #000 0 var(--_meter-segment), transparent 0 var(--_meter-period));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host-state([size="sm"])[data-ui-meter-segments] {
|
|
156
|
+
--_meter-gap: var(--ui-space-0-5);
|
|
157
|
+
}
|
|
158
|
+
|
|
90
159
|
/* Forced colours drop backgrounds: draw the fill in the text colour inside the outlined track. */
|
|
91
160
|
@media (forced-colors: active) {
|
|
92
161
|
.fill {
|
|
93
162
|
forced-color-adjust: none;
|
|
94
163
|
background: CanvasText;
|
|
95
164
|
}
|
|
165
|
+
|
|
166
|
+
/* The mask clips the track's outline, so each segment draws its own: the inset shadow draws the
|
|
167
|
+
top and bottom edges and the gradient the ends. */
|
|
168
|
+
:host[data-ui-meter-segments] {
|
|
169
|
+
forced-color-adjust: none;
|
|
170
|
+
background: repeating-linear-gradient(
|
|
171
|
+
to right,
|
|
172
|
+
CanvasText 0 1px,
|
|
173
|
+
Canvas 0 calc(var(--_meter-segment) - 1px),
|
|
174
|
+
CanvasText 0 var(--_meter-segment),
|
|
175
|
+
transparent 0 var(--_meter-period)
|
|
176
|
+
);
|
|
177
|
+
box-shadow: inset 0 0 0 1px CanvasText;
|
|
178
|
+
}
|
|
96
179
|
}
|
|
97
180
|
|
|
98
181
|
/* A component that sets its display still honours the hidden attribute on its root. */
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
<prop name="size" type="inherit | xs | sm | md | lg" default="inherit"
|
|
4
4
|
>The step on the type scale. inherit (the default) keeps the size of the text around it; xs is for fine print, sm for supporting text such as help and
|
|
5
5
|
metadata, md is body text, and lg is a lead paragraph.</prop>
|
|
6
|
-
<prop name="tone" type="default | secondary | muted | accent | danger | success" default="default"
|
|
6
|
+
<prop name="tone" type="default | secondary | muted | accent | danger | success | info | warning" default="default"
|
|
7
7
|
>The text's colour, by meaning. secondary is supporting prose such as a description; muted is quieter still, for metadata and hints; accent draws the eye;
|
|
8
|
-
danger states an error; success confirms one
|
|
8
|
+
danger states an error; success confirms one; info marks something moving forward normally; warning marks something that needs attention. Colour alone
|
|
9
|
+
does not carry the meaning, so the words must say it too.</prop>
|
|
9
10
|
<prop name="weight" type="inherit | normal | medium | semibold" default="inherit"
|
|
10
11
|
>The weight. inherit keeps the surrounding weight; medium and semibold emphasise a name or a figure.</prop>
|
|
11
12
|
<prop name="variant" type="body | eyebrow | code" default="body"
|
|
@@ -67,6 +68,14 @@
|
|
|
67
68
|
:host-state([tone="success"]) {
|
|
68
69
|
color: var(--ui-success);
|
|
69
70
|
}
|
|
71
|
+
/* The base info and warning colours fall short of 4.5:1 on sunken surfaces, so these use the
|
|
72
|
+
text-safe tokens a subtle badge sets its words in. */
|
|
73
|
+
:host-state([tone="info"]) {
|
|
74
|
+
color: var(--ui-info-subtle-text);
|
|
75
|
+
}
|
|
76
|
+
:host-state([tone="warning"]) {
|
|
77
|
+
color: var(--ui-warning-subtle-text);
|
|
78
|
+
}
|
|
70
79
|
|
|
71
80
|
:host-state([weight="normal"]) {
|
|
72
81
|
font-weight: var(--ui-font-normal);
|