@atelic-action/ui 3.7.0 → 3.9.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/README.md CHANGED
@@ -39,7 +39,7 @@ Every export, grouped by the entry it is imported from. The gallery column links
39
39
  | `Button`, `Chip`, `Eyebrow`, `Lead`, `SectionHeading` | `@atelic-action/ui/primitives` | The small pieces a page is set in | [#primitives](https://ui.atelic.me/#primitives) |
40
40
  | `GradeChip`, `gradeLabel`, `WriteupGrade` | `@atelic-action/ui/artifact` | A section's grade, A to D, as a chip in its color, the letter alone, and the grade type | [#grade-chip](https://ui.atelic.me/#grade-chip) |
41
41
  | `SignOff`, `WriteupPerson` | `@atelic-action/ui/artifact` | The close a document ends on, and the person it names | [#sign-off](https://ui.atelic.me/#sign-off) |
42
- | `Shot`, `WriteupShot` | `@atelic-action/ui/artifact` | The owner's own screen, opening the full picture, over its caption | [#shot](https://ui.atelic.me/#shot) |
42
+ | `Shot`, `WriteupShot` | `@atelic-action/ui/artifact` | The owner's own screen, opening the full picture, over its caption; a portrait crop is marked `data-portrait` and held to 200px (1.8in in print) | [#shot](https://ui.atelic.me/#shot) |
43
43
  | `Paragraph`, `Runs`, `ArtifactAnchor`, `isEmpty`, `ArtifactLink`, `ArtifactParagraph` | `@atelic-action/ui/artifact` | Plain data text a routine can write as JSON: a paragraph, its runs alone, one link, the empty test, and the two types | [#paragraph](https://ui.atelic.me/#paragraph) |
44
44
  | `ArtifactShell` | `@atelic-action/ui/artifact` | The chrome around a document page: skip link, dark header, credit band, watermark | [#site-header](https://ui.atelic.me/#site-header) (its dark bar) |
45
45
  | `AppErrorBoundary`, `ErrorFallback` | `@atelic-action/ui/artifact` | The error boundary and the page it falls back to | none |
@@ -338,7 +338,7 @@ The two pieces a reader sees are ordinary components, in `@atelic-action/ui/comp
338
338
 
339
339
  `@atelic-action/ui/artifact` is the pieces an artifact document is built from and the site around it, so a fix to a piece reaches every business's documents with one version bump. The composed documents themselves (`Writeup`, `Read`, `Report`, `Note`, and the sealed `Gate`, with their content types and their stylesheet) live in [`@atelic-action/artifact`](https://github.com/atelic-action/artifact) since 2.0.0, which depends on this package for everything below:
340
340
 
341
- - **The pieces:** `GradeChip` and `gradeLabel` with the `WriteupGrade` type, `SignOff` with the `WriteupPerson` type, `Shot` with the `WriteupShot` type, and the plain data text (`Paragraph`, `Runs`, `ArtifactAnchor`, and `isEmpty`, with the `ArtifactLink` and `ArtifactParagraph` types: a paragraph is a string or runs of text and `{ text, href }` links, so a routine can write a document as JSON).
341
+ - **The pieces:** `GradeChip` and `gradeLabel` with the `WriteupGrade` type, `SignOff` with the `WriteupPerson` type, `Shot` with the `WriteupShot` type (a crop taller than it is wide is measured in the browser, marked `data-portrait`, and held to 200px wide on screen and 1.8in in print; a layout that sizes its shots itself sets `--op-shot-portrait-max: none` to opt out, on screen and in print alike), and the plain data text (`Paragraph`, `Runs`, `ArtifactAnchor`, and `isEmpty`, with the `ArtifactLink` and `ArtifactParagraph` types: a paragraph is a string or runs of text and `{ text, href }` links, so a routine can write a document as JSON).
342
342
  - **The shell:** `ArtifactShell`, the `.atelic-ui` scope with the skip link, the dark header, the credit band, and the watermark around a page.
343
343
  - **The contract and the head:** the `ArtifactConfig` types, and `buildPageHead` and `canonicalURL` with their `PageMeta` type.
344
344
  - **Who opened it:** `mintToken`, `sealReader`, `openReader`, `readerId`, `readerLink`, and `whoIsReading`. The same six are also built and exported alone as `@atelic-action/ui/artifact/readers`, because a Playwright spec and a script run under Node, which compiles nothing inside `node_modules`.
@@ -705,7 +705,7 @@ The blocks a page composes, each styled in `styles/components.css` inside the `a
705
705
  | `IconList` | A list whose bullets are icons | `icon` and `tone` on the list set every bullet; an item's own override them. The bullet is decoration, so a screen reader hears only the items. A dot when no icon is set; the text's color when no tone is |
706
706
  | `ReportCard` | A name, a grade, and one line on it per row, in labeled groups, each row's parts centered on it | A row with `href` is a link from edge to edge with a chevron at its end; a link inside `line` still goes where it points. `before` sets the earlier grade faded beside the grade; no `grade` draws a dash read as not graded. `legend` explains the letters beside the `title`, or under the card with `legendAt="foot"`; `labels` sets the screen reader's words. The grade is `GradeChip` |
707
707
  | `Rank` | A figure with its badge, for a table cell | `figure` is the rank, the place, or a dash for none; `tone` colors the badge and `meaning` names it for a screen reader; `href` links the figure, in a new tab with `newTab`. The figure's slot is a fixed width, so the badges line up down a column |
708
- | `DataTable` | A table whose first column names each row, sortable by any column marked `sortable` | A click on a heading sorts on a wide screen. On a phone each row stacks, every fact wearing its column's label, and a dropdown sorts. A cell is a node, or `{ display, sort }` when what it shows is not what it sorts by; a formatted number in a string (`"$12,047"`, `"0.24%"`) sorts as a number. It renders in `defaultSort` on the server. Every other row sits on a tinted ground; `striped={false}` turns that off. A column marked `fit` hugs its content, for a swatch or a mark beside a figure. A column with a `hint` draws a `Hint` beside its heading, before the label when the column is right aligned; on a phone the heading row is hidden, so the hint is too |
708
+ | `DataTable` | A table whose first column names each row, sortable by any column marked `sortable` | A click on a heading sorts on a wide screen. On a phone each row stacks, every fact wearing its column's label, and a dropdown sorts. A cell is a node, or `{ display, sort }` when what it shows is not what it sorts by; a formatted number in a string (`"$12,047"`, `"0.24%"`) sorts as a number. It renders in `defaultSort` on the server. Every other row sits on a tinted ground; `striped={false}` turns that off. A column marked `fit` hugs its content, for a swatch or a mark beside a figure. A column with a `hint` draws a `Hint` beside its heading, before the label when the column is right aligned; on a phone the heading row is hidden, so the hint is too. A cell given as `null` or `undefined`, or left out of a short row, is empty: it draws a short gray rule, the `.data-table-empty` class, which a screen reader hears as "None" or as the column's `emptyLabel`, and it sorts last whichever way the column runs. The first cell names the row, so it is never drawn as empty; give every row a name. A typed string is always content, a dash included, so type nothing for an empty cell. A document may wear `.data-table-empty` for its own neutral mark, so every empty cell reads the same |
709
709
  | `Hint` | An info icon that opens a short explainer beside a word | Opens on hover or focus, stays open on a click or a tap, closes on Escape or a tap elsewhere. The bubble opens from the icon's left edge and slides left when it would run off the screen. `side="before"` puts the icon before its word, for a right aligned heading. `label` is what a screen reader calls the button; the bubble is its description. Print hides it |
710
710
  | `StatRow` | A row of large figures, each over what it counts and its `period`. `variant="quiet"` is the glance row for a working page: a light figure in the text color over a small capitalized label, hairlines between; `unit` sets a figure's unit small beside it | `trend` draws an arrow before a figure that is itself a change. `deltas` list comparisons beneath: an arrow, how far, against what (`basis`), and the earlier figure (`was`), each in its own tone, since a spend falling and a cost falling read differently |
711
711
  | `Callout` | One finding: an icon in its tone beside the title, the explainer under it | `variant="box"` sets it apart on a tinted ground, for something missing or owed |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atelic-action/ui",
3
- "version": "3.7.0",
3
+ "version": "3.9.1",
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",
@@ -1,4 +1,5 @@
1
1
  import { Maximize2 } from "lucide-react";
2
+ import { useEffect, useRef, useState } from "react";
2
3
  import { newTabProps } from "../lib/newTabProps";
3
4
 
4
5
  export interface WriteupShot {
@@ -10,6 +11,12 @@ export interface WriteupShot {
10
11
  caption: string;
11
12
  }
12
13
 
14
+ /** The src of a loaded image taller than it is wide; null for any other. */
15
+ function portraitSrcOf(img: HTMLImageElement): string | null {
16
+ if (!img.naturalWidth || !img.naturalHeight) return null;
17
+ return img.naturalHeight > img.naturalWidth ? img.getAttribute("src") : null;
18
+ }
19
+
13
20
  /**
14
21
  * The owner's own screen: the crop, opening the full screenshot in a new tab
15
22
  * when it has one, over its caption. The writeup, the read, and the note in
@@ -18,21 +25,50 @@ export interface WriteupShot {
18
25
  * own sheet. A linked crop says it opens: a hover title, and an expand badge
19
26
  * hidden by default that a document may turn on (the note does, on its
20
27
  * thumbnails).
28
+ *
29
+ * A crop taller than it is wide (a phone screen) marks the figure
30
+ * `data-portrait`, and the base sheet holds it far narrower than its column.
31
+ * The mark is measured in the browser, after the image has a size: on load,
32
+ * or in an effect when the image finished loading before hydration, so the
33
+ * prerendered page carries no mark and nothing reads the window at render.
21
34
  */
22
35
  export function Shot({ shot }: { shot: WriteupShot }) {
36
+ const img = useRef<HTMLImageElement>(null);
37
+ // The src the portrait mark was measured on, so a new src never wears the
38
+ // last image's mark while it loads or if it fails.
39
+ const [portraitSrc, setPortraitSrc] = useState<string | null>(null);
40
+ const portrait = portraitSrc !== null && portraitSrc === shot.src;
41
+
42
+ // An image that loaded before hydration fired its load event before React
43
+ // was listening, so read its size once on mount. A later src change fires
44
+ // load again, which the handler below measures.
45
+ useEffect(() => {
46
+ const current = img.current;
47
+ if (current?.complete) setPortraitSrc(portraitSrcOf(current));
48
+ }, []);
49
+
50
+ const picture = (
51
+ <img
52
+ ref={img}
53
+ src={shot.src}
54
+ alt={shot.alt}
55
+ loading="lazy"
56
+ onLoad={(event) => setPortraitSrc(portraitSrcOf(event.currentTarget))}
57
+ onError={() => setPortraitSrc(null)}
58
+ />
59
+ );
60
+
23
61
  return (
24
- <figure className="op-shot">
62
+ <figure className="op-shot" data-portrait={portrait ? "" : undefined}>
25
63
  {shot.href ? (
26
64
  <a href={shot.href} title="Open the full picture" {...newTabProps(shot.href, true)}>
27
- <img src={shot.src} alt={shot.alt} loading="lazy" />
65
+ {picture}
28
66
  <span className="op-shot-open" aria-hidden="true">
29
67
  <Maximize2 size={12} />
30
68
  </span>
31
69
  </a>
32
70
  ) : (
33
- <span className="op-shot-frame">
34
- <img src={shot.src} alt={shot.alt} loading="lazy" />
35
- </span>
71
+ <span className="op-shot-frame">{picture}</span>
36
72
  )}
37
73
  <figcaption>{shot.caption}</figcaption>
38
74
  </figure>
@@ -27,7 +27,11 @@ export interface SiteShellProps {
27
27
  basePath?: string;
28
28
  /** The header's links. Defaults to `site.nav`; the footer lists the same ones. */
29
29
  nav?: NavItem[];
30
- /** Home style pages with a full bleed hero get a transparent header. */
30
+ /**
31
+ * Home style pages with a full bleed hero get a transparent header, and
32
+ * their hero sits under it. Every other page starts below the fixed
33
+ * header: `<main>` clears it here, once, so no section has to.
34
+ */
31
35
  heroNav?: boolean;
32
36
  /**
33
37
  * A page that closes on its own ask turns the mobile booking bar off,
@@ -109,7 +113,9 @@ export function SiteShell({
109
113
  hideCTA={hideNavCTA}
110
114
  contact={{ phone: site.phone, email: site.email, address: site.address }}
111
115
  />
112
- <main id="main">{children}</main>
116
+ <main id="main" className={heroNav ? undefined : "clears-nav"}>
117
+ {children}
118
+ </main>
113
119
  {stickyCTA && <StickyCTABar primaryCTA={cta} phone={site.phone} />}
114
120
  {footer ? (
115
121
  <Footer
@@ -20,6 +20,8 @@ export interface DataTableColumn {
20
20
  hint?: ReactNode;
21
21
  /** What a screen reader calls the hint's button; defaults to "About" and the label. */
22
22
  hintLabel?: string;
23
+ /** What a screen reader hears for an empty cell in this column; defaults to "None". */
24
+ emptyLabel?: string;
23
25
  }
24
26
 
25
27
  /** A cell whose display is not what it sorts by, e.g. an icon over a number. */
@@ -28,6 +30,12 @@ export interface DataTableValueCell {
28
30
  sort: number | string;
29
31
  }
30
32
 
33
+ /**
34
+ * A cell is a node, or a value cell. `null` or `undefined`, or a cell left
35
+ * out, is an empty cell: it draws a short gray rule and sorts last either way.
36
+ * A string is always content, a typed dash included, since a dash can mean
37
+ * "unchanged".
38
+ */
31
39
  export type DataTableCell = ReactNode | DataTableValueCell;
32
40
 
33
41
  export interface DataTableRow {
@@ -53,6 +61,11 @@ function isValueCell(cell: DataTableCell): cell is DataTableValueCell {
53
61
  return typeof cell === "object" && cell !== null && "sort" in cell && "display" in cell;
54
62
  }
55
63
 
64
+ /** No value to show. The first cell names the row, so it is never empty. */
65
+ function isEmpty(cell: DataTableCell, column: number): boolean {
66
+ return column !== 0 && (cell === null || cell === undefined);
67
+ }
68
+
56
69
  function sortValue(cell: DataTableCell): number | string {
57
70
  if (isValueCell(cell)) return cell.sort;
58
71
  if (typeof cell === "number") return cell;
@@ -94,10 +107,13 @@ export function DataTable({
94
107
  if (!sort) return indexed;
95
108
  const direction = sort.direction === "asc" ? 1 : -1;
96
109
  return indexed.sort((a, b) => {
97
- const order = compare(
98
- sortValue(a.row.cells[sort.column]),
99
- sortValue(b.row.cells[sort.column]),
100
- );
110
+ const cellA = a.row.cells[sort.column];
111
+ const cellB = b.row.cells[sort.column];
112
+ // An empty cell sorts last whichever way the column runs.
113
+ const emptyA = isEmpty(cellA, sort.column);
114
+ const emptyB = isEmpty(cellB, sort.column);
115
+ if (emptyA || emptyB) return emptyA === emptyB ? a.index - b.index : emptyA ? 1 : -1;
116
+ const order = compare(sortValue(cellA), sortValue(cellB));
101
117
  return order === 0 ? a.index - b.index : order * direction;
102
118
  });
103
119
  }, [rows, sort]);
@@ -194,8 +210,21 @@ export function DataTable({
194
210
  <tbody>
195
211
  {sorted.map(({ row, index }) => (
196
212
  <tr key={index} data-tone={row.tone}>
197
- {row.cells.map((cell, c) => {
198
- const body = isValueCell(cell) ? cell.display : cell;
213
+ {/* One cell per column at least, so a cell left out draws as empty. */}
214
+ {Array.from({ length: Math.max(columns.length, row.cells.length) }, (_, c) => {
215
+ const cell = row.cells[c];
216
+ const body = isEmpty(cell, c) ? (
217
+ <>
218
+ <span className="data-table-empty" aria-hidden="true" />
219
+ <span className="data-table-empty-label">
220
+ {columns[c]?.emptyLabel ?? "None"}
221
+ </span>
222
+ </>
223
+ ) : isValueCell(cell) ? (
224
+ cell.display
225
+ ) : (
226
+ cell
227
+ );
199
228
  const shape = {
200
229
  "data-align": columns[c]?.align ?? "left",
201
230
  "data-fit": columns[c]?.fit || undefined,
@@ -79,6 +79,10 @@ function Clip({
79
79
  // A pause that interrupts a pending play rejects it with an AbortError;
80
80
  // that is the reader scrolling past, not autoplay being refused.
81
81
  let observer: IntersectionObserver | undefined;
82
+ // React sets muted as a property and never renders the attribute, and an
83
+ // iPhone browser's autoplay check reads the attribute, so set both.
84
+ video.muted = true;
85
+ video.setAttribute("muted", "");
82
86
  const play = () =>
83
87
  video.play()?.catch((err: unknown) => {
84
88
  if ((err as { name?: string } | null)?.name === "AbortError") return;
@@ -144,17 +148,15 @@ function Figure({ block, withBase }: { block: ProseBlock; withBase: (path: strin
144
148
 
145
149
  if (!src) {
146
150
  return (
147
- <figure className="pb-figure">
148
- <div className="ph" style={tileStyle(block.width, block.height)}>
149
- {block.alt ?? "Figure"}
150
- </div>
151
+ <figure className="pb-figure" style={tileStyle(block.width, block.height)}>
152
+ <div className="ph">{block.alt ?? "Figure"}</div>
151
153
  {block.caption ? <figcaption className="pb-caption">{block.caption}</figcaption> : null}
152
154
  </figure>
153
155
  );
154
156
  }
155
157
 
156
158
  return (
157
- <figure className="pb-figure">
159
+ <figure className="pb-figure" style={tileStyle(block.width, block.height)}>
158
160
  {/* biome-ignore lint/a11y/useKeyWithClickEvents: the backdrop click is a pointer shortcut; the dialog closes on Escape natively and has a close button */}
159
161
  <dialog
160
162
  ref={dialogRef}
@@ -206,7 +208,6 @@ function Figure({ block, withBase }: { block: ProseBlock; withBase: (path: strin
206
208
  <button
207
209
  type="button"
208
210
  className="pb-tile"
209
- style={tileStyle(block.width, block.height)}
210
211
  aria-label={`Open larger: ${label}`}
211
212
  onClick={() => {
212
213
  setReduceMotion(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? false);
@@ -109,10 +109,24 @@
109
109
  line-height: 1.45;
110
110
  color: var(--op-ink-faint, var(--neutral-500));
111
111
  }
112
+ /* A portrait crop (a phone screen, marked by Shot once its image has a
113
+ size) is held far narrower than its column, at the column's start, so
114
+ it never stands as a tall wall beside its findings. The cap is on the
115
+ figure, so the frame, its border, and the caption all hug the picture.
116
+ A layout that sizes its shots itself (fixed frames side by side) sets
117
+ --op-shot-portrait-max to none to keep them all the same size. The one
118
+ property governs print as well; a document that sets a size of its own
119
+ restates it under @media print for the sheet. */
120
+ .atelic-ui .op-shot[data-portrait] {
121
+ max-width: var(--op-shot-portrait-max, 200px);
122
+ }
112
123
  @media print {
113
124
  .atelic-ui .op-shot a {
114
125
  cursor: auto;
115
126
  }
127
+ .atelic-ui .op-shot[data-portrait] {
128
+ max-width: var(--op-shot-portrait-max, 1.8in);
129
+ }
116
130
  }
117
131
 
118
132
  /* ---- print: the shell's chrome steps aside on every artifact page ----
@@ -66,6 +66,13 @@
66
66
  }
67
67
 
68
68
  /* ---- Header ---- */
69
+ /* The page starts below the fixed header, cleared once here rather than by
70
+ each opening section. A page with a full bleed hero (heroNav) leaves it
71
+ off, so the hero runs under the transparent header. */
72
+ .atelic-ui main.clears-nav {
73
+ padding-top: var(--nav-height, 72px);
74
+ }
75
+
69
76
  /* Fixed header: transparent over a hero, solid once scrolled, or dark. */
70
77
  .atelic-ui .nav {
71
78
  position: fixed;
@@ -16,7 +16,7 @@
16
16
  channels there) sets the `--ui-` names and leaves its own alone. */
17
17
  @layer atelic-ui {
18
18
  .atelic-ui .not-found-hero {
19
- padding-top: calc(var(--nav-height, 72px) + clamp(40px, 7vw, 86px));
19
+ padding-top: clamp(40px, 7vw, 86px);
20
20
  padding-bottom: clamp(28px, 5vw, 60px);
21
21
  }
22
22
  .atelic-ui .not-found-hero h1 {
@@ -1042,6 +1042,27 @@
1042
1042
  text-transform: uppercase;
1043
1043
  color: var(--neutral-500);
1044
1044
  }
1045
+ /* An empty cell's dash: a short gray rule, never a typed character. A
1046
+ document may wear the class for its own neutral mark. Drawn as a
1047
+ border, since a print drops backgrounds by default. */
1048
+ .atelic-ui .data-table-empty {
1049
+ display: inline-block;
1050
+ width: 14px;
1051
+ height: 0;
1052
+ vertical-align: 0.3em;
1053
+ border-top: 1.5px solid var(--neutral-300);
1054
+ }
1055
+ .atelic-ui .data-table-empty-label {
1056
+ position: absolute;
1057
+ width: 1px;
1058
+ height: 1px;
1059
+ margin: -1px;
1060
+ padding: 0;
1061
+ overflow: hidden;
1062
+ clip: rect(0, 0, 0, 0);
1063
+ white-space: nowrap;
1064
+ border: 0;
1065
+ }
1045
1066
  @media print, (min-width: 721px) {
1046
1067
  .atelic-ui .data-table-sort {
1047
1068
  display: none;
@@ -245,24 +245,30 @@
245
245
  }
246
246
  }
247
247
 
248
+ /* The figure carries the tile's shape (its aspect ratio, inline) at the
249
+ row's height, so the flex row sizes it to the file. Set on the inner
250
+ button instead, WebKit (every iPhone browser) stretched the figure to the
251
+ row's width while the button stayed narrow, so the caption's shade ran
252
+ across empty space. */
248
253
  .atelic-ui .pb-figure {
249
254
  position: relative;
255
+ flex: 0 0 auto;
250
256
  margin: 0;
251
257
  height: var(--pb-tile-height);
252
258
  min-width: 0;
253
259
  max-width: 100%;
254
260
  }
255
261
 
256
- /* A placeholder keeps its own look and takes only the tile's shape. */
262
+ /* A placeholder keeps its own look and fills the figure. */
257
263
  .atelic-ui .pb-figure .ph {
264
+ width: 100%;
258
265
  height: 100%;
259
- max-width: 100%;
260
266
  }
261
267
 
262
268
  .atelic-ui .pb-tile {
263
269
  display: block;
270
+ width: 100%;
264
271
  height: 100%;
265
- max-width: 100%;
266
272
  padding: 0;
267
273
  border: 0;
268
274
  border-radius: 12px;
@@ -65,7 +65,12 @@
65
65
 
66
66
  /* ---- BlogPost (blog-post.css) ---- */
67
67
  /* A single article. The title is the content, so it sits in the flow rather
68
- than inside a hero band that would push the writing below the fold. */
68
+ than inside a hero band that would push the writing below the fold. The
69
+ shell clears the fixed header; the article sits as close under it as a
70
+ page hero's content does. */
71
+ .atelic-ui .blog-post {
72
+ padding-top: clamp(32px, 6vw, 64px);
73
+ }
69
74
 
70
75
  /* The article takes the site's own width, like every other page, so no
71
76
  page or site wears a column of its own size (Forni, 2026-10-26). The
@@ -678,7 +683,7 @@
678
683
 
679
684
  /* ---- PageHero (page-hero.css) ---- */
680
685
  .atelic-ui .page-hero {
681
- padding-top: calc(var(--nav-height) + clamp(40px, 7vw, 86px));
686
+ padding-top: clamp(40px, 7vw, 86px);
682
687
  padding-bottom: clamp(28px, 5vw, 60px);
683
688
  background: var(--surface-alt);
684
689
  }