@atelic-action/ui 1.1.0 → 2.0.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.
@@ -1,406 +0,0 @@
1
- import { ArrowUpRight } from "lucide-react";
2
- import { newTabProps } from "../lib/newTabProps";
3
- import { GradeChip, gradeLabel, type WriteupGrade } from "./GradeChip";
4
- import { type ArtifactLink, type ArtifactParagraph, isEmpty, Paragraph, Runs } from "./Paragraph";
5
- import { Shot, type WriteupShot } from "./Shot";
6
- import { SignOff, type WriteupPerson } from "./SignOff";
7
-
8
- /**
9
- * The read: what a customer gets at the end of an engagement's first week,
10
- * before anything changes. Where the writeup says what letter each section
11
- * earned, the read says why, and what changes. Its shape is the practice's
12
- * FOOTPRINT.md, under What the Owner Gets: a title and a dated lede; the gist
13
- * table (every section, its grade, and one line); then the tiers, each
14
- * section a question in three beats (what we found, why, what changes) with
15
- * any proof pictures and the tools it was read from; then the plan, in order;
16
- * then one closing line and the sign off.
17
- *
18
- * It is the writeup's sibling, not a variant: it wears the writeup's column,
19
- * head, grade chip and key, tier heading, section card, screen, sources, and
20
- * close (the `.op` classes), and adds only what is its own (the `.rd`
21
- * classes). The gist table is drawn from the tiers, so a tier added later
22
- * (Conversion, once the analytics access lands) is one more entry in `tiers`
23
- * and appears in the table and the body alike, with no change to the props.
24
- * Every prop is plain data, so a routine can write a read as JSON; the one
25
- * exception is the sign off person's `role`, which takes a node and is
26
- * equally happy with a string.
27
- */
28
-
29
- /** A link inside running text: the words the reader clicks and where they go. */
30
- export type ReadLink = ArtifactLink;
31
-
32
- /** A paragraph: a plain string, or runs of text and links in order. */
33
- export type ReadParagraph = ArtifactParagraph;
34
-
35
- /** A place a reading came from: the tool, opened in a new tab when it has an address. */
36
- export interface ReadSource {
37
- label: string;
38
- href?: string;
39
- }
40
-
41
- /** One section of a tier: a question in three beats. */
42
- export interface ReadSection {
43
- /** The anchor the gist table links to, e.g. "technical-seo". */
44
- id: string;
45
- /** The section's trade name, e.g. "Technical SEO": the gist table's Section column, and the line over the question. */
46
- name: string;
47
- /** The question the section answers, in the owner's words, e.g. "Can Google read the site?". The section's heading. */
48
- question: string;
49
- /** The baseline's grade. Omit for a section not yet graded; the table shows a quiet dash. */
50
- grade?: WriteupGrade;
51
- /** The one line in the gist table. */
52
- gist: ReadParagraph;
53
- /** What we found: one paragraph or more. */
54
- found: ReadParagraph[];
55
- /** A few concrete examples of what was found, as a short list under it. */
56
- examples?: ReadParagraph[];
57
- /** Proof pictures, each over its caption, e.g. a search result capture per market. */
58
- shots?: WriteupShot[];
59
- /** Why, in one sentence, set apart. */
60
- why: ReadParagraph;
61
- /** What changes: one paragraph or more. */
62
- changes: ReadParagraph[];
63
- /** The tools the readings came from, linked, so the owner can open them. */
64
- sources?: ReadSource[];
65
- }
66
-
67
- /** A tier, e.g. Health: its heading, the question it answers, and its sections in order. */
68
- export interface ReadTier {
69
- /** The anchor a header stop points at, e.g. "health". */
70
- id?: string;
71
- /** The tier's name, e.g. "Health". */
72
- title: string;
73
- /** The question the tier answers, in the owner's words. */
74
- lead?: string;
75
- sections: ReadSection[];
76
- }
77
-
78
- /** One step of the plan: a bold title and a sentence or two. */
79
- export interface ReadStep {
80
- title: string;
81
- body?: ReadParagraph;
82
- /** Whose step it is when it is not the practice's, e.g. "Yours" or a name; set beside the title. */
83
- who?: string;
84
- }
85
-
86
- /** The plan: the steps in order, numbered. */
87
- export interface ReadPlan {
88
- /** The anchor a header stop points at, e.g. "plan". */
89
- id?: string;
90
- /** The heading; defaults to the `plan` label. */
91
- title?: string;
92
- /** A line over the steps. */
93
- lead?: ReadParagraph;
94
- steps: ReadStep[];
95
- }
96
-
97
- /** The close: one line, then the sign off. */
98
- export interface ReadClose {
99
- /** One sentence, e.g. what follows and when. */
100
- line: ReadParagraph;
101
- signOff?: string;
102
- person?: WriteupPerson;
103
- }
104
-
105
- /** The fixed words the page sets, each overridable. */
106
- export interface ReadLabels {
107
- /** The gist table's first column. */
108
- section: string;
109
- /** The gist table's second column. */
110
- grade: string;
111
- /** The gist table's third column. */
112
- gist: string;
113
- /** What a screen reader hears for a section with no grade. */
114
- notGraded: string;
115
- found: string;
116
- why: string;
117
- changes: string;
118
- /** The label over a section's tools. */
119
- sources: string;
120
- /** The plan's heading when it names none. */
121
- plan: string;
122
- }
123
-
124
- export const readLabels: ReadLabels = {
125
- section: "Section",
126
- grade: "Grade",
127
- gist: "The Gist",
128
- notGraded: "Not graded yet",
129
- found: "What We Found",
130
- why: "Why",
131
- changes: "What Changes",
132
- sources: "Sources",
133
- plan: "The Plan",
134
- };
135
-
136
- export interface ReadProps {
137
- title: string;
138
- /** The business, set in the dateline. */
139
- preparedFor: string;
140
- /** The ISO date, e.g. "2026-10-16". */
141
- date: string;
142
- /** Two or three sentences under the title. */
143
- lede: ReadParagraph;
144
- /** The heading over the gist table, e.g. "At a Glance". */
145
- gistTitle?: string;
146
- /** The key: what each letter means, in a few words each. */
147
- gradeKey?: Array<{ grade: WriteupGrade; label: string }>;
148
- /** The tiers in order. Each section appears in the gist table and in the body. */
149
- tiers: ReadTier[];
150
- plan: ReadPlan;
151
- close: ReadClose;
152
- labels?: Partial<ReadLabels>;
153
- }
154
-
155
- function Sources({ sources, label }: { sources: ReadSource[]; label: string }) {
156
- return (
157
- <footer className="op-sources">
158
- <span className="op-sources-label">{label}</span>
159
- <ul>
160
- {sources.map((source) => (
161
- <li key={source.label}>
162
- {source.href ? (
163
- <a href={source.href} {...newTabProps(source.href, true)}>
164
- {source.label}
165
- <ArrowUpRight size={12} aria-hidden="true" />
166
- </a>
167
- ) : (
168
- source.label
169
- )}
170
- </li>
171
- ))}
172
- </ul>
173
- </footer>
174
- );
175
- }
176
-
177
- function Gist({
178
- tiers,
179
- title,
180
- gradeKey,
181
- labels,
182
- }: {
183
- tiers: ReadTier[];
184
- title?: string;
185
- gradeKey?: ReadProps["gradeKey"];
186
- labels: ReadLabels;
187
- }) {
188
- return (
189
- <section className="rd-gist" aria-label={title ? undefined : labels.gist}>
190
- {(title || gradeKey) && (
191
- <div className="op-ov-head">
192
- {title && <h2 className="op-ov-title">{title}</h2>}
193
- {gradeKey && (
194
- <ul className="op-legend">
195
- {gradeKey.map((entry) => (
196
- <li key={entry.grade}>
197
- <GradeChip grade={entry.grade} />
198
- <span>{entry.label}</span>
199
- </li>
200
- ))}
201
- </ul>
202
- )}
203
- </div>
204
- )}
205
- <div className="rd-gist-card">
206
- <table className="rd-gist-table">
207
- <thead>
208
- <tr>
209
- <th scope="col" className="rd-gist-section">
210
- {labels.section}
211
- </th>
212
- <th scope="col" className="rd-gist-grade">
213
- {labels.grade}
214
- </th>
215
- <th scope="col" className="rd-gist-read">
216
- {labels.gist}
217
- </th>
218
- </tr>
219
- </thead>
220
- {tiers.map((tier) => (
221
- <tbody key={tier.title}>
222
- <tr className="rd-gist-tier">
223
- <th scope="rowgroup" colSpan={3}>
224
- {tier.title}
225
- </th>
226
- </tr>
227
- {tier.sections.map((section) => (
228
- <tr key={section.id}>
229
- <th scope="row" className="rd-gist-section">
230
- <a href={`#${section.id}`}>{section.name}</a>
231
- </th>
232
- <td className="rd-gist-grade">
233
- {section.grade ? (
234
- <>
235
- <span className="op-sr-only">{gradeLabel[section.grade]}</span>
236
- <span aria-hidden="true">
237
- <GradeChip grade={section.grade} />
238
- </span>
239
- </>
240
- ) : (
241
- <>
242
- <span className="op-sr-only">{labels.notGraded}</span>
243
- <span className="op-dash" aria-hidden="true" />
244
- </>
245
- )}
246
- </td>
247
- <td className="rd-gist-read">
248
- <Runs paragraph={section.gist} />
249
- </td>
250
- </tr>
251
- ))}
252
- </tbody>
253
- ))}
254
- </table>
255
- </div>
256
- </section>
257
- );
258
- }
259
-
260
- function Section({ section, labels }: { section: ReadSection; labels: ReadLabels }) {
261
- const found = section.found.filter((paragraph) => !isEmpty(paragraph));
262
- const changes = section.changes.filter((paragraph) => !isEmpty(paragraph));
263
- const shots = section.shots ?? [];
264
- return (
265
- <section className="op-topic rd-section" id={section.id}>
266
- <header className="op-topic-head">
267
- <div>
268
- <p className="rd-name">{section.name}</p>
269
- <h3>{section.question}</h3>
270
- </div>
271
- {section.grade && (
272
- <>
273
- <span className="op-sr-only">{`${labels.grade} ${gradeLabel[section.grade]}`}</span>
274
- <span className="rd-grade" aria-hidden="true">
275
- <GradeChip grade={section.grade} />
276
- </span>
277
- </>
278
- )}
279
- </header>
280
- <div className="rd-beat rd-found">
281
- <h4>{labels.found}</h4>
282
- {found.map((paragraph, i) => (
283
- // biome-ignore lint/suspicious/noArrayIndexKey: paragraphs are static content in a fixed order
284
- <Paragraph paragraph={paragraph} key={i} />
285
- ))}
286
- {section.examples && section.examples.length > 0 && (
287
- <ul className="rd-examples">
288
- {section.examples.map((example, i) => (
289
- // biome-ignore lint/suspicious/noArrayIndexKey: examples are static content in a fixed order
290
- <li key={i}>
291
- <Runs paragraph={example} />
292
- </li>
293
- ))}
294
- </ul>
295
- )}
296
- {shots.length > 0 && (
297
- <div className="rd-shots" data-count={Math.min(shots.length, 3)}>
298
- {shots.map((shot) => (
299
- <Shot shot={shot} key={shot.src} />
300
- ))}
301
- </div>
302
- )}
303
- </div>
304
- <div className="rd-beat rd-why">
305
- <h4>{labels.why}</h4>
306
- <Paragraph paragraph={section.why} />
307
- </div>
308
- <div className="rd-beat rd-changes">
309
- <h4>{labels.changes}</h4>
310
- {changes.map((paragraph, i) => (
311
- // biome-ignore lint/suspicious/noArrayIndexKey: paragraphs are static content in a fixed order
312
- <Paragraph paragraph={paragraph} key={i} />
313
- ))}
314
- </div>
315
- {section.sources && section.sources.length > 0 && (
316
- <Sources sources={section.sources} label={labels.sources} />
317
- )}
318
- </section>
319
- );
320
- }
321
-
322
- function Plan({ plan, labels }: { plan: ReadPlan; labels: ReadLabels }) {
323
- return (
324
- <section className="rd-plan" id={plan.id}>
325
- <h2>{plan.title ?? labels.plan}</h2>
326
- {plan.lead && !isEmpty(plan.lead) && (
327
- <Paragraph paragraph={plan.lead} className="rd-plan-lead" />
328
- )}
329
- <ol className="rd-steps">
330
- {plan.steps.map((step) => (
331
- <li className="rd-step" key={step.title}>
332
- <p>
333
- <b className="rd-step-title">{step.title}</b>
334
- {step.who && (
335
- <>
336
- {" "}
337
- <span className="rd-step-who">{step.who}</span>
338
- </>
339
- )}
340
- {step.body && !isEmpty(step.body) && (
341
- <>
342
- {" "}
343
- <Runs paragraph={step.body} />
344
- </>
345
- )}
346
- </p>
347
- </li>
348
- ))}
349
- </ol>
350
- </section>
351
- );
352
- }
353
-
354
- export function Read({
355
- title,
356
- preparedFor,
357
- date,
358
- lede,
359
- gistTitle,
360
- gradeKey,
361
- tiers,
362
- plan,
363
- close,
364
- labels: overrides,
365
- }: ReadProps) {
366
- const labels = { ...readLabels, ...overrides };
367
- const shownTiers = tiers.filter((tier) => tier.sections.length > 0);
368
- return (
369
- <div className="op rd">
370
- <article className="op-doc rd-doc">
371
- <header className="op-head">
372
- <p className="op-meta">
373
- Prepared for <b>{preparedFor}</b>
374
- <span className="op-meta-sep" aria-hidden="true">
375
- {" · "}
376
- </span>
377
- <span className="op-meta-date">{date}</span>
378
- </p>
379
- <h1>{title}</h1>
380
- {!isEmpty(lede) && <Paragraph paragraph={lede} className="op-intro rd-lede" />}
381
- </header>
382
- {shownTiers.length > 0 && (
383
- <Gist tiers={shownTiers} title={gistTitle} gradeKey={gradeKey} labels={labels} />
384
- )}
385
- {shownTiers.map((tier) => (
386
- <div className="rd-tier" key={tier.title}>
387
- <div className="op-part" id={tier.id}>
388
- <h2>{tier.title}</h2>
389
- {tier.lead && <p>{tier.lead}</p>}
390
- </div>
391
- {tier.sections.map((section) => (
392
- <Section section={section} labels={labels} key={section.id} />
393
- ))}
394
- </div>
395
- ))}
396
- {plan.steps.length > 0 && <Plan plan={plan} labels={labels} />}
397
- {!isEmpty(close.line) && <Paragraph paragraph={close.line} className="rd-closing" />}
398
- {close.signOff && close.person && (
399
- <footer className="op-close rd-close">
400
- <SignOff signOff={close.signOff} person={close.person} />
401
- </footer>
402
- )}
403
- </article>
404
- </div>
405
- );
406
- }
@@ -1,131 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import { GradeChip, type WriteupGrade } from "./GradeChip";
3
- import { SignOff, type WriteupPerson } from "./SignOff";
4
-
5
- /**
6
- * The monthly page: what an Operate client gets each month, as one printed
7
- * letter sheet and its hosted twin. Its shape is the practice's
8
- * FOOTPRINT.md, under What the Owner Gets: the title and the period, then
9
- * the leads block answering the four questions the Statement of Work
10
- * promises, in that order, each a figure and one plain sentence; then the
11
- * seven grades with what moved since last month and since the baseline; then
12
- * the sign off. It wears the writeup's grade chip and sign off, and the
13
- * artifact shell's header on screen; print drops the header and the credit
14
- * band, so the sheet is the document alone.
15
- */
16
-
17
- export interface ReportLead {
18
- /** The figure, e.g. "31 leads" or "$1,240". */
19
- figure: ReactNode;
20
- /** One plain sentence on what the figure means to the owner. */
21
- sentence: ReactNode;
22
- }
23
-
24
- /** The four questions, answered in this order on every monthly page. */
25
- export interface ReportLeads {
26
- cameIn: ReportLead;
27
- fromWhere: ReportLead;
28
- cost: ReportLead;
29
- closed: ReportLead;
30
- }
31
-
32
- export interface ReportGradeRow {
33
- /** The tier, e.g. "Health". */
34
- tier: string;
35
- /** The section's trade name, e.g. "Local SEO". */
36
- section: string;
37
- /** The grade this month: the one judgement, in full color. */
38
- now: WriteupGrade;
39
- /** The grade last month; omit on the first month. */
40
- lastMonth?: WriteupGrade;
41
- /** The grade in the baseline snapshot, the first taken on private sources. */
42
- baseline?: WriteupGrade;
43
- /** One line on what moved, in the owner's words. */
44
- moved: string;
45
- }
46
-
47
- export interface ReportProps {
48
- title: string;
49
- /** The period as printed, e.g. "September 2026". */
50
- period: string;
51
- leads: ReportLeads;
52
- /** The seven sections, in the footprint's order. */
53
- grades: ReportGradeRow[];
54
- /** The sign off, the same lockup the writeup closes on. */
55
- close: { signOff: string; person: WriteupPerson };
56
- }
57
-
58
- /**
59
- * The questions are the monthly page's contract with the Statement of Work,
60
- * the same on every client's page, so they live here rather than in content.
61
- */
62
- const QUESTIONS: { key: keyof ReportLeads; label: string }[] = [
63
- { key: "cameIn", label: "What Came In" },
64
- { key: "fromWhere", label: "From Where" },
65
- { key: "cost", label: "What It Cost" },
66
- { key: "closed", label: "What It Closed" },
67
- ];
68
-
69
- function Earlier({ grade, label }: { grade?: WriteupGrade; label: string }) {
70
- return (
71
- <td className="rp-earlier" data-label={label}>
72
- {grade && <GradeChip grade={grade} />}
73
- </td>
74
- );
75
- }
76
-
77
- export function Report({ title, period, leads, grades, close }: ReportProps) {
78
- let lastTier = "";
79
- return (
80
- <div className="rp">
81
- <article className="rp-sheet">
82
- <header className="rp-head">
83
- <div className="rp-period">{period}</div>
84
- <h1>{title}</h1>
85
- </header>
86
- <div className="rp-leads">
87
- {QUESTIONS.map(({ key, label }) => (
88
- <section className="rp-lead" key={key}>
89
- <h2 className="rp-q">{label}</h2>
90
- <div className="rp-figure">{leads[key].figure}</div>
91
- <p>{leads[key].sentence}</p>
92
- </section>
93
- ))}
94
- </div>
95
- <table className="rp-grades">
96
- <thead>
97
- <tr>
98
- <th scope="col">Tier</th>
99
- <th scope="col">Section</th>
100
- <th scope="col">Now</th>
101
- <th scope="col">Last Month</th>
102
- <th scope="col">Baseline</th>
103
- <th scope="col">What Moved</th>
104
- </tr>
105
- </thead>
106
- <tbody>
107
- {grades.map((row) => {
108
- const tier = row.tier === lastTier ? "" : row.tier;
109
- lastTier = row.tier;
110
- return (
111
- <tr key={row.section} className={tier ? "is-tier-start" : undefined}>
112
- <td className="rp-tier">{tier}</td>
113
- <td className="rp-section">{row.section}</td>
114
- <td className="rp-now" data-label="Now">
115
- <GradeChip grade={row.now} />
116
- </td>
117
- <Earlier grade={row.lastMonth} label="Last Month" />
118
- <Earlier grade={row.baseline} label="Baseline" />
119
- <td className="rp-moved">{row.moved}</td>
120
- </tr>
121
- );
122
- })}
123
- </tbody>
124
- </table>
125
- <footer className="rp-close">
126
- <SignOff signOff={close.signOff} person={close.person} />
127
- </footer>
128
- </article>
129
- </div>
130
- );
131
- }