@grafctory/clay-widgets 0.0.0-stage → 0.5.0

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.
Files changed (189) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -2
  3. package/dist/content/empty.css +107 -0
  4. package/dist/content/empty.d.ts +40 -0
  5. package/dist/content/empty.d.ts.map +1 -0
  6. package/dist/content/empty.js +42 -0
  7. package/dist/content/empty.js.map +1 -0
  8. package/dist/content/heading.css +34 -0
  9. package/dist/content/heading.d.ts +45 -0
  10. package/dist/content/heading.d.ts.map +1 -0
  11. package/dist/content/heading.js +49 -0
  12. package/dist/content/heading.js.map +1 -0
  13. package/dist/content/image.css +198 -0
  14. package/dist/content/image.d.ts +77 -0
  15. package/dist/content/image.d.ts.map +1 -0
  16. package/dist/content/image.js +67 -0
  17. package/dist/content/image.js.map +1 -0
  18. package/dist/content/infobox.css +186 -0
  19. package/dist/content/infobox.d.ts +72 -0
  20. package/dist/content/infobox.d.ts.map +1 -0
  21. package/dist/content/infobox.js +63 -0
  22. package/dist/content/infobox.js.map +1 -0
  23. package/dist/content/pill.css +76 -0
  24. package/dist/content/pill.d.ts +57 -0
  25. package/dist/content/pill.d.ts.map +1 -0
  26. package/dist/content/pill.js +48 -0
  27. package/dist/content/pill.js.map +1 -0
  28. package/dist/content/text.css +44 -0
  29. package/dist/content/text.d.ts +30 -0
  30. package/dist/content/text.d.ts.map +1 -0
  31. package/dist/content/text.js +42 -0
  32. package/dist/content/text.js.map +1 -0
  33. package/dist/controls/button.css +469 -0
  34. package/dist/controls/button.d.ts +116 -0
  35. package/dist/controls/button.d.ts.map +1 -0
  36. package/dist/controls/button.js +61 -0
  37. package/dist/controls/button.js.map +1 -0
  38. package/dist/controls/checkbox.css +23 -0
  39. package/dist/controls/checkbox.d.ts +54 -0
  40. package/dist/controls/checkbox.d.ts.map +1 -0
  41. package/dist/controls/checkbox.js +49 -0
  42. package/dist/controls/checkbox.js.map +1 -0
  43. package/dist/controls/choice.css +288 -0
  44. package/dist/controls/choice.d.ts +63 -0
  45. package/dist/controls/choice.d.ts.map +1 -0
  46. package/dist/controls/choice.js +52 -0
  47. package/dist/controls/choice.js.map +1 -0
  48. package/dist/controls/fieldset.css +37 -0
  49. package/dist/controls/fieldset.d.ts +49 -0
  50. package/dist/controls/fieldset.d.ts.map +1 -0
  51. package/dist/controls/fieldset.js +51 -0
  52. package/dist/controls/fieldset.js.map +1 -0
  53. package/dist/controls/form.css +50 -0
  54. package/dist/controls/form.d.ts +64 -0
  55. package/dist/controls/form.d.ts.map +1 -0
  56. package/dist/controls/form.js +62 -0
  57. package/dist/controls/form.js.map +1 -0
  58. package/dist/controls/input.css +57 -0
  59. package/dist/controls/input.d.ts +129 -0
  60. package/dist/controls/input.d.ts.map +1 -0
  61. package/dist/controls/input.js +71 -0
  62. package/dist/controls/input.js.map +1 -0
  63. package/dist/controls/label.css +73 -0
  64. package/dist/controls/label.d.ts +76 -0
  65. package/dist/controls/label.d.ts.map +1 -0
  66. package/dist/controls/label.js +73 -0
  67. package/dist/controls/label.js.map +1 -0
  68. package/dist/controls/radio.css +23 -0
  69. package/dist/controls/radio.d.ts +60 -0
  70. package/dist/controls/radio.d.ts.map +1 -0
  71. package/dist/controls/radio.js +50 -0
  72. package/dist/controls/radio.js.map +1 -0
  73. package/dist/controls/select.css +37 -0
  74. package/dist/controls/select.d.ts +71 -0
  75. package/dist/controls/select.d.ts.map +1 -0
  76. package/dist/controls/select.js +59 -0
  77. package/dist/controls/select.js.map +1 -0
  78. package/dist/controls/switch.css +154 -0
  79. package/dist/controls/switch.d.ts +44 -0
  80. package/dist/controls/switch.d.ts.map +1 -0
  81. package/dist/controls/switch.js +48 -0
  82. package/dist/controls/switch.js.map +1 -0
  83. package/dist/controls/textarea.css +50 -0
  84. package/dist/controls/textarea.d.ts +106 -0
  85. package/dist/controls/textarea.d.ts.map +1 -0
  86. package/dist/controls/textarea.js +68 -0
  87. package/dist/controls/textarea.js.map +1 -0
  88. package/dist/glyphs/icon.core.d.ts +52 -0
  89. package/dist/glyphs/icon.core.d.ts.map +1 -0
  90. package/dist/glyphs/icon.core.js +67 -0
  91. package/dist/glyphs/icon.core.js.map +1 -0
  92. package/dist/glyphs/icon.css +32 -0
  93. package/dist/glyphs/icon.d.ts +152 -0
  94. package/dist/glyphs/icon.d.ts.map +1 -0
  95. package/dist/glyphs/icon.js +167 -0
  96. package/dist/glyphs/icon.js.map +1 -0
  97. package/dist/glyphs/icon.md +76 -0
  98. package/dist/glyphs/logo.css +73 -0
  99. package/dist/glyphs/logo.d.ts +27 -0
  100. package/dist/glyphs/logo.d.ts.map +1 -0
  101. package/dist/glyphs/logo.js +49 -0
  102. package/dist/glyphs/logo.js.map +1 -0
  103. package/dist/index.core.d.ts +18 -0
  104. package/dist/index.core.d.ts.map +1 -0
  105. package/dist/index.core.js +36 -0
  106. package/dist/index.core.js.map +1 -0
  107. package/dist/index.d.ts +65 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +95 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/layouts/card.css +190 -0
  112. package/dist/layouts/card.d.ts +75 -0
  113. package/dist/layouts/card.d.ts.map +1 -0
  114. package/dist/layouts/card.js +62 -0
  115. package/dist/layouts/card.js.map +1 -0
  116. package/dist/layouts/stack.css +58 -0
  117. package/dist/layouts/stack.d.ts +64 -0
  118. package/dist/layouts/stack.d.ts.map +1 -0
  119. package/dist/layouts/stack.js +69 -0
  120. package/dist/layouts/stack.js.map +1 -0
  121. package/dist/layouts/strip.css +58 -0
  122. package/dist/layouts/strip.d.ts +72 -0
  123. package/dist/layouts/strip.d.ts.map +1 -0
  124. package/dist/layouts/strip.js +73 -0
  125. package/dist/layouts/strip.js.map +1 -0
  126. package/dist/layouts/tabs.core.d.ts +73 -0
  127. package/dist/layouts/tabs.core.d.ts.map +1 -0
  128. package/dist/layouts/tabs.core.js +65 -0
  129. package/dist/layouts/tabs.core.js.map +1 -0
  130. package/dist/layouts/tabs.css +260 -0
  131. package/dist/layouts/tabs.d.ts +57 -0
  132. package/dist/layouts/tabs.d.ts.map +1 -0
  133. package/dist/layouts/tabs.js +128 -0
  134. package/dist/layouts/tabs.js.map +1 -0
  135. package/dist/layouts/tree.css +138 -0
  136. package/dist/layouts/tree.d.ts +46 -0
  137. package/dist/layouts/tree.d.ts.map +1 -0
  138. package/dist/layouts/tree.js +69 -0
  139. package/dist/layouts/tree.js.map +1 -0
  140. package/dist/navigation/link.css +229 -0
  141. package/dist/navigation/link.d.ts +89 -0
  142. package/dist/navigation/link.d.ts.map +1 -0
  143. package/dist/navigation/link.js +91 -0
  144. package/dist/navigation/link.js.map +1 -0
  145. package/dist/navigation/path.css +122 -0
  146. package/dist/navigation/path.d.ts +42 -0
  147. package/dist/navigation/path.d.ts.map +1 -0
  148. package/dist/navigation/path.js +49 -0
  149. package/dist/navigation/path.js.map +1 -0
  150. package/dist/navigation/toc.core.d.ts +111 -0
  151. package/dist/navigation/toc.core.d.ts.map +1 -0
  152. package/dist/navigation/toc.core.js +60 -0
  153. package/dist/navigation/toc.core.js.map +1 -0
  154. package/dist/navigation/toc.css +53 -0
  155. package/dist/navigation/toc.d.ts +112 -0
  156. package/dist/navigation/toc.d.ts.map +1 -0
  157. package/dist/navigation/toc.js +321 -0
  158. package/dist/navigation/toc.js.map +1 -0
  159. package/dist/scopes/guard.css +26 -0
  160. package/dist/scopes/guard.d.ts +37 -0
  161. package/dist/scopes/guard.d.ts.map +1 -0
  162. package/dist/scopes/guard.js +60 -0
  163. package/dist/scopes/guard.js.map +1 -0
  164. package/dist/scopes/style.css +26 -0
  165. package/dist/scopes/style.d.ts +68 -0
  166. package/dist/scopes/style.d.ts.map +1 -0
  167. package/dist/scopes/style.js +108 -0
  168. package/dist/scopes/style.js.map +1 -0
  169. package/dist/shells/tool.css +770 -0
  170. package/dist/shells/tool.d.ts +167 -0
  171. package/dist/shells/tool.d.ts.map +1 -0
  172. package/dist/shells/tool.js +286 -0
  173. package/dist/shells/tool.js.map +1 -0
  174. package/dist/signals/more.css +42 -0
  175. package/dist/signals/more.d.ts +28 -0
  176. package/dist/signals/more.d.ts.map +1 -0
  177. package/dist/signals/more.js +61 -0
  178. package/dist/signals/more.js.map +1 -0
  179. package/dist/signals/note.css +221 -0
  180. package/dist/signals/note.d.ts +83 -0
  181. package/dist/signals/note.d.ts.map +1 -0
  182. package/dist/signals/note.js +72 -0
  183. package/dist/signals/note.js.map +1 -0
  184. package/dist/signals/toasts.css +463 -0
  185. package/dist/signals/toasts.d.ts +68 -0
  186. package/dist/signals/toasts.d.ts.map +1 -0
  187. package/dist/signals/toasts.js +160 -0
  188. package/dist/signals/toasts.js.map +1 -0
  189. package/package.json +331 -4
