Repository navigation
Commit a4e4c73
authored
Add a compact render mode and a title to the markdown preview (#3882)
* Add a compact render mode and a title to the markdown preview
`Preview` renders into an iframe served by `/render`, which pads the page
by 1rem and lays out `main`/`p` as blocks. That is right for a document and
wrong for a short string: a one-line summary arrives in a padded box, and
the padding is counted into the measured frame height.
Adds two props:
- `compact` drops the page padding and lets the block wrappers flow, so a
short string renders as a line of text. Wrapping stays on, so content of
a sentence or two still fits its frame rather than being clipped.
- `title` sets the frame's accessible name, which was hardcoded to
"output". A page with several of these frames announced them all
identically.
Also sets `border-0` on the iframe, which otherwise picks up the UA
default border in some browsers.
Both props are additive and default to today's behaviour.
The approach here comes from @Tidemand's work in #3865, which needs this
same body-class plumbing for inline event summaries. This is deliberately
narrower: no shrink-to-fit width measurement, so that PR's inline mode can
layer on top rather than conflict with it.
* Tighten compact mode so it matches the text beside the frame
Measuring the first consumer in a browser turned up three things the
initial pass missed.
The reset sizes every element through a `*` selector, which beats
inheritance, so `body.compact { font-size }` never reached `main`, `p` or
the inline elements — content rendered at 12.25px next to 14px text
outside the frame. The metrics are now restated for the elements a short
string can contain.
`main` and `p` go back to blocks with the margins zeroed rather than
`display: inline`. `getRenderedHeight` measures `main`, and an inline box
reports the text box rather than the line box: two pixels short of the
leading, which clips descenders and the background of a code span.
Inline code keeps its horizontal padding and drops the vertical, which
otherwise grows the line box past the height the frame was sized to.
Measured on a one-line string with bold, a code span and a link: the frame
went from 65px to 23px, with nothing clipped and the type matching its
surroundings.
* Restore bold, and merge main
The star selector at the top of the reset sets font-weight on every
element, which beats the UA default for strong. Nothing restored it, so
`**bold**` has been rendering at normal weight on every markdown surface —
event summaries and incident summaries included, not just the compact mode
this PR adds. Found while checking a consumer.
Also merges main for the Io colour system. The reset now resolves code
colours through --color-surface-secondary and --color-content-primary, and
the compact rules here still hold against it: they set layout and metrics,
not colour.
* Break long unbroken tokens instead of overflowing
The reset set no overflow-wrap anywhere, so a long URL in a summary ran
past its container - and in compact mode, where the body clips, it simply
disappeared off the edge.
Same bug as the bold one: it affects every markdown surface, not just the
compact mode this PR adds. A consumer hit it, was fixed there, and this is
the half that belongs upstream.
* Carry the compact render styles into the Go render route
The ui-server serves /render from its own Go handler with the stylesheet
inlined as a template literal, so the compact changes to
src/markdown.reset.css only took effect under the SvelteKit dev server.
A packaged binary kept the 1rem page padding and the opaque box the
compact class exists to remove.
Ports the compact block, reads the compact query param with the same
exact-string parsing the SvelteKit route uses, and adds overflow-wrap so
a long unbroken token in a 255-character description wraps instead of
overflowing the frame.
Also pins strong/b to 600. Bold already worked here via the UA default,
since unlike the SvelteKit reset this star selector sets no font-weight,
but the UA's 700 rendered heavier than the same markdown does in dev.
The two stylesheets cannot be fully unified while this handler has no way
to read the Io theme variables the SvelteKit copy resolves colors
through, so a test holds the colorless compact block to parity and names
any selector that goes missing from it.
* Make the compact frame take the surface it is placed on
The compact mode shipped here painted its own canvas, so an embedder on
any surface other than the default got an opaque box: white on a dark
page. The fix has two halves and needs both. body.compact drops the
background, and the root declares a color-scheme matching the theme on
body, because a mismatch between the document's scheme and the one the
page gave the iframe element makes the browser paint an opaque canvas
regardless of what the document asks for.
Ports both halves to the Go render route as well, for the same reason the
compact styles went there: a packaged ui-server serves /render from Go,
not from SvelteKit.1 parent 8ac7a8e commit a4e4c73
6 files changed
Lines changed: 381 additions & 13 deletions
File tree
- server/server/route
- src
- lib/holocene/markdown-editor
- routes/(app)/render
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
191 | 197 | | |
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
195 | 201 | | |
196 | 202 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
201 | 208 | | |
202 | | - | |
203 | | - | |
204 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
| |||
214 | 222 | | |
215 | 223 | | |
216 | 224 | | |
| 225 | + | |
217 | 226 | | |
218 | 227 | | |
219 | 228 | | |
220 | 229 | | |
221 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
222 | 268 | | |
223 | 269 | | |
224 | 270 | | |
| |||
243 | 289 | | |
244 | 290 | | |
245 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
246 | 299 | | |
247 | 300 | | |
248 | 301 | | |
| |||
374 | 427 | | |
375 | 428 | | |
376 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
377 | 453 | | |
378 | 454 | | |
379 | 455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
254 | 257 | | |
255 | 258 | | |
256 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
23 | 35 | | |
24 | 36 | | |
25 | 37 | | |
| |||
30 | 42 | | |
31 | 43 | | |
32 | 44 | | |
| 45 | + | |
| 46 | + | |
33 | 47 | | |
34 | 48 | | |
35 | 49 | | |
| |||
105 | 119 | | |
106 | 120 | | |
107 | 121 | | |
108 | | - | |
| 122 | + | |
109 | 123 | | |
110 | 124 | | |
111 | 125 | | |
| |||
115 | 129 | | |
116 | 130 | | |
117 | 131 | | |
118 | | - | |
119 | | - | |
| 132 | + | |
| 133 | + | |
120 | 134 | | |
121 | 135 | | |
122 | 136 | | |
| |||
0 commit comments