@grafctory/clay-widgets 0.0.0-stage → 0.4.1
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/LICENSE +201 -0
- package/README.md +46 -2
- package/dist/content/empty.css +107 -0
- package/dist/content/empty.d.ts +40 -0
- package/dist/content/empty.d.ts.map +1 -0
- package/dist/content/empty.js +42 -0
- package/dist/content/empty.js.map +1 -0
- package/dist/content/heading.css +34 -0
- package/dist/content/heading.d.ts +45 -0
- package/dist/content/heading.d.ts.map +1 -0
- package/dist/content/heading.js +49 -0
- package/dist/content/heading.js.map +1 -0
- package/dist/content/image.css +176 -0
- package/dist/content/image.d.ts +71 -0
- package/dist/content/image.d.ts.map +1 -0
- package/dist/content/image.js +63 -0
- package/dist/content/image.js.map +1 -0
- package/dist/content/infobox.css +186 -0
- package/dist/content/infobox.d.ts +72 -0
- package/dist/content/infobox.d.ts.map +1 -0
- package/dist/content/infobox.js +63 -0
- package/dist/content/infobox.js.map +1 -0
- package/dist/content/pill.css +76 -0
- package/dist/content/pill.d.ts +57 -0
- package/dist/content/pill.d.ts.map +1 -0
- package/dist/content/pill.js +48 -0
- package/dist/content/pill.js.map +1 -0
- package/dist/content/text.css +44 -0
- package/dist/content/text.d.ts +30 -0
- package/dist/content/text.d.ts.map +1 -0
- package/dist/content/text.js +42 -0
- package/dist/content/text.js.map +1 -0
- package/dist/controls/button.css +469 -0
- package/dist/controls/button.d.ts +116 -0
- package/dist/controls/button.d.ts.map +1 -0
- package/dist/controls/button.js +61 -0
- package/dist/controls/button.js.map +1 -0
- package/dist/controls/checkbox.css +23 -0
- package/dist/controls/checkbox.d.ts +54 -0
- package/dist/controls/checkbox.d.ts.map +1 -0
- package/dist/controls/checkbox.js +49 -0
- package/dist/controls/checkbox.js.map +1 -0
- package/dist/controls/choice.css +288 -0
- package/dist/controls/choice.d.ts +63 -0
- package/dist/controls/choice.d.ts.map +1 -0
- package/dist/controls/choice.js +52 -0
- package/dist/controls/choice.js.map +1 -0
- package/dist/controls/fieldset.css +37 -0
- package/dist/controls/fieldset.d.ts +49 -0
- package/dist/controls/fieldset.d.ts.map +1 -0
- package/dist/controls/fieldset.js +51 -0
- package/dist/controls/fieldset.js.map +1 -0
- package/dist/controls/form.css +50 -0
- package/dist/controls/form.d.ts +64 -0
- package/dist/controls/form.d.ts.map +1 -0
- package/dist/controls/form.js +62 -0
- package/dist/controls/form.js.map +1 -0
- package/dist/controls/input.css +57 -0
- package/dist/controls/input.d.ts +120 -0
- package/dist/controls/input.d.ts.map +1 -0
- package/dist/controls/input.js +78 -0
- package/dist/controls/input.js.map +1 -0
- package/dist/controls/label.css +73 -0
- package/dist/controls/label.d.ts +76 -0
- package/dist/controls/label.d.ts.map +1 -0
- package/dist/controls/label.js +73 -0
- package/dist/controls/label.js.map +1 -0
- package/dist/controls/radio.css +23 -0
- package/dist/controls/radio.d.ts +60 -0
- package/dist/controls/radio.d.ts.map +1 -0
- package/dist/controls/radio.js +50 -0
- package/dist/controls/radio.js.map +1 -0
- package/dist/controls/select.css +37 -0
- package/dist/controls/select.d.ts +62 -0
- package/dist/controls/select.d.ts.map +1 -0
- package/dist/controls/select.js +59 -0
- package/dist/controls/select.js.map +1 -0
- package/dist/controls/switch.css +154 -0
- package/dist/controls/switch.d.ts +44 -0
- package/dist/controls/switch.d.ts.map +1 -0
- package/dist/controls/switch.js +48 -0
- package/dist/controls/switch.js.map +1 -0
- package/dist/controls/textarea.css +50 -0
- package/dist/controls/textarea.d.ts +97 -0
- package/dist/controls/textarea.d.ts.map +1 -0
- package/dist/controls/textarea.js +75 -0
- package/dist/controls/textarea.js.map +1 -0
- package/dist/glyphs/icon.core.d.ts +52 -0
- package/dist/glyphs/icon.core.d.ts.map +1 -0
- package/dist/glyphs/icon.core.js +67 -0
- package/dist/glyphs/icon.core.js.map +1 -0
- package/dist/glyphs/icon.css +32 -0
- package/dist/glyphs/icon.d.ts +152 -0
- package/dist/glyphs/icon.d.ts.map +1 -0
- package/dist/glyphs/icon.js +167 -0
- package/dist/glyphs/icon.js.map +1 -0
- package/dist/glyphs/icon.md +76 -0
- package/dist/glyphs/logo.css +73 -0
- package/dist/glyphs/logo.d.ts +27 -0
- package/dist/glyphs/logo.d.ts.map +1 -0
- package/dist/glyphs/logo.js +49 -0
- package/dist/glyphs/logo.js.map +1 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts/card.css +166 -0
- package/dist/layouts/card.d.ts +69 -0
- package/dist/layouts/card.d.ts.map +1 -0
- package/dist/layouts/card.js +57 -0
- package/dist/layouts/card.js.map +1 -0
- package/dist/layouts/stack.css +58 -0
- package/dist/layouts/stack.d.ts +64 -0
- package/dist/layouts/stack.d.ts.map +1 -0
- package/dist/layouts/stack.js +69 -0
- package/dist/layouts/stack.js.map +1 -0
- package/dist/layouts/strip.css +58 -0
- package/dist/layouts/strip.d.ts +72 -0
- package/dist/layouts/strip.d.ts.map +1 -0
- package/dist/layouts/strip.js +73 -0
- package/dist/layouts/strip.js.map +1 -0
- package/dist/layouts/tabs.core.d.ts +73 -0
- package/dist/layouts/tabs.core.d.ts.map +1 -0
- package/dist/layouts/tabs.core.js +65 -0
- package/dist/layouts/tabs.core.js.map +1 -0
- package/dist/layouts/tabs.css +260 -0
- package/dist/layouts/tabs.d.ts +57 -0
- package/dist/layouts/tabs.d.ts.map +1 -0
- package/dist/layouts/tabs.js +128 -0
- package/dist/layouts/tabs.js.map +1 -0
- package/dist/layouts/tree.css +138 -0
- package/dist/layouts/tree.d.ts +46 -0
- package/dist/layouts/tree.d.ts.map +1 -0
- package/dist/layouts/tree.js +69 -0
- package/dist/layouts/tree.js.map +1 -0
- package/dist/navigation/link.css +229 -0
- package/dist/navigation/link.d.ts +89 -0
- package/dist/navigation/link.d.ts.map +1 -0
- package/dist/navigation/link.js +91 -0
- package/dist/navigation/link.js.map +1 -0
- package/dist/navigation/path.css +122 -0
- package/dist/navigation/path.d.ts +42 -0
- package/dist/navigation/path.d.ts.map +1 -0
- package/dist/navigation/path.js +49 -0
- package/dist/navigation/path.js.map +1 -0
- package/dist/navigation/toc.core.d.ts +111 -0
- package/dist/navigation/toc.core.d.ts.map +1 -0
- package/dist/navigation/toc.core.js +60 -0
- package/dist/navigation/toc.core.js.map +1 -0
- package/dist/navigation/toc.css +53 -0
- package/dist/navigation/toc.d.ts +112 -0
- package/dist/navigation/toc.d.ts.map +1 -0
- package/dist/navigation/toc.js +321 -0
- package/dist/navigation/toc.js.map +1 -0
- package/dist/scopes/guard.css +26 -0
- package/dist/scopes/guard.d.ts +37 -0
- package/dist/scopes/guard.d.ts.map +1 -0
- package/dist/scopes/guard.js +60 -0
- package/dist/scopes/guard.js.map +1 -0
- package/dist/scopes/style.css +26 -0
- package/dist/scopes/style.d.ts +68 -0
- package/dist/scopes/style.d.ts.map +1 -0
- package/dist/scopes/style.js +108 -0
- package/dist/scopes/style.js.map +1 -0
- package/dist/shells/tool.css +778 -0
- package/dist/shells/tool.d.ts +164 -0
- package/dist/shells/tool.d.ts.map +1 -0
- package/dist/shells/tool.js +251 -0
- package/dist/shells/tool.js.map +1 -0
- package/dist/signals/more.css +42 -0
- package/dist/signals/more.d.ts +28 -0
- package/dist/signals/more.d.ts.map +1 -0
- package/dist/signals/more.js +61 -0
- package/dist/signals/more.js.map +1 -0
- package/dist/signals/note.css +221 -0
- package/dist/signals/note.d.ts +83 -0
- package/dist/signals/note.d.ts.map +1 -0
- package/dist/signals/note.js +72 -0
- package/dist/signals/note.js.map +1 -0
- package/dist/signals/toasts.css +463 -0
- package/dist/signals/toasts.d.ts +68 -0
- package/dist/signals/toasts.d.ts.map +1 -0
- package/dist/signals/toasts.js +160 -0
- package/dist/signals/toasts.js.map +1 -0
- package/package.json +331 -4
|
@@ -0,0 +1,221 @@
|
|
|
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
|
+
* A note takes the middle of whatever space it is handed and stacks what it carries down the centre of it: a head
|
|
19
|
+
* naming what has happened and, beneath it, as much of a body as the occasion calls for. The body is plain markup,
|
|
20
|
+
* which the design system styles as it styles the same markup anywhere else on the page; what this sheet adds is
|
|
21
|
+
* what the column asks of it, a paragraph reading as one of a stack, a section scrolling within the note rather than
|
|
22
|
+
* stretching it, and machine-readable detail set apart from the text above.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
clay-note {
|
|
26
|
+
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
row-gap: var(--skin--spacing-100);
|
|
32
|
+
|
|
33
|
+
/* The note is as wide as what it carries, so the margins centre it rather than a block stretching it. */
|
|
34
|
+
|
|
35
|
+
width: fit-content;
|
|
36
|
+
|
|
37
|
+
margin: auto;
|
|
38
|
+
|
|
39
|
+
/*
|
|
40
|
+
* Margins centre a box down a flex or grid line but never down the plain flow of a page, so a note standing alone
|
|
41
|
+
* fills the height of its container, wherever that height is definite, and centres what it carries within it. A
|
|
42
|
+
* minimum rather than a height lets a note taller than its container grow past it and scroll with the page.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
&:only-child {
|
|
46
|
+
min-block-size: 100%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
& > *:not(p) {
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
* The head is the first thing the note renders, so it is reached by position: it is a button where the reader is
|
|
55
|
+
* asked something and a span otherwise, and a class would state what the order already does.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
& > :first-child {
|
|
59
|
+
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: row;
|
|
62
|
+
align-items: center;
|
|
63
|
+
column-gap: var(--skin--spacing-050);
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* The mark is drawn against the text size of the box it sits in, which is the measure every glyph is drawn
|
|
67
|
+
* against, so a mark of the consumer's own grows with the headline exactly as a standard one does.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
& > :first-child {
|
|
71
|
+
font-size: var(--skin--scaling-200);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/*
|
|
77
|
+
* A note asking something boxes its head, so that it reads as a control at rest: the colour the design system
|
|
78
|
+
* gives an enabled button arrives only once the pointer is on it. The box is the one thing saying that the head
|
|
79
|
+
* answers to a click, so it is drawn in the colour of an enabled control, which holds the 3:1 a boundary carrying
|
|
80
|
+
* that on its own owes, rather than in the border colour, which is mixed for a rule between things and holds 1.6:1.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
&:has(> button) > :first-child {
|
|
84
|
+
|
|
85
|
+
/*
|
|
86
|
+
* The vertical padding answers to the height of the text rather than to the spacing ladder: a head is a single
|
|
87
|
+
* line, and padding it by the rhythm between blocks would leave a pill deeper than the line it holds.
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
padding: 0.75ex var(--skin--spacing-075);
|
|
91
|
+
|
|
92
|
+
border-style: var(--skin--border-style);
|
|
93
|
+
border-color: var(--skin--color-enabled);
|
|
94
|
+
|
|
95
|
+
/* Rounded deeper than a panel, so the badge reads as a marker rather than as a box of its own. */
|
|
96
|
+
|
|
97
|
+
border-radius: var(--skin--border-radius-050);
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* A level is told by the weight of the headline and by the colour of the mark together, neither standing on its
|
|
103
|
+
* own, with the mark itself naming the kind of notice besides. The weight answers to the step and not to which
|
|
104
|
+
* step it is, so the five are told apart by hue alone and a passage carrying none keeps the ordinary weight.
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
&:not([level="normal"]) > :first-child {
|
|
108
|
+
font-weight: var(--skin--font-weight-strong);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&[level="neutral"] > :first-child > :first-child {
|
|
112
|
+
color: var(--skin--color-note);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&[level="positive"] > :first-child > :first-child {
|
|
116
|
+
color: var(--skin--color-pass);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&[level="notable"] > :first-child > :first-child {
|
|
120
|
+
color: var(--skin--color-flag);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
&[level="negative"] > :first-child > :first-child {
|
|
124
|
+
color: var(--skin--color-warn);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&[level="critical"] > :first-child > :first-child {
|
|
128
|
+
color: var(--skin--color-fail);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* A block of text is centred under the mark, broken where the wording breaks it. */
|
|
132
|
+
|
|
133
|
+
& > div {
|
|
134
|
+
text-align: center;
|
|
135
|
+
white-space: pre;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/*
|
|
139
|
+
* A body with more to it than the note has room for scrolls within the note rather than pushing the page down.
|
|
140
|
+
* The two edges are masked by sticky bars carrying a shadow the colour of the page, which ride at the top and the
|
|
141
|
+
* bottom of the scroll box and fade whatever is about to leave it.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
& > section {
|
|
145
|
+
|
|
146
|
+
max-height: 7.5em;
|
|
147
|
+
|
|
148
|
+
padding: var(--skin--spacing-050) 0;
|
|
149
|
+
|
|
150
|
+
border-style: var(--skin--border-style) none;
|
|
151
|
+
overflow-y: auto;
|
|
152
|
+
overflow-x: hidden;
|
|
153
|
+
|
|
154
|
+
&::before,
|
|
155
|
+
&::after {
|
|
156
|
+
|
|
157
|
+
display: block;
|
|
158
|
+
content: '';
|
|
159
|
+
|
|
160
|
+
position: sticky;
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
* A bare 1, not a layering token: the masks are only ever compared against the content scrolling under
|
|
164
|
+
* them inside this box, so the ladder settling which of two things overlapping the page wins says nothing
|
|
165
|
+
* about them, and borrowing a step from it would claim a rank they never compete for.
|
|
166
|
+
*/
|
|
167
|
+
|
|
168
|
+
z-index: 1;
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* The colour of the page rather than an elevation shadow: this one hides what is leaving the scroll box
|
|
172
|
+
* instead of lifting the bar off it, so --skin--box-shadow-raised is the wrong tool however similar the
|
|
173
|
+
* declaration looks.
|
|
174
|
+
*/
|
|
175
|
+
|
|
176
|
+
box-shadow: 0 0 var(--skin--spacing-050) var(--skin--spacing-050) var(--skin--background-color);
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&::before {
|
|
181
|
+
top: 0;
|
|
182
|
+
transform: translateY(calc(-1 * var(--skin--spacing-050)));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&::after {
|
|
186
|
+
bottom: 0;
|
|
187
|
+
transform: translateY(var(--skin--spacing-050));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/*
|
|
193
|
+
* Machine-readable detail is set apart from the text above between two rules, in the mono face the design system
|
|
194
|
+
* gives code. It is laid out exactly as written, so the indentation of a trace survives, and a line wider than the
|
|
195
|
+
* note scrolls across rather than folding.
|
|
196
|
+
*/
|
|
197
|
+
|
|
198
|
+
& > code {
|
|
199
|
+
|
|
200
|
+
max-width: 50em;
|
|
201
|
+
|
|
202
|
+
padding: var(--skin--spacing-100) 0;
|
|
203
|
+
|
|
204
|
+
border-style: var(--skin--border-style) none;
|
|
205
|
+
border-radius: 0;
|
|
206
|
+
overflow: auto;
|
|
207
|
+
|
|
208
|
+
background-color: transparent; /* Set apart by its rules rather than by the tint of inline code. */
|
|
209
|
+
|
|
210
|
+
white-space: pre;
|
|
211
|
+
font-size: 0.75em;
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* A detail rendered on a condition leaves an empty box behind, which the column would otherwise space as a line. */
|
|
216
|
+
|
|
217
|
+
& > :empty {
|
|
218
|
+
display: none;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centred notice.
|
|
3
|
+
*
|
|
4
|
+
* Offers the notice a screen shows where it has nothing else to put, whether an aside, a failure or a question,
|
|
5
|
+
* centred in the space it is given and marked with a glyph unless the reader is asked to answer it.
|
|
6
|
+
*
|
|
7
|
+
* @module note
|
|
8
|
+
*/
|
|
9
|
+
import { type ComponentChildren } from "preact";
|
|
10
|
+
import "./note.css";
|
|
11
|
+
/**
|
|
12
|
+
* Creates a note.
|
|
13
|
+
*
|
|
14
|
+
* Shows a glyph and a headline, with whatever detail is given beneath them, centred in the space the note is handed,
|
|
15
|
+
* so a screen fills an area it has nothing else to put in without laying one out for the purpose.
|
|
16
|
+
*
|
|
17
|
+
* A note that is the only child of its container fills the container's height, where that height is definite, and
|
|
18
|
+
* centres its content vertically as well as horizontally. A note sharing its container is centred horizontally only.
|
|
19
|
+
* A note taller than its container grows past it and scrolls with the page rather than within the container.
|
|
20
|
+
*
|
|
21
|
+
* A note given a headline sets the mark beside it on one line; one given none sets the mark above the body.
|
|
22
|
+
*
|
|
23
|
+
* Where the reader is asked something, `onAccept` turns the head into a native control, so the activation by `Enter`
|
|
24
|
+
* and `Space`, the tab stop and the focus ring come with it rather than having to be asked for. The head then stands
|
|
25
|
+
* on its wording alone, the box around it saying that it answers to a click where a glyph would say it twice.
|
|
26
|
+
*
|
|
27
|
+
* A note telling of a failure is read out as soon as it reaches the page, so a reader who does not see it learns of
|
|
28
|
+
* the failure where they expected the answer; an aside waits to be come upon in reading order.
|
|
29
|
+
*
|
|
30
|
+
* @param options The widget configuration
|
|
31
|
+
*
|
|
32
|
+
* @returns The note
|
|
33
|
+
*/
|
|
34
|
+
export declare function Note({ level, icon, text, onAccept, children }: {
|
|
35
|
+
/**
|
|
36
|
+
* How much attention the passage deserves, told in the weight of the headline and the colour of the mark on the
|
|
37
|
+
* five-step scale every meaning in the interface lands on: `neutral` states something no verdict has been passed
|
|
38
|
+
* on (`note`), `positive` tells of something standing as intended (`pass`), `notable` singles out a passage not to
|
|
39
|
+
* be missed, with nothing wrong (`flag`), `negative` carries a caveat the reader is to weigh (`warn`), `critical`
|
|
40
|
+
* tells of a failure (`fail`), and `normal`, the default, says nothing in particular and takes no colour at all.
|
|
41
|
+
* A level is never told in colour alone, so a note carrying one says the same thing in its mark and its wording.
|
|
42
|
+
*
|
|
43
|
+
* A note telling of a failure is read out as soon as it reaches the page rather than waiting to be come upon.
|
|
44
|
+
*/
|
|
45
|
+
level?: "normal" | "neutral" | "positive" | "notable" | "negative" | "critical";
|
|
46
|
+
/**
|
|
47
|
+
* The glyph marking the notice, kept out of the accessibility tree unless it carries a label of its own, so that
|
|
48
|
+
* the note is read by its headline; the mark matching the level if omitted, that is a check for a positive note,
|
|
49
|
+
* a star for a notable one, a warning sign for a negative one, an alert for a failure and an information mark
|
|
50
|
+
* otherwise. A note the reader answers shows no mark, so what is given here plays no part alongside `onAccept`.
|
|
51
|
+
*/
|
|
52
|
+
icon?: ComponentChildren;
|
|
53
|
+
/**
|
|
54
|
+
* The headline the notice is read by, required where `onAccept` makes the head a control, which carries no mark
|
|
55
|
+
* to name it by. It is kept on the one line the head occupies, so wording asking for more room belongs in the
|
|
56
|
+
* body.
|
|
57
|
+
*/
|
|
58
|
+
text?: string;
|
|
59
|
+
/**
|
|
60
|
+
* What the reader's answer is handed to: supplying it turns the head into a control, boxed so that it reads as
|
|
61
|
+
* one before it is reached; a notice the reader only takes in if omitted.
|
|
62
|
+
*
|
|
63
|
+
* A screen taking the note away on the answer owes the reader somewhere to land, the control they were on going
|
|
64
|
+
* with it: only whoever removes the note knows what stands in its place, so the focus is theirs to hand on.
|
|
65
|
+
*/
|
|
66
|
+
onAccept?: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* The detail shown beneath the head, in the column the note centres; plain markup, styled as the same markup is
|
|
69
|
+
* anywhere else on the page, with the element stating how the column is to take it: a `div` as a block of
|
|
70
|
+
* wording, centred and broken where the wording breaks it; a `p` as one paragraph of a stack; a `section` as a
|
|
71
|
+
* body scrolling within the note rather than stretching it; a `code` block as machine-readable detail set apart
|
|
72
|
+
* from the text above. An element left empty is dropped, so a detail rendered on a condition leaves no gap.
|
|
73
|
+
*/
|
|
74
|
+
children?: ComponentChildren;
|
|
75
|
+
} & ({
|
|
76
|
+
onAccept?: undefined;
|
|
77
|
+
} | {
|
|
78
|
+
text: string;
|
|
79
|
+
})): import("preact").VNode<{
|
|
80
|
+
role: string | undefined;
|
|
81
|
+
level: "normal" | "neutral" | "positive" | "notable" | "negative" | "critical";
|
|
82
|
+
}>;
|
|
83
|
+
//# sourceMappingURL=note.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.d.ts","sourceRoot":"","sources":["../../src/signals/note.tsx"],"names":[],"mappings":"AAgBA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,QAAQ,CAAC;AAE/D,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,IAAI,CAAC,EAEpB,KAAgB,EAEhB,IAAI,EACJ,IAAI,EAEJ,QAAQ,EAER,QAAQ,EAER,EAAE;IAEF;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAA;IAG/E;;;;;OAKG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAA;IAExB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAGb;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IAGrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAE5B,GAAG,CAAC;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;;;GAmChD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "preact/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright © 2026 Metreeca srl
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Centred notice.
|
|
19
|
+
*
|
|
20
|
+
* Offers the notice a screen shows where it has nothing else to put, whether an aside, a failure or a question,
|
|
21
|
+
* centred in the space it is given and marked with a glyph unless the reader is asked to answer it.
|
|
22
|
+
*
|
|
23
|
+
* @module note
|
|
24
|
+
*/
|
|
25
|
+
import { createElement } from "preact";
|
|
26
|
+
import { Icon } from "../glyphs/icon.js";
|
|
27
|
+
import "./note.css";
|
|
28
|
+
/**
|
|
29
|
+
* Creates a note.
|
|
30
|
+
*
|
|
31
|
+
* Shows a glyph and a headline, with whatever detail is given beneath them, centred in the space the note is handed,
|
|
32
|
+
* so a screen fills an area it has nothing else to put in without laying one out for the purpose.
|
|
33
|
+
*
|
|
34
|
+
* A note that is the only child of its container fills the container's height, where that height is definite, and
|
|
35
|
+
* centres its content vertically as well as horizontally. A note sharing its container is centred horizontally only.
|
|
36
|
+
* A note taller than its container grows past it and scrolls with the page rather than within the container.
|
|
37
|
+
*
|
|
38
|
+
* A note given a headline sets the mark beside it on one line; one given none sets the mark above the body.
|
|
39
|
+
*
|
|
40
|
+
* Where the reader is asked something, `onAccept` turns the head into a native control, so the activation by `Enter`
|
|
41
|
+
* and `Space`, the tab stop and the focus ring come with it rather than having to be asked for. The head then stands
|
|
42
|
+
* on its wording alone, the box around it saying that it answers to a click where a glyph would say it twice.
|
|
43
|
+
*
|
|
44
|
+
* A note telling of a failure is read out as soon as it reaches the page, so a reader who does not see it learns of
|
|
45
|
+
* the failure where they expected the answer; an aside waits to be come upon in reading order.
|
|
46
|
+
*
|
|
47
|
+
* @param options The widget configuration
|
|
48
|
+
*
|
|
49
|
+
* @returns The note
|
|
50
|
+
*/
|
|
51
|
+
export function Note({ level = "normal", icon, text, onAccept, children }) {
|
|
52
|
+
const $icon = icon ?? (level === "positive" ? _jsx(Icon.CircleCheck, {})
|
|
53
|
+
: level === "notable" ? _jsx(Icon.Star, {})
|
|
54
|
+
: level === "negative" ? _jsx(Icon.Alert, {})
|
|
55
|
+
: level === "critical" ? _jsx(Icon.CircleAlert, {})
|
|
56
|
+
: _jsx(Icon.Info, {}));
|
|
57
|
+
/*
|
|
58
|
+
* The element states the level, which a stylesheet has no other way to read.
|
|
59
|
+
*
|
|
60
|
+
* A note telling of a failure is read out as soon as it reaches the page, a failure being met where the reader
|
|
61
|
+
* expected what they asked for: a screen swapping one in for the content it could not show would otherwise
|
|
62
|
+
* leave a reader who does not see it waiting on an area that has already given its answer. An aside, which
|
|
63
|
+
* reports nothing, is met in reading order like any other passage.
|
|
64
|
+
*/
|
|
65
|
+
return createElement("clay-note", {
|
|
66
|
+
role: level === "critical" ? "alert" : undefined,
|
|
67
|
+
level
|
|
68
|
+
}, _jsxs(_Fragment, { children: [onAccept
|
|
69
|
+
? _jsx("button", { type: "button", onClick: onAccept, children: text })
|
|
70
|
+
: _jsxs("span", { children: [$icon, text] }), children] }));
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=note.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"note.js","sourceRoot":"","sources":["../../src/signals/note.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAA0B,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,IAAI,CAAC,EAEpB,KAAK,GAAG,QAAQ,EAEhB,IAAI,EACJ,IAAI,EAEJ,QAAQ,EAER,QAAQ,EAoDwC;IAEhD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,WAAW,KAAE;QAC/D,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,IAAI,KAAE;YACnC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,KAAK,KAAE;gBACrC,CAAC,CAAC,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAC,IAAI,CAAC,WAAW,KAAE;oBAC3C,CAAC,CAAC,KAAC,IAAI,CAAC,IAAI,KAAE,CAClB,CAAC;IAEF;;;;;;;OAOG;IAEH,OAAO,aAAa,CAAC,WAAW,EAAE;QAEjC,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;QAEhD,KAAK;KAEL,EAAE,8BAED,QAAQ;gBACR,CAAC,CAAC,iBAAQ,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,QAAQ,YAAG,IAAI,GAAU;gBAC1D,CAAC,CAAC,2BAAO,KAAK,EAAE,IAAI,IAAQ,EAG5B,QAAQ,IAEP,CAAC,CAAC;AAEN,CAAC"}
|