@greenrenge/skills 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +99 -2
- package/bin/cli.mjs +525 -0
- package/bin/lib/onboard.mjs +1168 -0
- package/bin/lib/probe.mjs +631 -0
- package/catalog.json +590 -0
- package/package.json +50 -4
- package/skills/deck-story/SKILL.md +258 -0
- package/skills/deck-story/check-svg-text.mjs +94 -0
- package/skills/deck-story/check.mjs +348 -0
- package/skills/diagram-router/LICENSE +21 -0
- package/skills/diagram-router/SKILL.md +193 -0
- package/skills/diagram-router/THIRD_PARTY_NOTICES.md +15 -0
- package/skills/diagram-router/references/channels.md +213 -0
- package/skills/diagram-router/references/evals.md +85 -0
- package/skills/diagram-router/references/gathering.md +101 -0
- package/skills/diagram-router/references/prior-art.md +65 -0
- package/skills/diagram-router/references/routing.md +166 -0
- package/skills/diagram-router/skill-release.json +17 -0
- package/skills/frontend-design/SKILL.md +443 -0
- package/skills/frontend-design/references/rtl.md +72 -0
- package/skills/frontend-design/scripts/.upstream-sha +1 -0
- package/skills/frontend-design/scripts/LICENSE +21 -0
- package/skills/frontend-design/scripts/README.md +24 -0
- package/skills/frontend-design/scripts/gates.md +243 -0
- package/skills/frontend-design/scripts/sloplint-render.mjs +1283 -0
- package/skills/frontend-design/scripts/sloplint.mjs +4426 -0
- package/skills/open-code-review-rules/SKILL.md +59 -0
- package/skills/open-code-review-rules/references/ocr-allowlists.json +161 -0
- package/skills/open-code-review-rules/references/ocr-rule-semantics.md +39 -0
- package/skills/open-code-review-rules/scripts/verify_ocr_rules.py +836 -0
- package/skills/plain-english-mode/SKILL.md +41 -0
- package/skills/pr-diagram-portfolio/SKILL.md +75 -0
- package/skills/pr-diagram-portfolio/references/angle-framework.md +124 -0
- package/skills/pr-diagram-portfolio/references/portfolio-delivery.md +79 -0
- package/skills/pr-diagram-portfolio/scripts/restore_still_css.py +180 -0
- package/skills/pr-lens/LICENSE-upstream +21 -0
- package/skills/pr-lens/SKILL.md +99 -0
- package/skills/pr-lens/VENDOR.md +47 -0
- package/skills/pr-lens/package-lock.json +91 -0
- package/skills/pr-lens/package.json +9 -0
- package/skills/pr-lens/references/config.md +90 -0
- package/skills/pr-lens/references/example.graph.json +580 -0
- package/skills/pr-lens/references/graph-document.md +233 -0
- package/skills/pr-lens/skill-release.json +16 -0
- package/skills/security-remediation-epic/SKILL.md +316 -0
- package/skills/security-remediation-epic/prompt-template.md +33 -0
- package/skills/skill-maintainer/SKILL.md +99 -0
- package/skills/skill-maintainer/references/placement-and-coupling.md +43 -0
- package/skills/skill-maintainer/scripts/audit_skills.py +297 -0
- package/skills/t3-successor-handoff/SKILL.md +141 -0
- package/skills/t3-thread-bridge/SKILL.md +175 -0
- package/skills/t3-thread-bridge/references/launch-recipes.md +123 -0
- package/skills/t3-thread-bridge/references/ping-back.md +108 -0
- package/skills/t3-thread-bridge/scripts/thread_ledger.py +203 -0
- package/skills/t3-ticket-orchestrator/SKILL.md +304 -0
- package/skills/t3-ticket-orchestrator/references/proving-the-gates.md +63 -0
- package/skills/ticket-scheme/SKILL.md +144 -0
- package/skills/ulw-plan/SKILL.md +98 -0
- package/skills/ulw-plan/references/full-workflow.md +255 -0
- package/skills/ulw-plan/references/intent-clear.md +44 -0
- package/skills/ulw-plan/references/intent-unclear.md +44 -0
- package/skills/ulw-plan/scripts/plan-templates.mjs +180 -0
- package/skills/ulw-plan/scripts/scaffold-plan.mjs +187 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: deck-story
|
|
3
|
+
description: "Turn material into a deck a room can follow: a story spine, assertion titles, one idea per slide, a routed picture, a printable HTML deck, and a QA pass that renders and measures every slide. Use when asked to build a presentation, an orientation deck, slides for a session or a review, to story a talk, to cut a document down into slides, or to fix a deck that reads as too dense, too texty or badly laid out."
|
|
4
|
+
metadata:
|
|
5
|
+
short-description: Story a deck, cut it to one idea per slide, route its picture, then render and measure every slide
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Deck Story
|
|
9
|
+
|
|
10
|
+
A deck is a **pace**, not a document. The room reads faster than you speak, so every word on a
|
|
11
|
+
slide competes with your voice for the same channel. A deck that carries paragraphs loses that
|
|
12
|
+
competition and the room stops listening to either.
|
|
13
|
+
|
|
14
|
+
This skill builds the deck, and it separates two artefacts that are usually confused:
|
|
15
|
+
|
|
16
|
+
- **The deck** carries the story. One idea per slide, a picture where a picture helps.
|
|
17
|
+
- **The companion document** carries the detail and the evidence. Every claim, every command,
|
|
18
|
+
every citation.
|
|
19
|
+
|
|
20
|
+
If you find yourself writing prose for a slide, that prose belongs in the companion document.
|
|
21
|
+
Ship both.
|
|
22
|
+
|
|
23
|
+
## 1. The spine, before any slide exists
|
|
24
|
+
|
|
25
|
+
Write this first, in one sitting. The spine decides which slides exist.
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Once upon a time ___.
|
|
29
|
+
Every day ___.
|
|
30
|
+
One day ___.
|
|
31
|
+
Because of that ___.
|
|
32
|
+
Because of that ___.
|
|
33
|
+
Until finally ___.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
| Beat | The deck's job |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| Once upon a time | The world the audience already lives in |
|
|
39
|
+
| Every day | The status quo, plain enough that they nod |
|
|
40
|
+
| One day | What changed, or the question that breaks the status quo |
|
|
41
|
+
| Because of that | The first consequence, and the consequence of that |
|
|
42
|
+
| Because of that | The second consequence |
|
|
43
|
+
| Until finally | Where it lands, and what they do about it |
|
|
44
|
+
|
|
45
|
+
A slide that serves no beat is a fact you found interesting. Cut it.
|
|
46
|
+
|
|
47
|
+
Four lines travel with the spine, and they are the difference between a deck and a summary:
|
|
48
|
+
|
|
49
|
+
- **Why this story** — the belief underneath. This is the heart of it, and the reason you are
|
|
50
|
+
the one on stage.
|
|
51
|
+
- **The position** — a claim a reasonable person could disagree with. A deck nobody can
|
|
52
|
+
disagree with has not said anything, and a deck with no answer could have been an email.
|
|
53
|
+
- **The stakes** — what the room loses if they do nothing.
|
|
54
|
+
- **The ending, written first** — the final slide, verbatim. Endings are hard; get yours
|
|
55
|
+
working before the middle, or you build five sections toward a close that does not exist.
|
|
56
|
+
|
|
57
|
+
Two more moves worth the effort:
|
|
58
|
+
|
|
59
|
+
- **Admiration of the trying, not the winning.** Show the failed version, the constraint, the
|
|
60
|
+
thing that took three tries. Those are the slides people remember.
|
|
61
|
+
- **The coincidence rule.** A surprising fact may open a problem. It may never resolve one.
|
|
62
|
+
If a section ends with "and then it turned out fine", the slides did not earn it.
|
|
63
|
+
|
|
64
|
+
## 2. The slide
|
|
65
|
+
|
|
66
|
+
### The title is the message
|
|
67
|
+
|
|
68
|
+
An **assertion title** states the slide's finding. A **topic title** names the subject.
|
|
69
|
+
|
|
70
|
+
| Weak | Strong |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| Background | The verify environment was three setups, and CI knew only one |
|
|
73
|
+
| Results | The memory limit was measured, then written down |
|
|
74
|
+
| Architecture | The pod never sees the image bytes |
|
|
75
|
+
|
|
76
|
+
Rules for the title:
|
|
77
|
+
|
|
78
|
+
- It is the largest text on the slide, and it sits upper-left. Upper-left is where a
|
|
79
|
+
left-to-right audience looks first. Never bottom the title: the front row's heads cover
|
|
80
|
+
the bottom edge.
|
|
81
|
+
- One line, two at most. Spend the effort distilling.
|
|
82
|
+
- High contrast, clean font. The title is read at a glance, not studied.
|
|
83
|
+
- It is the sentence the slide concludes, not a label for what follows.
|
|
84
|
+
|
|
85
|
+
### One idea, and a word budget
|
|
86
|
+
|
|
87
|
+
- **One idea per slide.** Two ideas compete and the audience keeps one, usually the wrong one.
|
|
88
|
+
Split the slide.
|
|
89
|
+
- **Six elements** at most on a slide. Past six the cognitive load climbs sharply.
|
|
90
|
+
- **Fifty words** of prose at most, headline included; forty when the slide carries bullets.
|
|
91
|
+
A code block is not prose to be read aloud, but it counts against the slide's room.
|
|
92
|
+
- **One minute** per slide, so a 45-minute session with discussion lands around 18 slides.
|
|
93
|
+
Slides are free. Dense slides are not.
|
|
94
|
+
|
|
95
|
+
### The room can hear you
|
|
96
|
+
|
|
97
|
+
- **Left-align the text.** Centred text has no reading order and flattens the hierarchy.
|
|
98
|
+
Centre a graphic if you like; never centre a paragraph.
|
|
99
|
+
- **Equal margins.** The top margin equals the bottom margin, both 6 to 8 percent of the
|
|
100
|
+
slide's height; the sides 5 to 6 percent of its width. Unequal margins read as a mistake
|
|
101
|
+
even when nobody can say why.
|
|
102
|
+
- **Type scale**, in points on a 13.33 by 7.5 inch slide: 36 to 44 for the title, 24 to 28 for
|
|
103
|
+
body, 18 to 22 for supporting labels. If the type has to shrink to fit, the content is too
|
|
104
|
+
big.
|
|
105
|
+
- **Contrast**: 4.5:1 for body text, 3:1 for text at 24pt or larger. Measure it; do not
|
|
106
|
+
eyeball it.
|
|
107
|
+
- **White space is not waste.** It isolates the one thing that matters. A slide should be
|
|
108
|
+
quiet around its point.
|
|
109
|
+
- **Consistency**: one font family, one accent colour, one layout family. The layout should
|
|
110
|
+
change when the slide's job changes, and a run of identical layouts is a list pretending
|
|
111
|
+
to be a story.
|
|
112
|
+
|
|
113
|
+
### Keep the detail in the companion document
|
|
114
|
+
|
|
115
|
+
Every fact that does not earn its place on a slide goes in the companion file: the command
|
|
116
|
+
list, the citation, the table, the exception, the caveat. Link it from the deck once. The
|
|
117
|
+
room never reads the companion during the session, and that is the point.
|
|
118
|
+
|
|
119
|
+
## 3. The picture
|
|
120
|
+
|
|
121
|
+
A picture is worth drawing only when the reader learns more from it than from a paragraph.
|
|
122
|
+
|
|
123
|
+
> **Gate.** Would the reader learn more from this than from a well-written paragraph?
|
|
124
|
+
> If no, answer in text and stop. A list of things is a list; a one-shape diagram is a
|
|
125
|
+
> sentence.
|
|
126
|
+
|
|
127
|
+
Route the picture with the **`diagram-router`** skill, and say which discriminator decided
|
|
128
|
+
it. The short table:
|
|
129
|
+
|
|
130
|
+
| The picture is about | Owner |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| Cloud, brand logos, "where does it run" | `stack-diagram` |
|
|
133
|
+
| Values, series, comparisons, part-to-whole | `diagram-design` |
|
|
134
|
+
| A diff's mechanics, identical every run | `pr-lens` |
|
|
135
|
+
| Call order, behaviour, lifecycle, data model, a system as a whole | `archify` |
|
|
136
|
+
| Strategy, journey, narrative, process, editorial charts | `diagram-design` |
|
|
137
|
+
|
|
138
|
+
Rules that keep a picture honest:
|
|
139
|
+
|
|
140
|
+
- **Pick the form before the tool.** A request lifecycle is a sequence diagram. A request
|
|
141
|
+
journey is a workflow. A repository layout is a tree. A pipeline with a lineage break is a
|
|
142
|
+
dataflow. A set of services in a cloud is a stack diagram.
|
|
143
|
+
- **One skill owns one artefact.** Never mix two skills' visual languages in one picture.
|
|
144
|
+
- **Fidelity is a target, not a ceiling.** When the story needs more nodes than the channel
|
|
145
|
+
allows, raise the fidelity or split into overview and detail. A wrong picture cannot be
|
|
146
|
+
fixed later.
|
|
147
|
+
- **Label the shape, not the trivia.** Short labels; the detail lives in the companion
|
|
148
|
+
document.
|
|
149
|
+
- **Never invent a fact to fill a layout.** A picture with fewer claims beats a picture with
|
|
150
|
+
invented ones.
|
|
151
|
+
- **Say what you dropped.** The reader of the diagram cannot see what is missing; the person
|
|
152
|
+
who asked for it must.
|
|
153
|
+
|
|
154
|
+
## 4. The session
|
|
155
|
+
|
|
156
|
+
The deck is one part of a session. The strongest shape for a technical orientation:
|
|
157
|
+
|
|
158
|
+
1. **Slides** — the story, the concepts, the shape of the system.
|
|
159
|
+
2. **Demo** — the real thing running, once. Show what the slides claimed.
|
|
160
|
+
3. **Where to explore** — the paths, the commands, the documents. Resources, not a call to
|
|
161
|
+
action.
|
|
162
|
+
|
|
163
|
+
Inside the slides:
|
|
164
|
+
|
|
165
|
+
- Say what you are going to do before you do it.
|
|
166
|
+
- Focus on concepts, not code. The code is an implementation detail; what the audience wants
|
|
167
|
+
is what can only be read between the lines. Point at code, do not paste it.
|
|
168
|
+
- Keep the technology list to a minimum. Name what matters, move on.
|
|
169
|
+
- Explain the non-obvious details. The obvious ones need no slide.
|
|
170
|
+
- Write speaker notes with the exact transition sentence that bridges each slide to the next.
|
|
171
|
+
Each slide carries them as `<aside class="notes">`, which the deck hides and a key reveals;
|
|
172
|
+
the checker fails a deck whose slides have none. The shape follows reveal.js's speaker
|
|
173
|
+
notes, and its cost is forty lines of the deck's own JavaScript.
|
|
174
|
+
|
|
175
|
+
## 5. The QA pass
|
|
176
|
+
|
|
177
|
+
Render every slide and look at it. Automated checks passing is not the same as a slide that
|
|
178
|
+
reads well, and a slide that reads badly is the only thing the room ever sees.
|
|
179
|
+
|
|
180
|
+
| Check | The test | The fix |
|
|
181
|
+
| --- | --- | --- |
|
|
182
|
+
| 3-second | Parseable in three seconds at arm's length | Cut until it passes |
|
|
183
|
+
| One message | Exactly one idea; two means split | Split the slide |
|
|
184
|
+
| Spine beat | Which beat it serves | Cut a slide that serves none |
|
|
185
|
+
| Layout | Margins equal, text left, nothing overflowing | Fix the box, not the type size |
|
|
186
|
+
| Picture | Chosen by discriminator, legible at slide size | Re-route, or split the picture |
|
|
187
|
+
| Contrast | 4.5:1 body, 3:1 large text | Darken the text or the ground |
|
|
188
|
+
|
|
189
|
+
A deck read rather than presented is judged differently: substitute "makes sense forwarded
|
|
190
|
+
with no context" for the 3-second test.
|
|
191
|
+
|
|
192
|
+
Then the mechanical checks. **These are shipped with this skill — run them, do not
|
|
193
|
+
reimplement them.** A deck is one self-contained HTML file; both tools read it, and neither
|
|
194
|
+
opens a browser to do the arithmetic half.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
node check.mjs path/to/deck.html --svg-dir path/to/diagrams # the deck gate
|
|
198
|
+
node check-svg-text.mjs path/to/diagrams # the label gate
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
`check.mjs` enforces the table above where it is arithmetic, and nothing else:
|
|
202
|
+
|
|
203
|
+
| Rule | What it asserts | Severity |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| `budget/words` | ≤50 words of prose per slide | failure |
|
|
206
|
+
| `budget/elements` | ≤6 elements per slide | failure |
|
|
207
|
+
| `layout/margins` | top equals bottom; both in 5–9 %, sides in 4–7 % | failure |
|
|
208
|
+
| `layout/centred-body` | no paragraph or list over 2 lines or 120 characters is centred | failure |
|
|
209
|
+
| `contrast` | 4.5:1 for body text, 3:1 for text at 18pt or larger, measured against the ground the text actually sits on | failure |
|
|
210
|
+
| `layout/monotony` | no 4+ slides in a row share one layout | **note** — whether a run of identical layouts is a list pretending to be a story depends on the story. `--strict` makes it a failure |
|
|
211
|
+
| `content/empty-slide` | no slide without content | failure |
|
|
212
|
+
| `content/placeholder-text` | no leftover `[TBD]`-shaped prompt | failure |
|
|
213
|
+
| `content/duplicate-title` | no two slides share a headline | failure |
|
|
214
|
+
| `notes/missing` | every slide carries speaker notes | failure |
|
|
215
|
+
| `print/path` | a `@media print` rule exists | failure |
|
|
216
|
+
| `type/min-size` | content text is at least 18pt | **note** — the chrome is furniture and is exempt |
|
|
217
|
+
|
|
218
|
+
`check-svg-text.mjs` writes a report page and prints its path; open it and it names every
|
|
219
|
+
label that overflows its box or is painted over by a later box. SVG text is not clipped, so
|
|
220
|
+
an overlong label paints over whatever is drawn next.
|
|
221
|
+
|
|
222
|
+
Still yours to do by eye, because no tool can:
|
|
223
|
+
|
|
224
|
+
- Render every slide to an image and **look at every one**. A layout defect in slide 14 is
|
|
225
|
+
invisible in the source.
|
|
226
|
+
- Check the picture is legible at slide size, against the viewing distance, not the source.
|
|
227
|
+
- Check the print path actually reads as a handout. The tool asserts the rule exists; only
|
|
228
|
+
your eyes know whether it works.
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
## 6. Traps
|
|
232
|
+
|
|
233
|
+
| Symptom | Cause | Fix |
|
|
234
|
+
| --- | --- | --- |
|
|
235
|
+
| The room is reading instead of listening | Paragraphs on slides | Move the detail to the companion document |
|
|
236
|
+
| Every slide looks the same | One layout family | Change the layout when the job changes |
|
|
237
|
+
| The picture says nothing specific | Facts were never gathered | Gather before drawing |
|
|
238
|
+
| The deck is a summary | No position | Find the claim someone could disagree with |
|
|
239
|
+
| The title is a label | Topic title | Rewrite it as the finding |
|
|
240
|
+
| Two ideas on one slide | No split | Split it |
|
|
241
|
+
| It renders but reads as mush | Layout defect in the source | Look at the render, fix the box |
|
|
242
|
+
|
|
243
|
+
## Where these rules come from
|
|
244
|
+
|
|
245
|
+
The spine is Emma Coats' 22 rules of storytelling (Pixar), with the six-beat structure from
|
|
246
|
+
Kenn Adams' story spine. The assertion title and the glance test are Duarte's: the title is
|
|
247
|
+
the message, and the slide must be graspable in three seconds at a glance before the audience
|
|
248
|
+
returns to the presenter. The element and word budgets come from cognitive-load work on
|
|
249
|
+
technical slides (a 2021 review in *Current Protocols*, and the "presentation-design" agent
|
|
250
|
+
skill's limits of six elements and fifty words). The layout values — the 5–6 % side margins,
|
|
251
|
+
the 6–8 % top and bottom, the 36–44/24–28/18–22 type scale on a 13.33 by 7.5 inch slide —
|
|
252
|
+
come from OpenPresentation's slide-design principles
|
|
253
|
+
([openpresentation.org](https://openpresentation.org/), `docs/slide-design-principles.md`),
|
|
254
|
+
and the assertion-evidence method from the Harvard Writing Center. "Focus on concepts, not code" and the presentation-demo-resources
|
|
255
|
+
session shape come from Ricardo Ferreira's and Rossella Ferrandino's workshop write-ups.
|
|
256
|
+
|
|
257
|
+
Verify these rules against the artefact, not against this file. A deck that reads well is the
|
|
258
|
+
evidence.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Reports text that overflows the box it sits in, for every SVG under docs/onboarding/diagrams/.
|
|
3
|
+
//
|
|
4
|
+
// Text in an SVG is not clipped, so an overflowing line paints over whatever is drawn next.
|
|
5
|
+
// This finds those lines instead of leaving them to be discovered in a screenshot.
|
|
6
|
+
//
|
|
7
|
+
// node check-svg-text.mjs <dir-of-svgs>
|
|
8
|
+
//
|
|
9
|
+
// It writes a report page to the OS temp directory and prints the path. Open that page in a
|
|
10
|
+
// browser; it prints one line per offending text element, or "no overflow".
|
|
11
|
+
//
|
|
12
|
+
// SVG text is not clipped: an overlong label paints over whatever is drawn next. This
|
|
13
|
+
// finds those labels before a room does.
|
|
14
|
+
|
|
15
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
16
|
+
import { tmpdir } from 'node:os'
|
|
17
|
+
import { dirname, join, resolve } from 'node:path'
|
|
18
|
+
import { fileURLToPath } from 'node:url'
|
|
19
|
+
|
|
20
|
+
const here = dirname(fileURLToPath(import.meta.url))
|
|
21
|
+
const diagramsDir = resolve(process.argv[2] || join(here, 'diagrams'))
|
|
22
|
+
|
|
23
|
+
const files = (await readdir(diagramsDir)).filter((f) => f.endsWith('.svg')).sort()
|
|
24
|
+
const svgs = []
|
|
25
|
+
for (const name of files) {
|
|
26
|
+
svgs.push({ name, markup: await readFile(join(diagramsDir, name), 'utf8') })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const page = `<!doctype html>
|
|
30
|
+
<html><head><meta charset="utf-8"><title>onboarding svg text check</title></head>
|
|
31
|
+
<body><div id="host"></div><script>
|
|
32
|
+
const SVGS = ${JSON.stringify(svgs)};
|
|
33
|
+
const out = [];
|
|
34
|
+
for (const { name, markup } of SVGS) {
|
|
35
|
+
const doc = new DOMParser().parseFromString(markup, "image/svg+xml");
|
|
36
|
+
const svg = doc.documentElement;
|
|
37
|
+
document.getElementById("host").replaceChildren(svg);
|
|
38
|
+
const svgBB = svg.getBBox();
|
|
39
|
+
// Document order decides who paints over whom, so every drawn element carries its index.
|
|
40
|
+
const order = new Map();
|
|
41
|
+
let n = 0;
|
|
42
|
+
svg.querySelectorAll("rect,text,path,line,polyline,circle,ellipse").forEach((el) => order.set(el, n++));
|
|
43
|
+
const all = [...svg.querySelectorAll("rect")].map((r) => ({ r, bb: r.getBBox(), ord: order.get(r) }));
|
|
44
|
+
// The canvas is the ground, and the lane stripes and panels are decoration. A label that
|
|
45
|
+
// happens to start inside one of them is not inside its box, so none of them can be a
|
|
46
|
+
// text's container, and none of them can paint over a label.
|
|
47
|
+
const isGround = (o) => o.bb.width >= svgBB.width * 0.98 && o.bb.height >= svgBB.height * 0.98;
|
|
48
|
+
const isStripe = (o) => o.bb.width <= 24 && o.bb.height > o.bb.width * 3;
|
|
49
|
+
const isPanel = (o) => (o.r.getAttribute("class") || "").includes("c-lane");
|
|
50
|
+
const boxes = all.filter((o) => !isGround(o) && !isStripe(o) && !isPanel(o));
|
|
51
|
+
for (const t of svg.querySelectorAll("text")) {
|
|
52
|
+
const b = t.getBBox();
|
|
53
|
+
const x = b.x, y = b.y + b.height / 2;
|
|
54
|
+
// A container is a box that holds the whole label. When none does, the label runs past
|
|
55
|
+
// the box it starts in, and the box it starts in is the tightest that holds its start.
|
|
56
|
+
const encloses = boxes.filter((o) =>
|
|
57
|
+
b.x >= o.bb.x - 0.5 && b.x + b.width <= o.bb.x + o.bb.width + 0.5 &&
|
|
58
|
+
b.y >= o.bb.y - 0.5 && b.y + b.height <= o.bb.y + o.bb.height + 0.5);
|
|
59
|
+
if (!encloses.length) {
|
|
60
|
+
const starts = boxes.filter((o) =>
|
|
61
|
+
x >= o.bb.x && x <= o.bb.x + o.bb.width && y >= o.bb.y && y <= o.bb.y + o.bb.height);
|
|
62
|
+
if (starts.length) {
|
|
63
|
+
const host = starts.reduce((a, o) => (o.bb.width < a.bb.width ? o : a));
|
|
64
|
+
const over = b.x + b.width - (host.bb.x + host.bb.width);
|
|
65
|
+
if (over > 0.5) {
|
|
66
|
+
out.push(name + " :: " + JSON.stringify(t.textContent.slice(0, 70)) +
|
|
67
|
+
" overflows its box by " + over.toFixed(1) + "px");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// A box drawn after this label that the label runs into paints over it.
|
|
72
|
+
for (const o of boxes) {
|
|
73
|
+
if (o.ord <= order.get(t)) continue;
|
|
74
|
+
const bb = o.bb;
|
|
75
|
+
if (x >= bb.x && x <= bb.x + bb.width && y >= bb.y && y <= bb.y + bb.height) continue;
|
|
76
|
+
const overlaps = b.x < bb.x + bb.width && b.x + b.width > bb.x &&
|
|
77
|
+
b.y < bb.y + bb.height && b.y + b.height > bb.y;
|
|
78
|
+
if (overlaps) {
|
|
79
|
+
out.push(name + " :: " + JSON.stringify(t.textContent.slice(0, 70)) +
|
|
80
|
+
" is painted over by a later box");
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
document.title = "RESULT:" + out.length;
|
|
87
|
+
document.body.innerHTML = "<pre id=report>" + (out.length ? out.join("\\n") : "no overflow") + "</pre>";
|
|
88
|
+
</script></body></html>`
|
|
89
|
+
|
|
90
|
+
const reportPath = join(tmpdir(), 'onboarding-svg-text-check.html')
|
|
91
|
+
await writeFile(reportPath, page, 'utf8')
|
|
92
|
+
|
|
93
|
+
console.log(`${files.length} SVG file(s) checked.`)
|
|
94
|
+
console.log(`Report page: file://${reportPath}`)
|