@atelic-action/ui 4.0.0 → 4.1.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.
- package/README.md +15 -2
- package/package.json +1 -1
- package/src/email/frame.tsx +154 -2
- package/src/email/render.tsx +24 -2
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ Every export, grouped by the entry it is imported from. The gallery column links
|
|
|
46
46
|
| `AppErrorBoundary`, `ErrorFallback` | `@atelic-action/ui/artifact` | The error boundary and the page it falls back to | none |
|
|
47
47
|
| `buildPageHead`, `canonicalURL`, `newTabProps`, the `ArtifactConfig` types | `@atelic-action/ui/artifact` | A page's head, a link's new tab props, and a site's contract | none |
|
|
48
48
|
| `whoIsReading` | `@atelic-action/ui/artifact` and `@atelic-action/ui/artifact/readers` | Who opened a document, by the email they signed in with; the second entry is the same function, built, for what Node runs | none |
|
|
49
|
-
| `Masthead`, `TitleCard`, `Footer`, `FailurePage` | `@atelic-action/ui/email` | An email's frame: the wordmark row, the title card, the foot, the failure page | [#email](https://ui.atelic.me/#email) |
|
|
49
|
+
| `Masthead`, `TitleCard`, `Footer`, `FailurePage` | `@atelic-action/ui/email` | An email's frame: the wordmark row, the title card, the foot, the failure page (plain, or structured by a step and a fix) | [#email](https://ui.atelic.me/#email) |
|
|
50
50
|
| `Card`, `Row`, `FoldRow`, `Eyebrow`, `SubEyebrow`, `Fold`, `BigFold` | `@atelic-action/ui/email` | The containers and labels an email's sections sit in | [#email](https://ui.atelic.me/#email) |
|
|
51
51
|
| `Item`, `TitleLine`, `Note`, `EmptyRow`, `Stat`, `StatsRow`, `List`, `ListRow`, `LeadRow`, `MonoTable`, `ReadBlock`, `Badge` | `@atelic-action/ui/email` | The rows inside a card | [#email](https://ui.atelic.me/#email) |
|
|
52
52
|
| `Scoreboard`, `GroupRow`, `TargetRow`, `Bar`, `WhatMoved`, `DayStrip`, `StatStrip` | `@atelic-action/ui/email` | Targets against what was logged, what moved, and the week by day | [#email](https://ui.atelic.me/#email) |
|
|
@@ -650,6 +650,19 @@ const text = recordStackText(records);
|
|
|
650
650
|
|
|
651
651
|
`renderEmail` builds the document shell itself and puts only the rows through React, because React emits no doctype, React 19 hoists and reorders head tags, and it would escape the `>` in `details>summary`. `renderFailureEmail` is the same shell around `FailurePage`. Both live at `@atelic-action/ui/email/render`, apart from the components, so a site that mounts a component on a page never pulls React's server renderer into its browser bundle.
|
|
652
652
|
|
|
653
|
+
The failure page takes two optional strings (4.1.0): `step`, what failed as a short label (`"Claude model call"`), and `fix`, what to do in a sentence or two that may hold a command. Given either, the reason line under the headline becomes a labelled block, one row per fact on a hairline with a faint eyebrow over its value: What Failed (the step), Why (the reason), and What to Do (the fix, its label in the accent and its value in mono), then the log tail under its own Log eyebrow. A row whose value is empty or only whitespace is left out, so an empty reason leaves no bare Why. The preheader leads with the step when there is one (`Claude model call: OAuth token revoked`). Given neither, the page is byte for byte what it was before, held by a frozen copy in `tst/email/frozen/`.
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
renderFailureEmail({
|
|
657
|
+
runnerTitle: "Brief",
|
|
658
|
+
eyebrowText: "Week 47",
|
|
659
|
+
step: "Claude model call",
|
|
660
|
+
reason: "OAuth token revoked, status 401",
|
|
661
|
+
fix: "Run claude setup-token, then push the new token to the vault.",
|
|
662
|
+
logTail,
|
|
663
|
+
});
|
|
664
|
+
```
|
|
665
|
+
|
|
653
666
|
### The Mapping
|
|
654
667
|
|
|
655
668
|
Where the jq takes a pre rendered html string (`$rows`, `$body_html`, `$cells_html`, a records cell's `html`, a stat's caption), the React prop is `children` or a `ReactNode`. Where the jq escapes a string argument, the prop is a plain string and React does the escaping.
|
|
@@ -688,7 +701,7 @@ Where the jq takes a pre rendered html string (`$rows`, `$body_html`, `$cells_ht
|
|
|
688
701
|
| `title_card` | `TitleCard` | `eyebrowText`, `headlineLines`, `lede`, `stats` (the rows under the lede, in place of the jq's `$stats_html`) |
|
|
689
702
|
| `footer` | `Footer` | `meta` |
|
|
690
703
|
| `page` | `renderEmail` | `title`, `preheader`, `children`, `palette`, `fonts` |
|
|
691
|
-
| `failure_page` | `renderFailureEmail`, or `FailurePage` as body rows | `runnerTitle`, `eyebrowText`, `reason`, `logTail` |
|
|
704
|
+
| `failure_page` | `renderFailureEmail`, or `FailurePage` as body rows | `runnerTitle`, `eyebrowText`, `reason`, `logTail`, and since 4.1.0 the optional `step` and `fix` (no jq counterpart) |
|
|
692
705
|
|
|
693
706
|
The plain text alternative part ports as plain functions with no React anywhere in them: `spaces`, `rpad`, `lpad`, `wrap`, `textRule`, `textSection`, `textRead`, `textBar`, `textTarget`, `textTableGrid`, `textTable`, `recordStackText`, `textWidth`, plus `asciiUpcase` and `asciiDowncase`. Every width counts Unicode codepoints, the way jq's `length` does.
|
|
694
707
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atelic-action/ui",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Shared UI for the Atelic templates: site chrome, base styles, the component library, the access gate, and the app shell they install",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
package/src/email/frame.tsx
CHANGED
|
@@ -188,14 +188,50 @@ export type FailurePageProps = {
|
|
|
188
188
|
eyebrowText: string;
|
|
189
189
|
reason: string;
|
|
190
190
|
logTail: string;
|
|
191
|
+
/** What failed, as a short label ("Claude model call"). */
|
|
192
|
+
step?: string;
|
|
193
|
+
/** What to do about it, a sentence or two that may hold a command. */
|
|
194
|
+
fix?: string;
|
|
191
195
|
};
|
|
192
196
|
|
|
197
|
+
/** True for a string with something in it besides whitespace. */
|
|
198
|
+
function filled(value: string | undefined): value is string {
|
|
199
|
+
return value !== undefined && value.trim() !== "";
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** One long token (a path, a URL) wraps instead of widening the column. */
|
|
203
|
+
const wrapLong = { overflowWrap: "anywhere", wordBreak: "break-word" } as const;
|
|
204
|
+
|
|
205
|
+
type FailureFact = { label: string; value: string; kind: "step" | "reason" | "fix" };
|
|
206
|
+
|
|
193
207
|
/**
|
|
194
208
|
* The body rows of the failure page, in the same cream, so a bad week reads
|
|
195
|
-
* like a good one with the reason on top and the log's tail beneath.
|
|
209
|
+
* like a good one with the reason on top and the log's tail beneath. With a
|
|
210
|
+
* `step` or a `fix` the reason becomes a labelled block of what failed, why,
|
|
211
|
+
* and what to do, and the log sits under its own label; without either the
|
|
212
|
+
* page is exactly the plain one.
|
|
196
213
|
*/
|
|
197
|
-
export function FailurePage({
|
|
214
|
+
export function FailurePage({
|
|
215
|
+
runnerTitle,
|
|
216
|
+
eyebrowText,
|
|
217
|
+
reason,
|
|
218
|
+
logTail,
|
|
219
|
+
step,
|
|
220
|
+
fix,
|
|
221
|
+
}: FailurePageProps) {
|
|
198
222
|
const { palette, fonts } = useEmailTheme();
|
|
223
|
+
if (filled(step) || filled(fix)) {
|
|
224
|
+
return (
|
|
225
|
+
<StructuredFailurePage
|
|
226
|
+
runnerTitle={runnerTitle}
|
|
227
|
+
eyebrowText={eyebrowText}
|
|
228
|
+
reason={reason}
|
|
229
|
+
logTail={logTail}
|
|
230
|
+
step={step}
|
|
231
|
+
fix={fix}
|
|
232
|
+
/>
|
|
233
|
+
);
|
|
234
|
+
}
|
|
199
235
|
return (
|
|
200
236
|
<>
|
|
201
237
|
<Masthead title={runnerTitle} />
|
|
@@ -254,3 +290,119 @@ export function FailurePage({ runnerTitle, eyebrowText, reason, logTail }: Failu
|
|
|
254
290
|
</>
|
|
255
291
|
);
|
|
256
292
|
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The structured failure page: the same eyebrow and headline, then one row per
|
|
296
|
+
* fact that has a value, each a faint eyebrow over its value on a hairline,
|
|
297
|
+
* and the log's tail last under its own eyebrow. The fix's label wears the
|
|
298
|
+
* accent, as an accented `Note` does, and its value is set in mono because it
|
|
299
|
+
* so often holds a command.
|
|
300
|
+
*/
|
|
301
|
+
function StructuredFailurePage({
|
|
302
|
+
runnerTitle,
|
|
303
|
+
eyebrowText,
|
|
304
|
+
reason,
|
|
305
|
+
logTail,
|
|
306
|
+
step,
|
|
307
|
+
fix,
|
|
308
|
+
}: FailurePageProps) {
|
|
309
|
+
const { palette, fonts } = useEmailTheme();
|
|
310
|
+
const facts: FailureFact[] = [];
|
|
311
|
+
if (filled(step)) facts.push({ label: "What Failed", value: step, kind: "step" });
|
|
312
|
+
if (filled(reason)) facts.push({ label: "Why", value: reason, kind: "reason" });
|
|
313
|
+
if (filled(fix)) facts.push({ label: "What to Do", value: fix, kind: "fix" });
|
|
314
|
+
const hasLog = filled(logTail);
|
|
315
|
+
const cell = { padding: "14px 0", borderTop: `1px solid ${palette.line}` };
|
|
316
|
+
const valueStyle = (kind: FailureFact["kind"]) => {
|
|
317
|
+
if (kind === "fix") {
|
|
318
|
+
return {
|
|
319
|
+
marginTop: "6px",
|
|
320
|
+
fontFamily: fonts.mono,
|
|
321
|
+
fontSize: "13px",
|
|
322
|
+
lineHeight: "1.6",
|
|
323
|
+
color: palette.ink,
|
|
324
|
+
whiteSpace: "pre-wrap" as const,
|
|
325
|
+
...wrapLong,
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
marginTop: "6px",
|
|
330
|
+
fontFamily: fonts.sans,
|
|
331
|
+
fontSize: "15px",
|
|
332
|
+
lineHeight: "1.5",
|
|
333
|
+
color: kind === "step" ? palette.ink : palette.dim,
|
|
334
|
+
...wrapLong,
|
|
335
|
+
...(kind === "step" ? { fontWeight: "600" } : {}),
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
return (
|
|
339
|
+
<>
|
|
340
|
+
<Masthead title={runnerTitle} />
|
|
341
|
+
<Card>
|
|
342
|
+
<tr>
|
|
343
|
+
<td style={{ padding: "26px 26px 6px", ...eyebrowStyle(fonts), color: palette.faint }}>
|
|
344
|
+
{eyebrowText}
|
|
345
|
+
</td>
|
|
346
|
+
</tr>
|
|
347
|
+
<tr>
|
|
348
|
+
<td
|
|
349
|
+
style={{
|
|
350
|
+
padding: "0 26px",
|
|
351
|
+
fontFamily: fonts.sans,
|
|
352
|
+
fontSize: "30px",
|
|
353
|
+
fontWeight: "600",
|
|
354
|
+
letterSpacing: "-0.03em",
|
|
355
|
+
lineHeight: "1.1",
|
|
356
|
+
color: palette.ink,
|
|
357
|
+
}}
|
|
358
|
+
>
|
|
359
|
+
{`The ${asciiDowncase(runnerTitle)} did not run.`}
|
|
360
|
+
</td>
|
|
361
|
+
</tr>
|
|
362
|
+
<tr>
|
|
363
|
+
<td style={{ padding: "22px 26px 12px" }}>
|
|
364
|
+
<table {...tableReset} width="100%">
|
|
365
|
+
<tbody>
|
|
366
|
+
{facts.map((fact) => (
|
|
367
|
+
<tr key={fact.kind}>
|
|
368
|
+
<td style={cell}>
|
|
369
|
+
<div
|
|
370
|
+
style={{
|
|
371
|
+
...eyebrowStyle(fonts),
|
|
372
|
+
color: fact.kind === "fix" ? palette.accent : palette.faint,
|
|
373
|
+
}}
|
|
374
|
+
>
|
|
375
|
+
{fact.label}
|
|
376
|
+
</div>
|
|
377
|
+
<div style={valueStyle(fact.kind)}>{fact.value}</div>
|
|
378
|
+
</td>
|
|
379
|
+
</tr>
|
|
380
|
+
))}
|
|
381
|
+
{hasLog ? (
|
|
382
|
+
<tr>
|
|
383
|
+
<td style={cell}>
|
|
384
|
+
<div style={{ ...eyebrowStyle(fonts), color: palette.faint }}>Log</div>
|
|
385
|
+
<pre
|
|
386
|
+
style={{
|
|
387
|
+
fontFamily: fonts.mono,
|
|
388
|
+
fontSize: "12px",
|
|
389
|
+
lineHeight: "1.5",
|
|
390
|
+
whiteSpace: "pre-wrap",
|
|
391
|
+
...wrapLong,
|
|
392
|
+
color: palette.dim,
|
|
393
|
+
margin: "6px 0 0",
|
|
394
|
+
}}
|
|
395
|
+
>
|
|
396
|
+
{logTail}
|
|
397
|
+
</pre>
|
|
398
|
+
</td>
|
|
399
|
+
</tr>
|
|
400
|
+
) : null}
|
|
401
|
+
</tbody>
|
|
402
|
+
</table>
|
|
403
|
+
</td>
|
|
404
|
+
</tr>
|
|
405
|
+
</Card>
|
|
406
|
+
</>
|
|
407
|
+
);
|
|
408
|
+
}
|
package/src/email/render.tsx
CHANGED
|
@@ -77,22 +77,42 @@ export type RenderFailureEmailOptions = {
|
|
|
77
77
|
eyebrowText: string;
|
|
78
78
|
reason: string;
|
|
79
79
|
logTail: string;
|
|
80
|
+
/** What failed, as a short label; it also leads the preheader. */
|
|
81
|
+
step?: string;
|
|
82
|
+
/** What to do about it, a sentence or two that may hold a command. */
|
|
83
|
+
fix?: string;
|
|
80
84
|
palette?: Palette;
|
|
81
85
|
fonts?: Fonts;
|
|
82
86
|
};
|
|
83
87
|
|
|
84
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* The inbox preview: the reason alone, or led by the step when there is one
|
|
90
|
+
* ("Claude model call: OAuth token revoked").
|
|
91
|
+
*/
|
|
92
|
+
function failurePreheader(reason: string, step: string | undefined): string {
|
|
93
|
+
const label = step?.trim() ?? "";
|
|
94
|
+
if (label === "") return reason;
|
|
95
|
+
const why = reason.trim();
|
|
96
|
+
return why === "" ? label : `${label}: ${why}`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The failure page: the reason on top and the log's tail beneath, or with a
|
|
101
|
+
* `step` or a `fix` the labelled block of what failed, why, and what to do.
|
|
102
|
+
*/
|
|
85
103
|
export function renderFailureEmail({
|
|
86
104
|
runnerTitle,
|
|
87
105
|
eyebrowText,
|
|
88
106
|
reason,
|
|
89
107
|
logTail,
|
|
108
|
+
step,
|
|
109
|
+
fix,
|
|
90
110
|
palette,
|
|
91
111
|
fonts,
|
|
92
112
|
}: RenderFailureEmailOptions): string {
|
|
93
113
|
return renderEmail({
|
|
94
114
|
title: `${runnerTitle}: did not run`,
|
|
95
|
-
preheader: reason,
|
|
115
|
+
preheader: failurePreheader(reason, step),
|
|
96
116
|
palette,
|
|
97
117
|
fonts,
|
|
98
118
|
children: (
|
|
@@ -101,6 +121,8 @@ export function renderFailureEmail({
|
|
|
101
121
|
eyebrowText={eyebrowText}
|
|
102
122
|
reason={reason}
|
|
103
123
|
logTail={logTail}
|
|
124
|
+
step={step}
|
|
125
|
+
fix={fix}
|
|
104
126
|
/>
|
|
105
127
|
),
|
|
106
128
|
});
|