@@ -0,0 +1,463 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ /*
18
+ * The stack floats over the screen, raised as an overlay, hanging from the edge it is placed on with its toasts piled
19
+ * away from it, newest nearest the edge. The whole tray takes the pointer, so a click between its toasts never lands
20
+ * on the screen beneath. A status colours the mark and the start edge alone, so every message reads alike.
21
+ */
22
+
23
+
24
+ /**** Registrations ***************************************************************************************************/
25
+
26
+ /*
27
+ * The width every toast takes past a narrow screen, so the stack reads as one column with its edges lined up, a
28
+ * message too long for it wrapping onto more lines rather than widening its toast. It is a measure of the text the
29
+ * toasts carry, so it grows with the type, and is held to the room the screen leaves.
30
+ */
31
+
32
+ @property --clay-toasts-width {
33
+ syntax: "*";
34
+ inherits: true;
35
+ initial-value: 24em;
36
+ }
37
+
38
+
39
+ /**** Stack ***********************************************************************************************************/
40
+
41
+ clay-toasts {
42
+
43
+ /*
44
+ * The stack is a single tray of glass gathering its toasts, as wide as its toasts and kept within the screen by the
45
+ * same margin at the sides as at its edge; on a narrow screen it spans the whole width. The glass is darker than
46
+ * the page and lets it show through, so the tray reads as one group floating over it in either scheme, and the
47
+ * toasts set on it stand out against the glass without needing a shadow of their own.
48
+ */
49
+
50
+ position: fixed;
51
+ inset-inline: var(--skin--spacing-100);
52
+ z-index: var(--skin--z-index-toast);
53
+
54
+ display: flex;
55
+ align-items: stretch;
56
+
57
+ padding: var(--skin--spacing-100);
58
+
59
+ background-color: var(--skin--background-color-glass);
60
+ backdrop-filter: var(--skin--backdrop-filter-glass);
61
+
62
+ border-radius: var(--skin--border-radius-100);
63
+
64
+ /*
65
+ * A tray with nothing on it is not drawn, its padding and its glass going with the last toast. The element stays
66
+ * in the page all the same, as the live region the toasts are read out from.
67
+ */
68
+
69
+ &:not(:has(> div:not([hidden]))) {
70
+ padding: 0;
71
+ background-color: transparent;
72
+ backdrop-filter: none;
73
+ }
74
+
75
+ /*
76
+ * The edge decides which way the stack grows, where the gap between toasts falls and where a toast slides in
77
+ * from. The order the toasts come in stays newest first, so a reader moving through them meets the newest first
78
+ * wherever it is drawn.
79
+ */
80
+
81
+ &[edge="top"] {
82
+
83
+ top: var(--skin--spacing-100);
84
+ flex-direction: column;
85
+
86
+ /* The gap after the last toast is part of its slot, so the tray closes on what is left of its padding. */
87
+
88
+ padding-block-end: calc(var(--skin--spacing-100) - var(--skin--spacing-050));
89
+
90
+ --clay-toasts-before: 0;
91
+ --clay-toasts-after: var(--skin--spacing-050);
92
+ --clay-toasts-shift: calc(-1 * var(--skin--spacing-050));
93
+
94
+ }
95
+
96
+ &[edge="bottom"] {
97
+
98
+ bottom: var(--skin--spacing-100);
99
+ flex-direction: column-reverse;
100
+
101
+ /* The gap before the topmost toast is part of its slot, so the tray opens on what is left of its padding. */
102
+
103
+ padding-block-start: calc(var(--skin--spacing-100) - var(--skin--spacing-050));
104
+
105
+ --clay-toasts-before: var(--skin--spacing-050);
106
+ --clay-toasts-after: 0;
107
+ --clay-toasts-shift: var(--skin--spacing-050);
108
+
109
+ }
110
+
111
+ /*
112
+ * Past the phone held upright, every toast takes the same width, held to the room the screen leaves, and the tray
113
+ * shrinks to them, keeping to the side it is placed on by taking up the room on the other side, the start and the
114
+ * end following the writing direction.
115
+ */
116
+
117
+ @container style(--skin--viewport-small: on) {
118
+
119
+ width: fit-content;
120
+
121
+ & > div {
122
+ width: var(--clay-toasts-width);
123
+ max-width: 100%;
124
+ }
125
+
126
+ &[side="start"] {
127
+ margin-inline-end: auto;
128
+ }
129
+
130
+ &[side="center"] {
131
+ margin-inline: auto;
132
+ }
133
+
134
+ &[side="end"] {
135
+ margin-inline-start: auto;
136
+ }
137
+
138
+ }
139
+
140
+ /*
141
+ * Each toast sits in a slot as tall as the toast and the gap away from the edge, which opens as the toast slides in
142
+ * and closes as it fades out, so the toasts beyond move along with it rather than jumping once it has gone.
143
+ */
144
+
145
+ & > div {
146
+
147
+ display: grid;
148
+ grid-template-rows: 1fr;
149
+
150
+ margin-block: var(--clay-toasts-before) var(--clay-toasts-after);
151
+
152
+ /*
153
+ * The reset hands every element the background of the one around it, which would lay the glass again under
154
+ * each toast, deepening it to an opaque rectangle behind every rounded card.
155
+ */
156
+
157
+ background-color: transparent;
158
+
159
+ /*
160
+ * The slot cuts off whatever part of the toast it no longer has room for, the toast keeping its full height
161
+ * inside it, so a closing slot wipes the toast away rather than squeezing it.
162
+ */
163
+
164
+ overflow: clip;
165
+
166
+ /*
167
+ * The slot stays in the flow until the fade is over. The duration is held to a millisecond at least, so the
168
+ * fade still ends, and the stack lets the toast go, where the reader asked for less motion and the durations
169
+ * collapse to zero: a transition taking no time at all never ends.
170
+ */
171
+
172
+ transition-property: grid-template-rows, margin-block, opacity, translate, display;
173
+ transition-duration: max(var(--skin--duration-normal), 1ms);
174
+ transition-timing-function: var(--skin--easing-enter);
175
+ transition-behavior: allow-discrete;
176
+
177
+ @starting-style {
178
+ grid-template-rows: 0fr;
179
+ margin-block: 0;
180
+ opacity: 0;
181
+ translate: 0 var(--clay-toasts-shift);
182
+ }
183
+
184
+ /* The display above is unlayered and outranks the reset hiding a hidden element, so the rule is restated here. */
185
+
186
+ &[hidden] {
187
+ display: none;
188
+ grid-template-rows: 0fr;
189
+ margin-block: 0;
190
+ opacity: 0;
191
+ transition-timing-function: var(--skin--easing-exit);
192
+ }
193
+
194
+ /*
195
+ * The bare wrapper the slot sizes on asks for no room of its own, so the slot can close all the way, while the
196
+ * toast inside keeps the height of what it carries.
197
+ */
198
+
199
+ & > div {
200
+
201
+ min-height: 0;
202
+ background-color: transparent;
203
+
204
+ /*
205
+ * The mark and the dismiss control keep to the first line of the message, where reading starts, rather
206
+ * than to the middle of a message running over several lines, so they stay together and in the same place
207
+ * from one toast to the next whatever the length of what each says.
208
+ */
209
+
210
+ & > div {
211
+
212
+ display: flex;
213
+ align-items: start;
214
+ column-gap: var(--skin--spacing-050);
215
+
216
+ padding: var(--skin--spacing-050) var(--skin--spacing-100);
217
+
218
+ /* The dismiss control closing the toast carries room of its own, so the edge beside it is padded tighter. */
219
+
220
+ padding-inline-end: var(--skin--spacing-050);
221
+
222
+ /*
223
+ * Each toast is a card of its own on the glass, lighter than the page where the glass is darker,
224
+ * rounded well short of the tray so the cards read as nested within it, with the glass showing in the
225
+ * gap between. The surface and the neutral border are the same whatever the status, so the cards read
226
+ * as one stack rather than a patchwork of tints; the status is told by the mark and by a strip along
227
+ * the start edge, both in the ink of its step. Every card draws the strip, a plain one in the colour of
228
+ * its border, so the marks and the messages line up from one toast to the next whatever each tells.
229
+ */
230
+
231
+ --clay-toasts-ink: var(--skin--border-color);
232
+
233
+ background-color: var(--skin--background-color-overlay);
234
+ border: var(--skin--border-width) var(--skin--border-style) var(--skin--border-color);
235
+ border-inline-start-width: calc(3 * var(--skin--border-width));
236
+ border-inline-start-color: var(--clay-toasts-ink);
237
+ border-radius: var(--skin--border-radius-050);
238
+
239
+ /*
240
+ * The neutral covers lose the label and the focus ring on an overlay, so the controls on the card
241
+ * answer the pointer with the accent states, which the design system holds legible on the overlay too.
242
+ */
243
+
244
+ --skin--background-color-hover-neutral: var(--skin--background-color-hover);
245
+ --skin--background-color-pressed-neutral: var(--skin--background-color-pressed);
246
+
247
+ /*
248
+ * The mark is centred on the first line, the space a line takes beyond the glyph split above and below
249
+ * it, and held further off the message than the gap alone, so it reads as a marker set apart.
250
+ */
251
+
252
+ & > svg {
253
+ flex: none;
254
+ margin-block: calc((1lh - 1em) / 2);
255
+ margin-inline-end: var(--skin--spacing-025);
256
+ }
257
+
258
+ /* The message takes the room the mark and the dismiss control leave, wrapping within it. */
259
+
260
+ & > span {
261
+
262
+ flex: 1;
263
+ min-width: 0;
264
+ overflow-wrap: anywhere;
265
+
266
+ /*
267
+ * The message of an actionable post is a native button, so it takes the focus and the keys a
268
+ * control answers to, drawn as a quiet link: in the weight and the ink of the message around it,
269
+ * told from plain text by a hairline underline in the colour of a rule, and taking the link colour
270
+ * only once the pointer is on it.
271
+ */
272
+
273
+ & > button {
274
+
275
+ all: unset;
276
+
277
+ cursor: pointer;
278
+
279
+ text-decoration-line: underline;
280
+ text-decoration-color: var(--skin--border-color);
281
+ text-decoration-thickness: var(--skin--border-width);
282
+ text-underline-position: under; /* Hung below the descenders, as links are. */
283
+ text-underline-offset: 0.15em;
284
+
285
+ &:hover {
286
+ color: var(--skin--color-hover);
287
+ text-decoration-color: currentColor;
288
+ }
289
+
290
+ &:focus-visible {
291
+ outline: var(--skin--outline-focus);
292
+ }
293
+
294
+ }
295
+
296
+ }
297
+
298
+ /*
299
+ * The dismiss control is set smaller than the message and in the ink a field label takes, so it reads
300
+ * as an aside to the message rather than as a control competing with it. The button floors its target
301
+ * on the text it is set in, so the smaller text draws a smaller target, held clear by the gap.
302
+ */
303
+
304
+ & > div {
305
+
306
+ /* Held to the first line of the message, so the control is centred on it whatever its size. */
307
+
308
+ flex: none;
309
+ display: flex;
310
+ align-items: center;
311
+ height: 1lh;
312
+
313
+ & > clay-button {
314
+ font-size: var(--skin--scaling-075);
315
+ color: var(--skin--color-label);
316
+ }
317
+
318
+ }
319
+
320
+ }
321
+
322
+ }
323
+
324
+ /*
325
+ * A card telling of a status colours its mark and its strip in the ink of its step, its glyph and its wording
326
+ * telling the same status, so no reader depends on the colour; a plain post keeps the mark in the ink of text.
327
+ */
328
+
329
+ &[status="pending"] > div > div {
330
+
331
+ --clay-toasts-ink: var(--skin--color-note);
332
+
333
+ /* The mark turns at the spin period whatever motion the reader asked for. */
334
+
335
+ & > svg {
336
+ color: var(--clay-toasts-ink);
337
+ animation: clay-toasts-turn var(--skin--duration-spin) linear infinite;
338
+ }
339
+
340
+ }
341
+
342
+ &[status="success"] > div > div {
343
+
344
+ --clay-toasts-ink: var(--skin--color-pass);
345
+
346
+ & > svg {
347
+ color: var(--clay-toasts-ink);
348
+ }
349
+
350
+ }
351
+
352
+ &[status="paused"] > div > div {
353
+
354
+ --clay-toasts-ink: var(--skin--color-flag);
355
+
356
+ & > svg {
357
+ color: var(--clay-toasts-ink);
358
+ }
359
+
360
+ }
361
+
362
+ &[status="warning"] > div > div {
363
+
364
+ --clay-toasts-ink: var(--skin--color-warn);
365
+
366
+ & > svg {
367
+ color: var(--clay-toasts-ink);
368
+ }
369
+
370
+ }
371
+
372
+ /* A defect of the interface is a failure all the same, told apart from an ordinary one by its glyph alone. */
373
+
374
+ &:is([status="failure"], [status="defect"]) > div > div {
375
+
376
+ --clay-toasts-ink: var(--skin--color-fail);
377
+
378
+ & > svg {
379
+ color: var(--clay-toasts-ink);
380
+ }
381
+
382
+ }
383
+
384
+ }
385
+
386
+ /*
387
+ * The control dismissing every toast shown is a small round button centred on a corner of the tray, no larger
388
+ * than its mark needs, set apart from the tray as described below, its mark set like the controls on the cards:
389
+ * smaller than the message and in the ink of a label, so it reads as an aside to the toasts it clears.
390
+ *
391
+ * The corner is the one the tray is anchored by, on the edge the stack hangs from and the side it keeps to, so the
392
+ * button stays put while toasts come and go and the tray grows and shrinks away from it: the top end corner by
393
+ * default, a bottom corner for a stack hanging from the bottom, a start corner for a stack kept to the start.
394
+ */
395
+
396
+ & > footer {
397
+
398
+ /*
399
+ * The corner of a rounded tray is the middle of its curve, which lies in from either edge by the radius less
400
+ * its projection at 45 degrees; the button is centred halfway between there and the corner of the box, so it
401
+ * sits a little outside the curve, shifted by half its own size outwards on either axis.
402
+ */
403
+
404
+ --clay-toasts-corner: calc(var(--skin--border-radius-100) * (1 - cos(45deg)) / 2);
405
+ --clay-toasts-x: 50%;
406
+ --clay-toasts-y: -50%;
407
+
408
+ position: absolute;
409
+ inset-block-start: var(--clay-toasts-corner);
410
+ inset-inline-end: var(--clay-toasts-corner);
411
+
412
+ translate: var(--clay-toasts-x) var(--clay-toasts-y);
413
+
414
+ display: flex;
415
+ justify-content: center;
416
+ align-items: center;
417
+
418
+ /*
419
+ * The button is the glass of the tray made opaque, the tint the tray is laid in at full strength, so it reads
420
+ * a shade darker than the tray whatever the tray lets through, and ringed in the colour of the page, so a
421
+ * narrow band of page sets it apart from the tray rather than letting it melt into it.
422
+ */
423
+
424
+ background-color: oklch(from var(--skin--background-color-glass) l c h / 1);
425
+ border: calc(2 * var(--skin--border-width)) var(--skin--border-style) var(--skin--background-color);
426
+
427
+ /* The square is rounded to a circle whatever the side measures, clipping the button fill with it. */
428
+
429
+ border-radius: 50%;
430
+ overflow: hidden;
431
+
432
+ /* The inline end lies on the left where the writing runs right to left, so the outward shift turns with it. */
433
+
434
+ &:dir(rtl) {
435
+ translate: calc(-1 * var(--clay-toasts-x)) var(--clay-toasts-y);
436
+ }
437
+
438
+ /* The mark takes the colour of the ring, so the two read as one control cut out of the tray. */
439
+
440
+ & > clay-button {
441
+ font-size: var(--skin--scaling-075);
442
+ color: var(--skin--background-color);
443
+ }
444
+
445
+ }
446
+
447
+ &[edge="bottom"] > footer {
448
+ inset-block: auto var(--clay-toasts-corner);
449
+ --clay-toasts-y: 50%;
450
+ }
451
+
452
+ &[side="start"] > footer {
453
+ inset-inline: var(--clay-toasts-corner) auto;
454
+ --clay-toasts-x: -50%;
455
+ }
456
+
457
+ }
458
+
459
+ @keyframes clay-toasts-turn {
460
+ to {
461
+ rotate: 1turn;
462
+ }
463
+ }
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Transient notices.
3
+ *
4
+ * Offers the stack of notices telling a reader how the operations under way are going and how they ended, floating
5
+ * over the screen without moving anything on it, and read out to assistive technology as they change.
6
+ *
7
+ * @module toasts
8
+ */
9
+ import { type Post } from "@grafctory/clay/board";
10
+ import "./toasts.css";
11
+ /**
12
+ * Creates a toast stack.
13
+ *
14
+ * Floats the posts standing on the enclosing {@link @grafctory/clay!board.Board Board} over an edge of the screen,
15
+ * one toast each, newest nearest the edge, each marked by a glyph telling its status, so an interface tells the reader
16
+ * how its operations are going without laying out room for them. A post updated on the board is updated where it
17
+ * stands, a post put up slides in, and a post cleared fades out while the others stay put.
18
+ *
19
+ * Where given a `timeout`, a toast telling of nothing more pressing than a plain or completed post is taken away on
20
+ * its own once it is up, while the post stays on the board for any other reader. Any other toast stays until whoever
21
+ * put its post up clears it, or until the reader deals with it: by dismissing it through the quiet control beside the
22
+ * message, hinted as it is pointed at, or by following the message of an actionable post where an `onAction` handler
23
+ * is given. Either way the post is cleared from the board for every reader. The stack takes the pointer over the whole
24
+ * of its glass, so a click falling between its toasts never lands on what lies beneath it.
25
+ *
26
+ * Every toast takes the same width, so the stack reads as one column, a long message wrapping rather than widening
27
+ * its toast; the width is retuned through the `--clay-toasts-width` custom property, `24rem` unless restated, and
28
+ * gives way to the whole width of a narrow screen.
29
+ *
30
+ * Every post put up or updated is read out to assistive technology without moving the focus. The stack is to be
31
+ * rendered once, near the root of the interface, as it is the page region announcements come from; outside any board
32
+ * it shows nothing.
33
+ *
34
+ * @param options The widget configuration
35
+ *
36
+ * @returns The toast stack
37
+ */
38
+ export declare function Toasts({ position, timeout, onAction }?: {
39
+ /**
40
+ * Where the stack floats: the edge of the screen it hangs from, and the side of that edge it keeps to, `start` and
41
+ * `end` following the writing direction; centred on the edge if only the edge is given. The newest toast sits
42
+ * nearest the edge and slides in from it. On a narrow screen the stack spans the edge whatever the side, so it
43
+ * keeps every toast legible. One placement serves a whole interface, chosen where its layout leaves room, clear of
44
+ * the navigation and the main actions; if omitted, the stack hangs from the top edge, centred on it.
45
+ */
46
+ position?: "top" | "bottom" | readonly ["top" | "bottom", "start" | "center" | "end"];
47
+ /**
48
+ * The milliseconds the toast of a `normal` or `success` post is shown before it is taken away, counted from the
49
+ * moment the post was put up or last updated; the post itself stays on the board. The toasts of `pending`,
50
+ * `paused`, `warning`, `failure` and `defect` posts stay until their posts are cleared, as do those of actionable
51
+ * posts whatever their status where an `onAction` handler is given, so nothing still under way, waiting to be
52
+ * resumed, asking for attention or waiting to be acted on goes unseen. No toast is taken away on its own if the
53
+ * value is not positive or omitted, and every toast then stays in view until its post is cleared from the board.
54
+ */
55
+ timeout?: number;
56
+ /**
57
+ * What an actionable post is handed to when the reader activates its message, for instance to open what it tells
58
+ * of or to retry what failed; supplying it turns the message of every actionable post into a control, drawn as a
59
+ * link. Acting on a post deals with it, so the post is cleared from the board for every reader before it is handed
60
+ * over, and a handler putting it up again keeps it standing. Messages stay plain text if omitted.
61
+ */
62
+ onAction?: (post: Post) => void;
63
+ }): import("preact").VNode<{
64
+ role: string;
65
+ edge: "bottom" | "top";
66
+ side: string;
67
+ }>;
68
+ //# sourceMappingURL=toasts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toasts.d.ts","sourceRoot":"","sources":["../../src/signals/toasts.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,IAAI,EAAmC,MAAM,uBAAuB,CAAC;AAKnF,OAAO,cAAc,CAAC;AAGtB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,MAAM,CAAC,EAEtB,QAAgB,EAChB,OAAW,EAEX,QAAQ,EAER,GAAE;IAEF;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,SAAS,CAAC,KAAK,GAAG,QAAQ,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAA;IAErF;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAGhB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAA;CAE1B;;;;GA+DL"}