From 6462e5865094500873b45eaa45c9c3d6443f335e Mon Sep 17 00:00:00 2001
From: ChristopherPHolder
Date: Sat, 7 Nov 2026 14:01:33 +0100
Subject: [PATCH] docs: callout icons, line highlights, diffs and copy-link
anchors
Callouts get an icon per kind. Fenced blocks accept a {1,3-4} attribute
that highlights lines, and diff blocks mark added and removed lines
(copying a diff gives the resulting file). Heading anchors become a
link icon that copies the section's URL and confirms with a small
toast.
Content: the recorder export steps highlight the lines they add, and
the init page shows the rc file change as a diff.
Closes #319
---
packages/docs/src/app/docs/_doc-overlays.scss | 48 +++++++++++
packages/docs/src/app/docs/doc-page.html | 15 ++++
packages/docs/src/app/docs/doc-page.ts | 35 +++++++-
packages/docs/src/app/docs/markdown.ts | 83 ++++++++++++++++++-
packages/docs/src/content/cli/init.md | 16 ++++
.../content/user-flows/recorder-exports.md | 4 +-
packages/docs/src/styles.scss | 56 ++++++++++++-
7 files changed, 247 insertions(+), 10 deletions(-)
diff --git a/packages/docs/src/app/docs/_doc-overlays.scss b/packages/docs/src/app/docs/_doc-overlays.scss
index 249ae37b..c31852e7 100644
--- a/packages/docs/src/app/docs/_doc-overlays.scss
+++ b/packages/docs/src/app/docs/_doc-overlays.scss
@@ -316,3 +316,51 @@
transform: scale(0.92) translateY(8px);
}
}
+
+/* A small confirmation that rises from the bottom, e.g. after copying a link. */
+.toast {
+ position: fixed;
+ z-index: 40;
+ left: 50%;
+ bottom: var(--space-6);
+ display: inline-flex;
+ align-items: center;
+ gap: var(--space-2);
+ padding: var(--space-2) var(--space-4);
+ border-radius: var(--radius-full);
+ background: var(--color-neutral-900);
+ color: var(--color-neutral-50);
+ box-shadow: var(--shadow-lg);
+ font-size: 0.875rem;
+ line-height: 1.25rem;
+ font-weight: 500;
+ opacity: 0;
+ translate: -50% 12px;
+ pointer-events: none;
+ transition:
+ opacity var(--duration-base) ease-out,
+ translate var(--duration-base) var(--ease-out);
+
+ svg {
+ width: 1rem;
+ height: 1rem;
+ color: var(--color-success-400);
+ }
+}
+
+.toast-visible {
+ opacity: 1;
+ translate: -50% 0;
+}
+
+:root[data-theme='dark'] .toast {
+ background: var(--color-neutral-50);
+ color: var(--color-neutral-900);
+}
+
+@media (prefers-color-scheme: dark) {
+ :root:not([data-theme='light']) .toast {
+ background: var(--color-neutral-50);
+ color: var(--color-neutral-900);
+ }
+}
diff --git a/packages/docs/src/app/docs/doc-page.html b/packages/docs/src/app/docs/doc-page.html
index 258751e8..441c02a4 100644
--- a/packages/docs/src/app/docs/doc-page.html
+++ b/packages/docs/src/app/docs/doc-page.html
@@ -182,6 +182,21 @@ {{ doc().page.title
+
+
') ? rest.slice(4) : `${rest}`;
- return `\n`;
+ return `\n`;
},
table({ header, rows }: Tokens.Table) {
const labels = header.map((c) =>
diff --git a/packages/docs/src/content/cli/init.md b/packages/docs/src/content/cli/init.md
index c9d602f4..cd0184ee 100644
--- a/packages/docs/src/content/cli/init.md
+++ b/packages/docs/src/content/cli/init.md
@@ -47,6 +47,22 @@ Point `--rcPath` at the file you want to change and pass only the values that sh
npx user-flow init --rcPath .user-flowrc.ci.json --outPath tmp/measures
```
+Only the value you passed changes:
+
+```diff title=".user-flowrc.ci.json"
+ {
+ "collect": {
+ "url": "https://coffee-cart.netlify.app/",
+ "ufPath": "./user-flows"
+ },
+ "persist": {
+- "outPath": "./measures",
++ "outPath": "tmp/measures",
+ "format": ["html"]
+ }
+ }
+```
+
> [!TIP]
> Combine `init` with `--verbose` to print the resolved rc file without changing anything:
> `npx user-flow init --rcPath .user-flowrc.ci.json --verbose`
diff --git a/packages/docs/src/content/user-flows/recorder-exports.md b/packages/docs/src/content/user-flows/recorder-exports.md
index 3ae7c2c7..9ee0bff2 100644
--- a/packages/docs/src/content/user-flows/recorder-exports.md
+++ b/packages/docs/src/content/user-flows/recorder-exports.md
@@ -70,7 +70,7 @@ One timespan over everything is a coarse measurement. To see each interaction on
| `startTimespan` / `endTimespan` | `flow.startTimespan()` / `flow.endTimespan()` |
| `snapshot` | `flow.snapshot()` |
-```json title="recordings/order-coffee.replay.json"
+```json {4,11,12} title="recordings/order-coffee.replay.json"
{
"title": "Order coffee",
"steps": [
@@ -102,7 +102,7 @@ const interactions: UserFlowInteractionsFn = async (ctx: UserFlowContext): Promi
Measurement steps accept the same options as their Lighthouse counterparts through `stepOptions`. A `name` makes the report readable:
-```json title="recordings/order-coffee.replay.json"
+```json {5,16} title="recordings/order-coffee.replay.json"
{
"steps": [
{
diff --git a/packages/docs/src/styles.scss b/packages/docs/src/styles.scss
index e4c7720f..8023a309 100644
--- a/packages/docs/src/styles.scss
+++ b/packages/docs/src/styles.scss
@@ -303,12 +303,26 @@ pre {
}
.heading-anchor {
+ display: inline-flex;
margin-left: var(--space-2);
+ vertical-align: middle;
color: var(--text-subtle);
text-decoration: none;
- font-weight: 400;
opacity: 0;
- transition: opacity 0.15s ease-out;
+ translate: -4px 0;
+ transition:
+ opacity var(--duration-fast) ease-out,
+ translate var(--duration-base) var(--ease-out),
+ color var(--duration-fast) ease-out;
+
+ svg {
+ width: 0.8em;
+ height: 0.8em;
+ }
+
+ &:hover {
+ color: var(--link);
+ }
}
h2:hover .heading-anchor,
@@ -316,6 +330,7 @@ pre {
h4:hover .heading-anchor,
.heading-anchor:focus {
opacity: 1;
+ translate: 0;
}
p,
@@ -552,8 +567,8 @@ pre {
height: 2rem;
border: 1px solid var(--accent-outline);
border-radius: var(--radius-full);
- background: var(--accent-soft);
- color: var(--accent-soft-text);
+ background: var(--surface-raised);
+ color: var(--link);
font-family: var(--font-mono);
font-size: 0.875rem;
font-weight: 600;
@@ -833,6 +848,9 @@ pre {
}
.callout-title {
+ display: flex;
+ align-items: center;
+ gap: var(--space-1-5);
margin: 0 0 var(--space-1) !important;
font-family: var(--font-mono);
font-size: 0.75rem;
@@ -843,6 +861,12 @@ pre {
color: var(--callout-title);
}
+.callout-icon {
+ flex: none;
+ width: 1rem;
+ height: 1rem;
+}
+
.callout-tip {
--callout-border: var(--callout-tip-border);
--callout-bg: var(--callout-tip-bg);
@@ -997,6 +1021,30 @@ pre {
opacity: 1;
}
+/* Highlighted lines (`{1,3-4}`) and diff lines span the full width of the block. */
+.code-line {
+ display: inline-block;
+ min-width: calc(100% + 2 * var(--space-4));
+ margin: 0 calc(-1 * var(--space-4));
+ padding: 0 var(--space-4);
+ border-left: 2px solid transparent;
+}
+
+.code-line.is-highlighted {
+ background: rgb(139 92 246 / 0.16);
+ border-left-color: var(--color-primary-400);
+}
+
+.code-line.is-added {
+ background: rgb(34 197 94 / 0.14);
+ border-left-color: var(--color-success-400);
+}
+
+.code-line.is-removed {
+ background: rgb(239 68 68 / 0.14);
+ border-left-color: var(--color-error-400);
+}
+
/* Terminal blocks: window dots in the title bar, a prompt before each
command (a pseudo-element, so it is never selected or copied), muted
comments and dimmer output. */