@brignano/design 0.6.0 → 0.8.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/DECISIONS.md +176 -0
- package/DESIGN.md +250 -75
- package/README.md +4 -1
- package/components.css +2134 -0
- package/package.json +11 -3
- package/product-page.css +184 -20
- package/scripts/colour.mjs +41 -0
- package/scripts/email-tokens.mjs +58 -0
- package/scripts/fold.mjs +135 -0
- package/tailwind.css +7 -0
- package/templates/article.css +167 -0
- package/templates/changelog.css +53 -0
- package/templates/email.html +61 -0
- package/templates/email.txt +10 -0
- package/templates/legal.css +65 -0
- package/tokens.css +30 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brignano/design",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Shared design system for brignano surfaces
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Shared design system for brignano surfaces — colour, type, space, shape, motion.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -17,7 +17,12 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"tokens.css",
|
|
19
19
|
"tokens.chart.css",
|
|
20
|
+
"components.css",
|
|
20
21
|
"product-page.css",
|
|
22
|
+
"templates/",
|
|
23
|
+
"scripts/fold.mjs",
|
|
24
|
+
"scripts/email-tokens.mjs",
|
|
25
|
+
"scripts/colour.mjs",
|
|
21
26
|
"tailwind.css",
|
|
22
27
|
"DESIGN.md",
|
|
23
28
|
"DECISIONS.md"
|
|
@@ -26,7 +31,10 @@
|
|
|
26
31
|
"./tokens.css": "./tokens.css",
|
|
27
32
|
"./tokens.chart.css": "./tokens.chart.css",
|
|
28
33
|
"./tailwind.css": "./tailwind.css",
|
|
29
|
-
"./
|
|
34
|
+
"./components.css": "./components.css",
|
|
35
|
+
"./product-page.css": "./product-page.css",
|
|
36
|
+
"./templates/*": "./templates/*",
|
|
37
|
+
"./scripts/email-tokens.mjs": "./scripts/email-tokens.mjs"
|
|
30
38
|
},
|
|
31
39
|
"sideEffects": [
|
|
32
40
|
"*.css"
|
package/product-page.css
CHANGED
|
@@ -4,26 +4,50 @@
|
|
|
4
4
|
* @import '@brignano/design/product-page.css';
|
|
5
5
|
* <html class="tier-marketing">
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Show, then tell. A stranger glancing at a phone gets what the product is,
|
|
8
|
+
* what it does for them, and the one thing to do, from the first screen and
|
|
9
|
+
* without reading a paragraph. Write the five-line brief first (DESIGN.md
|
|
10
|
+
* §13); the page is built from it.
|
|
8
11
|
*
|
|
9
|
-
* .pp-header brand, a few in-page links, the
|
|
10
|
-
* .pp-hero status,
|
|
11
|
-
*
|
|
12
|
+
* .pp-header brand, a few in-page links, the primary action
|
|
13
|
+
* .pp-hero .pp-hero-head (status, .pp-audience naming who it's for, a
|
|
14
|
+
* thesis of 8 words or fewer), the proof (.pp-media), then
|
|
15
|
+
* .pp-hero-body (the pain and the fix in one sentence, the
|
|
16
|
+
* ask, "Try the live demo" when there is one, and a short
|
|
17
|
+
* note). On a phone the proof sits between the thesis and
|
|
18
|
+
* the subhead, so it is on the first screen.
|
|
19
|
+
* one signature band, the one only this product could have:
|
|
20
|
+
* .pp-gets three cards, each a small picture of the product
|
|
21
|
+
* .pp-compare this product beside the obvious alternative
|
|
22
|
+
* or a band of the product's own (a library, an embedded demo)
|
|
23
|
+
* .pp-how three numbered steps, one line each
|
|
12
24
|
* .pp-close the primary action again, with whatever it needs: a short
|
|
13
25
|
* .pp-form of .pp-field (.pp-done once it's sent), and the
|
|
14
26
|
* prices (.pp-price) if the product has them
|
|
15
27
|
* .pp-footer brand and links, then the legal line: © year, owner, and
|
|
16
28
|
* the product's Privacy and Terms links if it has them
|
|
17
29
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
30
|
+
* Each product looks like itself (ADR-0011), with three choices on the page:
|
|
31
|
+
*
|
|
32
|
+
* data-mark on .pp teal | violet | magenta: the product's mark, which
|
|
33
|
+
* inks its glyph, the hero rule, the stage behind the
|
|
34
|
+
* proof and the step numerals. Never a button or text.
|
|
35
|
+
* data-layout on .pp-hero split (default) | mirror (proof on the left) |
|
|
36
|
+
* stage (centred words and actions, the proof full width under them)
|
|
37
|
+
* the proof's frame bare, .pp-device (a phone) or .pp-browser (a window)
|
|
38
|
+
*
|
|
39
|
+
* The skeleton is previews/product-page.html, and a worked example is
|
|
40
|
+
* previews/product-page-example.html: copy one, keep the order, replace the
|
|
41
|
+
* words and pictures. scripts/fold.mjs checks the first phone screen.
|
|
42
|
+
* Rules (DESIGN.md §13):
|
|
20
43
|
*
|
|
21
44
|
* - One primary action per page (.pp-button). Everything else is secondary.
|
|
22
45
|
* - The status is a word with a dot, never a coloured badge on its own.
|
|
23
|
-
* -
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* -
|
|
46
|
+
* - Every picture is the product: a live demo, a real screenshot, a screen
|
|
47
|
+
* recording, or a faithful mock built from the product's own components.
|
|
48
|
+
* No stock imagery, no illustrations of people.
|
|
49
|
+
* - Write for the person who will use it, in their words. Tool names
|
|
50
|
+
* (Terraform, CI, AWS) go in the steps, not the thesis.
|
|
27
51
|
*
|
|
28
52
|
* Every class starts with .pp- so it can sit beside a site's own stylesheet.
|
|
29
53
|
* Colours are tokens only; widths are --pp-width / --pp-gutter, which a page
|
|
@@ -32,12 +56,19 @@
|
|
|
32
56
|
.pp {
|
|
33
57
|
--pp-width: 1160px;
|
|
34
58
|
--pp-gutter: var(--s5);
|
|
59
|
+
/* The product's mark (ADR-0011): ink until data-mark picks one. The stage
|
|
60
|
+
is the field behind the hero proof, a faint wash of the mark. */
|
|
61
|
+
--pp-mark: var(--ink);
|
|
62
|
+
--pp-stage: color-mix(in srgb, var(--pp-mark) 8%, transparent);
|
|
35
63
|
background: var(--bg);
|
|
36
64
|
color: var(--ink);
|
|
37
65
|
font: var(--text-base) / 1.6 var(--sans);
|
|
38
66
|
font-variant-numeric: tabular-nums;
|
|
39
67
|
-webkit-font-smoothing: antialiased;
|
|
40
68
|
}
|
|
69
|
+
.pp[data-mark="teal"] { --pp-mark: var(--mark-teal); }
|
|
70
|
+
.pp[data-mark="violet"] { --pp-mark: var(--mark-violet); }
|
|
71
|
+
.pp[data-mark="magenta"] { --pp-mark: var(--mark-magenta); }
|
|
41
72
|
/* On <body>, drop the browser's 8px margin so the sticky header and every band
|
|
42
73
|
run to the screen edges. On a wrapper, the body is the site's business. */
|
|
43
74
|
body.pp { margin: 0; }
|
|
@@ -63,6 +94,8 @@ body.pp { margin: 0; }
|
|
|
63
94
|
font-weight: 600; font-size: var(--text-lg); letter-spacing: -0.01em;
|
|
64
95
|
}
|
|
65
96
|
.pp-brand img, .pp-brand svg { width: 26px; height: 26px; }
|
|
97
|
+
/* An inline glyph drawn in currentColor takes the product's mark. */
|
|
98
|
+
.pp-brand svg { color: var(--pp-mark); }
|
|
66
99
|
.pp-nav { display: flex; align-items: center; gap: var(--s5); margin-left: auto; }
|
|
67
100
|
.pp-nav a { color: var(--ink-soft); text-decoration: none; font-size: var(--text-sm); font-weight: 500; }
|
|
68
101
|
.pp-nav a:hover { color: var(--ink); }
|
|
@@ -115,18 +148,98 @@ body.pp { margin: 0; }
|
|
|
115
148
|
.pp-note { margin: var(--s3) 0 0; font-size: var(--text-sm); color: var(--ink-soft); }
|
|
116
149
|
|
|
117
150
|
/* ── Hero ──────────────────────────────────────────────────────────────
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
151
|
+
Split into .pp-hero-head (status, thesis), the proof (.pp-media), and
|
|
152
|
+
.pp-hero-body (subhead, actions, note). On a phone they stack in that
|
|
153
|
+
order, so the proof is on the first screen; from 960px the head and body
|
|
154
|
+
share the left column and the proof takes the right.
|
|
155
|
+
|
|
156
|
+
The older markup, one copy <div> then the figure, still lays out (copy
|
|
157
|
+
first, proof under it on a phone), but it puts the proof below the first
|
|
158
|
+
phone screen, so new pages use the split. */
|
|
159
|
+
.pp-hero { padding: var(--s7) 0 var(--s8); }
|
|
160
|
+
@media (max-width: 560px) { .pp-hero { padding: var(--s5) 0 var(--s7); } }
|
|
121
161
|
.pp-hero > .pp-wrap { display: grid; gap: var(--s7); align-items: center; grid-template-columns: minmax(0, 1fr); }
|
|
122
162
|
@media (min-width: 960px) { .pp-hero > .pp-wrap { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
|
|
123
|
-
.pp-hero .pp-
|
|
163
|
+
.pp-hero > .pp-wrap:has(> .pp-hero-head) { gap: var(--s5); grid-template-areas: "head" "media" "body"; }
|
|
164
|
+
.pp-hero-head { grid-area: head; }
|
|
165
|
+
.pp-hero-body { grid-area: body; }
|
|
166
|
+
.pp-hero-head ~ .pp-media { grid-area: media; }
|
|
167
|
+
@media (min-width: 960px) {
|
|
168
|
+
.pp-hero > .pp-wrap:has(> .pp-hero-head) {
|
|
169
|
+
gap: var(--s4) var(--s7); align-items: stretch;
|
|
170
|
+
grid-template-areas: "head media" "body media"; grid-template-rows: 1fr 1fr;
|
|
171
|
+
}
|
|
172
|
+
.pp-hero-head { align-self: end; }
|
|
173
|
+
.pp-hero-body { align-self: start; }
|
|
174
|
+
.pp-hero-head ~ .pp-media { align-self: center; }
|
|
175
|
+
}
|
|
176
|
+
.pp-hero .pp-status { margin-bottom: var(--s4); }
|
|
177
|
+
/* The hero rule: a short bar in the product's mark, the first thing on the
|
|
178
|
+
page that is this product's and nobody else's. */
|
|
179
|
+
.pp-hero-head::before {
|
|
180
|
+
content: ""; display: block; width: 48px; height: 4px; border-radius: 2px;
|
|
181
|
+
background: var(--pp-mark); margin-bottom: var(--s4);
|
|
182
|
+
}
|
|
183
|
+
/* Who it's for, in a few words, above the thesis: "For teams running on AWS".
|
|
184
|
+
A stranger decides "is this for me?" before reading anything else. Ink,
|
|
185
|
+
not cobalt: cobalt says "you can act on this", and this is a label. */
|
|
186
|
+
.pp-audience { margin: 0 0 var(--s2); font-size: var(--text-base); font-weight: 600; line-height: 1.4; color: var(--ink-soft); }
|
|
187
|
+
/* The thesis names the outcome in 8 words or fewer. On a phone it steps down
|
|
188
|
+
from --text-4xl so it takes two or three lines, not five. */
|
|
124
189
|
.pp-thesis {
|
|
125
|
-
font-size: var(--text-4xl); font-weight: 600; line-height: 1.04; letter-spacing: -0.035em;
|
|
126
|
-
margin: 0 0 var(--s4); max-width:
|
|
190
|
+
font-size: min(var(--text-4xl), 1.25rem + 4vw); font-weight: 600; line-height: 1.04; letter-spacing: -0.035em;
|
|
191
|
+
margin: 0 0 var(--s4); max-width: 16ch; text-wrap: balance;
|
|
127
192
|
}
|
|
128
|
-
.pp-
|
|
193
|
+
.pp-hero-head .pp-thesis { margin-bottom: 0; }
|
|
194
|
+
/* The subhead is one sentence, 25 words or fewer. */
|
|
195
|
+
.pp-subhead { font-size: var(--text-lg); line-height: 1.5; color: var(--ink-soft); margin: 0 0 var(--s5); max-width: 40ch; text-wrap: pretty; }
|
|
129
196
|
.pp-media { margin: 0; min-width: 0; }
|
|
197
|
+
/* The stage: the proof sits on a field of the product's mark, so the eye
|
|
198
|
+
lands on it first and each product's first screen has its own colour. */
|
|
199
|
+
.pp-hero .pp-media { box-sizing: border-box; padding: var(--s6); border-radius: calc(var(--radius-lg) * 2); background: var(--pp-stage); }
|
|
200
|
+
@media (max-width: 560px) { .pp-hero .pp-media { padding: var(--s4); border-radius: var(--radius-lg); } }
|
|
201
|
+
|
|
202
|
+
/* Hero layouts (ADR-0011). Split is the default above. Mirror puts the proof
|
|
203
|
+
on the left, for a product whose picture should be read first. Stage
|
|
204
|
+
centres the words and the actions, then gives the proof the full width
|
|
205
|
+
under them, for a wide picture: a map, a dashboard, a before and after.
|
|
206
|
+
The actions sit above the proof so they stay on a laptop's first screen.
|
|
207
|
+
On a phone all three stack the same way: head, proof, body. */
|
|
208
|
+
@media (min-width: 960px) {
|
|
209
|
+
.pp-hero[data-layout="mirror"] > .pp-wrap:has(> .pp-hero-head) {
|
|
210
|
+
grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); grid-template-areas: "media head" "media body";
|
|
211
|
+
}
|
|
212
|
+
.pp-hero[data-layout="stage"] > .pp-wrap:has(> .pp-hero-head) {
|
|
213
|
+
grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "body" "media"; grid-template-rows: auto;
|
|
214
|
+
gap: var(--s6); justify-items: center; text-align: center;
|
|
215
|
+
}
|
|
216
|
+
.pp-hero[data-layout="stage"] .pp-hero-head::before { margin-inline: auto; }
|
|
217
|
+
.pp-hero[data-layout="stage"] .pp-thesis { max-width: 20ch; margin-inline: auto; }
|
|
218
|
+
.pp-hero[data-layout="stage"] .pp-subhead { max-width: 52ch; margin-inline: auto; }
|
|
219
|
+
.pp-hero[data-layout="stage"] .pp-actions { justify-content: center; }
|
|
220
|
+
.pp-hero[data-layout="stage"] .pp-hero-head ~ .pp-media { width: 100%; max-width: 1000px; }
|
|
221
|
+
.pp-hero[data-layout="stage"] .pp-media { text-align: start; }
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* A browser window around the proof, for a product that lives in a web page
|
|
225
|
+
(an extension, a web app). The bar holds the address, in mono. */
|
|
226
|
+
.pp-browser {
|
|
227
|
+
overflow: hidden; background: var(--card); border: 1px solid var(--line);
|
|
228
|
+
border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
|
|
229
|
+
}
|
|
230
|
+
.pp-browser-bar {
|
|
231
|
+
display: flex; align-items: center; gap: var(--s3); padding: 8px 12px;
|
|
232
|
+
background: var(--bg); border-bottom: 1px solid var(--line);
|
|
233
|
+
}
|
|
234
|
+
.pp-browser-bar::before {
|
|
235
|
+
content: ""; flex: none; width: 44px; height: 10px;
|
|
236
|
+
background: radial-gradient(circle at 5px 5px, var(--line-strong) 4px, transparent 4.5px) 0 0 / 17px 10px repeat-x;
|
|
237
|
+
}
|
|
238
|
+
.pp-browser-url {
|
|
239
|
+
flex: 1; min-width: 0; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--card);
|
|
240
|
+
font: var(--text-xs) / 1.4 var(--mono); color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
241
|
+
}
|
|
242
|
+
.pp-browser > :not(.pp-browser-bar) { display: block; width: 100%; height: auto; }
|
|
130
243
|
|
|
131
244
|
/* ── Proof media: a clip, a phone frame, the steps it shows ───────────────
|
|
132
245
|
The proof slot holds an <img> or a <video>, bare or in a .pp-device phone
|
|
@@ -185,8 +298,9 @@ body.pp { margin: 0; }
|
|
|
185
298
|
transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
|
|
186
299
|
}
|
|
187
300
|
.pp-steps > li::before { content: counter(pp-step) " "; color: var(--ink); }
|
|
188
|
-
/* The step the clip is on
|
|
189
|
-
|
|
301
|
+
/* The step the clip is on: the word inks, the bar takes the product's mark.
|
|
302
|
+
Identity, not state, so it never needs a word of its own. */
|
|
303
|
+
.pp-steps > li[aria-current="step"] { color: var(--ink); border-top-color: var(--pp-mark); }
|
|
190
304
|
|
|
191
305
|
/* Pause / Play. A word, because moving content that runs past five seconds
|
|
192
306
|
needs a way to stop it (WCAG 2.2.2). Hidden until the script wires it. */
|
|
@@ -202,8 +316,58 @@ body.pp { margin: 0; }
|
|
|
202
316
|
.pp-play[hidden] { display: none; }
|
|
203
317
|
@media (pointer: coarse) { .pp-play { min-height: 44px; } }
|
|
204
318
|
|
|
319
|
+
/* ── Bands: what you get, how it works ─────────────────────────────────
|
|
320
|
+
A band is a hairline, a short title that is a sentence, and a grid. */
|
|
321
|
+
.pp-band { padding: var(--s8) 0; border-top: 1px solid var(--line); scroll-margin-top: 64px; }
|
|
322
|
+
@media (max-width: 560px) { .pp-band { padding: var(--s7) 0; } }
|
|
323
|
+
.pp-title {
|
|
324
|
+
font-size: clamp(var(--text-xl), 1rem + 2vw, var(--text-3xl)); font-weight: 600; line-height: 1.15;
|
|
325
|
+
letter-spacing: -0.025em; margin: 0; max-width: 24ch; text-wrap: balance;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/* What you get: three cards. Each is a small picture of the product doing the
|
|
329
|
+
thing, a short heading, and one line. The picture carries it; the words
|
|
330
|
+
name it. On a phone they stack; from about 820px they sit in a row. */
|
|
331
|
+
.pp-gets { list-style: none; margin: var(--s6) 0 0; padding: 0; display: grid; gap: var(--s4);
|
|
332
|
+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
|
|
333
|
+
.pp-get { display: flex; flex-direction: column; overflow: hidden;
|
|
334
|
+
background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-1); }
|
|
335
|
+
.pp-get-media { margin: 0; aspect-ratio: 16 / 9; overflow: hidden; display: grid; place-items: center;
|
|
336
|
+
background: var(--bg); border-bottom: 1px solid var(--line); }
|
|
337
|
+
.pp-get-media > img, .pp-get-media > video { display: block; width: 100%; height: 100%; object-fit: cover; }
|
|
338
|
+
.pp-get h3 { margin: var(--s4) var(--s4) 4px; font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
|
|
339
|
+
.pp-get p { margin: 0 var(--s4) var(--s4); color: var(--ink-soft); }
|
|
340
|
+
|
|
341
|
+
/* Compare: this product beside the thing the reader would otherwise use
|
|
342
|
+
("a site builder", "a wiki of screenshots"). Two columns, the same rows in
|
|
343
|
+
each, said as words, so nothing rests on colour. Ours is on the right and
|
|
344
|
+
carries the mark on its top rule. On a phone they stack, ours first. */
|
|
345
|
+
.pp-compare { margin: var(--s6) 0 0; display: grid; gap: var(--s4); grid-template-columns: minmax(0, 1fr); }
|
|
346
|
+
@media (min-width: 720px) { .pp-compare { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
|
347
|
+
.pp-compare > div { padding: var(--s5); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); }
|
|
348
|
+
.pp-compare > .is-ours { border-top: 4px solid var(--pp-mark); box-shadow: var(--shadow-2); }
|
|
349
|
+
@media (max-width: 719px) { .pp-compare > .is-ours { order: -1; } }
|
|
350
|
+
.pp-compare h3 { margin: 0 0 var(--s3); font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
|
|
351
|
+
.pp-compare > :not(.is-ours) h3 { color: var(--ink-soft); }
|
|
352
|
+
.pp-compare ul { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
|
|
353
|
+
.pp-compare li { padding-top: var(--s2); border-top: 1px solid var(--line); }
|
|
354
|
+
.pp-compare > :not(.is-ours) li { color: var(--ink-soft); }
|
|
355
|
+
|
|
356
|
+
/* How it works: three numbered steps, one line each, numbered by the list. */
|
|
357
|
+
.pp-how { list-style: none; margin: var(--s6) 0 0; padding: 0; counter-reset: pp-how; display: grid; gap: var(--s5);
|
|
358
|
+
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
|
|
359
|
+
.pp-how > li { counter-increment: pp-how; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px var(--s3); align-items: baseline; }
|
|
360
|
+
.pp-how > li::before {
|
|
361
|
+
content: counter(pp-how); grid-row: span 2; display: inline-grid; place-items: center; width: 28px; height: 28px;
|
|
362
|
+
border-radius: 50%; border: 2px solid var(--pp-mark); font: 600 var(--text-sm) / 1 var(--mono); color: var(--ink);
|
|
363
|
+
}
|
|
364
|
+
.pp-how h3 { margin: 0; font-size: var(--text-lg); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
|
|
365
|
+
.pp-how p { margin: 0; color: var(--ink-soft); }
|
|
366
|
+
.pp-band .pp-figure { margin-top: var(--s6); }
|
|
367
|
+
|
|
205
368
|
/* ── Story ─────────────────────────────────────────────────────────────
|
|
206
|
-
|
|
369
|
+
Optional, and at most one chapter on a product page (the longer argument
|
|
370
|
+
belongs in the docs). An <ol> of chapters. Each opens on a hairline with "01 / Label" in mono,
|
|
207
371
|
then a headline that is a sentence, then a short body and an optional
|
|
208
372
|
figure. Wide screens put the label in its own column. */
|
|
209
373
|
.pp-story { list-style: none; margin: 0; padding: 0; counter-reset: pp-chapter; }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// colour.mjs — the one colour resolver, shared by check.mjs and
|
|
2
|
+
// email-tokens.mjs so the two can't drift. No dependencies.
|
|
3
|
+
|
|
4
|
+
export function hex(h) {
|
|
5
|
+
h = h.slice(1);
|
|
6
|
+
if (h.length === 3) h = [...h].map((c) => c + c).join('');
|
|
7
|
+
return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
8
|
+
}
|
|
9
|
+
export const toHex = (rgb) => '#' + rgb.map((c) => Math.round(c).toString(16).padStart(2, '0')).join('');
|
|
10
|
+
|
|
11
|
+
// Resolves a value to { rgb, alpha } against a map of one theme's tokens.
|
|
12
|
+
// Handles hex, var() and the one color-mix form the tokens use:
|
|
13
|
+
// color-mix(in srgb, X N%, transparent).
|
|
14
|
+
export function resolve(value, map, seen = new Set()) {
|
|
15
|
+
value = value.trim();
|
|
16
|
+
const ref = value.match(/^var\((--[\w-]+)\)$/);
|
|
17
|
+
if (ref) {
|
|
18
|
+
if (seen.has(ref[1]) || !map.has(ref[1])) throw new Error(`cannot resolve ${ref[1]}`);
|
|
19
|
+
return resolve(map.get(ref[1]), map, new Set([...seen, ref[1]]));
|
|
20
|
+
}
|
|
21
|
+
if (/^#[0-9a-f]{3,6}$/i.test(value)) return { rgb: hex(value), alpha: 1 };
|
|
22
|
+
const mix = value.match(/^color-mix\(in srgb,\s*(.+?)\s+([\d.]+)%,\s*transparent\)$/);
|
|
23
|
+
if (mix) {
|
|
24
|
+
const c = resolve(mix[1], map, seen);
|
|
25
|
+
return { rgb: c.rgb, alpha: c.alpha * (+mix[2] / 100) };
|
|
26
|
+
}
|
|
27
|
+
throw new Error(`unsupported colour value: ${value}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Splits on top-level commas, so light-dark(color-mix(…, x), y) splits once.
|
|
31
|
+
export function split(s) {
|
|
32
|
+
const out = [];
|
|
33
|
+
let depth = 0, start = 0;
|
|
34
|
+
for (let i = 0; i < s.length; i++) {
|
|
35
|
+
if (s[i] === '(') depth++;
|
|
36
|
+
else if (s[i] === ')') depth--;
|
|
37
|
+
else if (s[i] === ',' && depth === 0) { out.push(s.slice(start, i).trim()); start = i + 1; }
|
|
38
|
+
}
|
|
39
|
+
out.push(s.slice(start).trim());
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// email-tokens.mjs — fills an email template's colours from tokens.css.
|
|
2
|
+
//
|
|
3
|
+
// node scripts/email-tokens.mjs [template] > email.html
|
|
4
|
+
//
|
|
5
|
+
// Email clients can't read CSS custom properties, so templates/email.html
|
|
6
|
+
// names each colour as a token in double braces, like {{--ink}}, and this
|
|
7
|
+
// script swaps each one for the token's light-theme value (email is light
|
|
8
|
+
// only: client dark modes rewrite colours unpredictably). Translucent tokens are flattened onto --card, the
|
|
9
|
+
// email's surface. Content placeholders ({{heading}}, {{button_url}}, …) are
|
|
10
|
+
// left for your app to fill. Exits non-zero, naming the token, if one can't be
|
|
11
|
+
// resolved, so a renamed token fails loudly instead of sending a blank colour.
|
|
12
|
+
//
|
|
13
|
+
// No dependencies; the colour maths is colour.mjs, shared with check.mjs,
|
|
14
|
+
// which also imports resolveLight and TOKEN from here.
|
|
15
|
+
|
|
16
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
import { resolve, split, toHex } from './colour.mjs';
|
|
19
|
+
|
|
20
|
+
const here = (p) => new URL(`../${p}`, import.meta.url);
|
|
21
|
+
export const TOKEN = /\{\{(--[\w-]+)\}\}/g;
|
|
22
|
+
|
|
23
|
+
// The first declaration of each custom property in tokens.css (the :root block).
|
|
24
|
+
export function tokenMap(css = readFileSync(here('tokens.css'), 'utf8')) {
|
|
25
|
+
const map = new Map();
|
|
26
|
+
const body = css.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
27
|
+
for (const m of body.matchAll(/(--[\w-]+)\s*:\s*([^;]+);/g)) if (!map.has(m[1])) map.set(m[1], m[2].trim());
|
|
28
|
+
return map;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Light-theme value of a token as #rrggbb, flattened onto --card when translucent.
|
|
32
|
+
export function resolveLight(name, map = tokenMap()) {
|
|
33
|
+
if (!map.has(name)) throw new Error(`${name} is not a token in tokens.css`);
|
|
34
|
+
const light = new Map([...map].map(([k, v]) => {
|
|
35
|
+
const ld = v.match(/^light-dark\((.*)\)$/s);
|
|
36
|
+
return [k, ld ? split(ld[1])[0] : v];
|
|
37
|
+
}));
|
|
38
|
+
const c = resolve(`var(${name})`, light);
|
|
39
|
+
if (c.alpha === 1) return toHex(c.rgb);
|
|
40
|
+
const card = resolve('var(--card)', light).rgb;
|
|
41
|
+
return toHex(c.rgb.map((v, i) => v * c.alpha + card[i] * (1 - c.alpha)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function fill(html, map = tokenMap()) {
|
|
45
|
+
return html.replace(TOKEN, (_, name) => resolveLight(name, map));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// argv[1] keeps a symlinked path (pnpm, npm link, workspaces) while
|
|
49
|
+
// import.meta.url is the real file, so compare real paths.
|
|
50
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
51
|
+
const file = process.argv[2] ?? fileURLToPath(here('templates/email.html'));
|
|
52
|
+
try {
|
|
53
|
+
process.stdout.write(fill(readFileSync(file, 'utf8')));
|
|
54
|
+
} catch (e) {
|
|
55
|
+
console.error(`email-tokens: ${e.message}`);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
}
|
package/scripts/fold.mjs
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// fold.mjs — the first phone screen of a product page, checked instead of hoped for.
|
|
2
|
+
//
|
|
3
|
+
// node scripts/fold.mjs <url> [<url> ...] [--shots <dir>]
|
|
4
|
+
//
|
|
5
|
+
// Opens each page at iPhone size (390 × 844) and fails when a stranger
|
|
6
|
+
// glancing at it would not get what it is and what to do (DESIGN.md §13):
|
|
7
|
+
//
|
|
8
|
+
// 1. the thesis (h1.pp-thesis) is not wholly on the first screen, or runs
|
|
9
|
+
// past 8 words, or the hero has no audience line (.pp-audience);
|
|
10
|
+
// 2. the hero subhead runs past 25 words;
|
|
11
|
+
// 3. less than 160px of the proof (.pp-hero .pp-media) is on the first
|
|
12
|
+
// screen, or the proof is wider than its box (cropped on a phone);
|
|
13
|
+
// 4. no primary action (.pp-button) is visible on the first screen;
|
|
14
|
+
// 5. the page scrolls sideways;
|
|
15
|
+
// 6. the page is longer than 7 phone screens, the length at which it has
|
|
16
|
+
// become a case study;
|
|
17
|
+
// 7. the words are over budget: more than 40 words of copy on the first
|
|
18
|
+
// screen, or 180 on the whole page. Copy is what the reader has to read:
|
|
19
|
+
// the words inside pictures (.pp-media, .pp-get-media), the form, the
|
|
20
|
+
// header and the footer don't count, nor anything marked
|
|
21
|
+
// data-fold="skip" (the preview site's own bar);
|
|
22
|
+
// 8. the status (.pp-status) shows more than once on the first screen.
|
|
23
|
+
//
|
|
24
|
+
// It can't tell whether a stranger gets it. That is the stranger test in
|
|
25
|
+
// DESIGN.md §13: hand the first-screen shot (--shots) to someone, or a fresh
|
|
26
|
+
// agent with no context, and compare what they say to the page's brief.
|
|
27
|
+
//
|
|
28
|
+
// Needs Playwright with Chromium (`npm i --no-save playwright` and
|
|
29
|
+
// `npx playwright install chromium`, or set CHROME_PATH); the design package itself stays
|
|
30
|
+
// dependency-free, so this script is run in CI and by the sites that copy it,
|
|
31
|
+
// not by `npm run check`. --shots writes a first-screen PNG per page.
|
|
32
|
+
|
|
33
|
+
import { mkdirSync } from 'node:fs';
|
|
34
|
+
import { createRequire } from 'node:module';
|
|
35
|
+
|
|
36
|
+
const require = createRequire(import.meta.url);
|
|
37
|
+
const { chromium } = (() => { try { return require('playwright'); } catch { return require('playwright-core'); } })();
|
|
38
|
+
|
|
39
|
+
const args = process.argv.slice(2);
|
|
40
|
+
const shotsAt = args.indexOf('--shots');
|
|
41
|
+
const shots = shotsAt >= 0 ? args.splice(shotsAt, 2)[1] : null;
|
|
42
|
+
if (!args.length) {
|
|
43
|
+
console.error('usage: node scripts/fold.mjs <url> [<url> ...] [--shots <dir>]');
|
|
44
|
+
process.exit(2);
|
|
45
|
+
}
|
|
46
|
+
if (shots) mkdirSync(shots, { recursive: true });
|
|
47
|
+
|
|
48
|
+
const W = 390, H = 844;
|
|
49
|
+
const LIMITS = { thesisWords: 8, subheadWords: 25, proofVisible: 160, screens: 7, foldWords: 40, pageWords: 180 };
|
|
50
|
+
|
|
51
|
+
// CHROME_PATH points at an installed Chrome instead of Playwright's own
|
|
52
|
+
// download (CI uses the runner's Chrome, which tracks new OS images).
|
|
53
|
+
const browser = await chromium.launch(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {});
|
|
54
|
+
const page = await browser.newPage({ viewport: { width: W, height: H }, deviceScaleFactor: 2, isMobile: true, hasTouch: true });
|
|
55
|
+
await page.route(/googletagmanager|google-analytics|plausible|cloudflareinsights/, (r) => r.abort());
|
|
56
|
+
|
|
57
|
+
let failed = 0;
|
|
58
|
+
for (const url of args) {
|
|
59
|
+
await page.goto(url, { waitUntil: 'load' });
|
|
60
|
+
await page.evaluate(() => document.fonts.ready);
|
|
61
|
+
const r = await page.evaluate(({ W, H }) => {
|
|
62
|
+
const words = (el) => (el ? el.textContent.trim().split(/\s+/).filter(Boolean).length : 0);
|
|
63
|
+
const box = (el) => (el ? el.getBoundingClientRect() : null);
|
|
64
|
+
const thesis = document.querySelector('h1.pp-thesis');
|
|
65
|
+
const subhead = document.querySelector('.pp-hero .pp-subhead');
|
|
66
|
+
const media = document.querySelector('.pp-hero .pp-media');
|
|
67
|
+
const buttons = [...document.querySelectorAll('.pp-button')].filter((b) => {
|
|
68
|
+
const r = b.getBoundingClientRect();
|
|
69
|
+
return r.width > 0 && r.top >= 0 && r.bottom <= H;
|
|
70
|
+
});
|
|
71
|
+
const audience = document.querySelector('.pp-hero .pp-audience');
|
|
72
|
+
// Copy words: text the reader has to read, outside pictures, form, header, footer.
|
|
73
|
+
const skip = '.pp-media, .pp-get-media, .pp-form, .pp-done, .pp-header, .pp-footer, .pp-skip, script, style, [hidden], [data-fold="skip"]';
|
|
74
|
+
let foldWords = 0, pageWords = 0;
|
|
75
|
+
const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
|
76
|
+
while (walk.nextNode()) {
|
|
77
|
+
const el = walk.currentNode.parentElement;
|
|
78
|
+
if (!el || el.closest(skip)) continue;
|
|
79
|
+
const r = el.getBoundingClientRect();
|
|
80
|
+
if (!r.width || !r.height) continue;
|
|
81
|
+
const n = walk.currentNode.textContent.split(/\s+/).filter(Boolean).length;
|
|
82
|
+
pageWords += n;
|
|
83
|
+
if (r.top < H && r.bottom > 0) foldWords += n;
|
|
84
|
+
}
|
|
85
|
+
const statuses = [...document.querySelectorAll('.pp-status')].filter((s) => {
|
|
86
|
+
const r = s.getBoundingClientRect();
|
|
87
|
+
return r.width > 0 && r.top < H && r.bottom > 0;
|
|
88
|
+
}).length;
|
|
89
|
+
const tb = box(thesis), mb = box(media);
|
|
90
|
+
return {
|
|
91
|
+
thesis: thesis ? { words: words(thesis), bottom: tb.bottom } : null,
|
|
92
|
+
audience: audience ? audience.textContent.trim() : '',
|
|
93
|
+
subheadWords: words(subhead),
|
|
94
|
+
media: media ? { visible: Math.max(0, Math.min(mb.bottom, H) - mb.top), overflow: media.scrollWidth - media.clientWidth } : null,
|
|
95
|
+
buttons: buttons.length,
|
|
96
|
+
foldWords, pageWords, statuses,
|
|
97
|
+
scrollWidth: document.documentElement.scrollWidth,
|
|
98
|
+
height: document.documentElement.scrollHeight,
|
|
99
|
+
};
|
|
100
|
+
}, { W, H });
|
|
101
|
+
|
|
102
|
+
const problems = [];
|
|
103
|
+
if (!r.thesis) problems.push('no h1.pp-thesis');
|
|
104
|
+
else {
|
|
105
|
+
if (r.thesis.bottom > H) problems.push(`thesis ends at ${Math.round(r.thesis.bottom)}px, below the first screen (${H}px)`);
|
|
106
|
+
if (r.thesis.words > LIMITS.thesisWords) problems.push(`thesis is ${r.thesis.words} words (max ${LIMITS.thesisWords})`);
|
|
107
|
+
}
|
|
108
|
+
if (!r.audience) problems.push('no audience line (.pp-hero .pp-audience) saying who it is for');
|
|
109
|
+
if (r.subheadWords > LIMITS.subheadWords) problems.push(`hero subhead is ${r.subheadWords} words (max ${LIMITS.subheadWords})`);
|
|
110
|
+
if (!r.media) problems.push('no proof (.pp-hero .pp-media)');
|
|
111
|
+
else {
|
|
112
|
+
if (r.media.visible < LIMITS.proofVisible) problems.push(`only ${Math.round(r.media.visible)}px of the proof is on the first screen (min ${LIMITS.proofVisible})`);
|
|
113
|
+
if (r.media.overflow > 1) problems.push(`the proof is ${r.media.overflow}px wider than its box, so it is cropped on a phone`);
|
|
114
|
+
}
|
|
115
|
+
if (!r.buttons) problems.push('no .pp-button visible on the first screen');
|
|
116
|
+
if (r.scrollWidth > W) problems.push(`page scrolls sideways (${r.scrollWidth}px wide)`);
|
|
117
|
+
if (r.foldWords > LIMITS.foldWords) problems.push(`${r.foldWords} words of copy on the first screen (max ${LIMITS.foldWords}): let the proof say it`);
|
|
118
|
+
if (r.pageWords > LIMITS.pageWords) problems.push(`${r.pageWords} words of copy on the page (max ${LIMITS.pageWords}): move the argument to the docs`);
|
|
119
|
+
if (r.statuses > 1) problems.push(`the status shows ${r.statuses} times on the first screen (once is enough)`);
|
|
120
|
+
const screens = r.height / H;
|
|
121
|
+
if (screens > LIMITS.screens) problems.push(`page is ${screens.toFixed(1)} phone screens long (max ${LIMITS.screens})`);
|
|
122
|
+
|
|
123
|
+
if (shots) {
|
|
124
|
+
const name = new URL(url).pathname.split('/').filter(Boolean).pop()?.replace(/\.html$/, '') || 'index';
|
|
125
|
+
await page.screenshot({ path: `${shots}/${name}-fold.png` });
|
|
126
|
+
}
|
|
127
|
+
if (problems.length) {
|
|
128
|
+
failed++;
|
|
129
|
+
console.log(`✗ ${url}\n${problems.map((p) => ` ${p}`).join('\n')}`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(`✓ ${url} · thesis ${r.thesis.words} words, ${r.foldWords} words on screen one, ${r.pageWords} on the page, ${Math.round(r.media.visible)}px of proof, ${screens.toFixed(1)} screens`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
await browser.close();
|
|
135
|
+
process.exit(failed ? 1 : 0);
|
package/tailwind.css
CHANGED
|
@@ -61,6 +61,13 @@
|
|
|
61
61
|
--color-diff-removed-ink: var(--diff-removed-ink);
|
|
62
62
|
--color-diff-removed-surface: var(--diff-removed-surface);
|
|
63
63
|
|
|
64
|
+
--color-code-surface: var(--code-surface);
|
|
65
|
+
--color-code-ink: var(--code-ink);
|
|
66
|
+
--color-code-keyword: var(--code-keyword);
|
|
67
|
+
--color-code-string: var(--code-string);
|
|
68
|
+
--color-code-comment: var(--code-comment);
|
|
69
|
+
--color-code-highlight: var(--code-highlight);
|
|
70
|
+
|
|
64
71
|
--color-mark: var(--mark);
|
|
65
72
|
--color-mark-ink: var(--mark-ink);
|
|
66
73
|
|