@@ -48,7 +48,7 @@ Your function receives three arguments:
4848
4949* ` node ` — the parent ` div ` to append content to.
5050* ` args ` — the parameters passed from markdown. Framework-level keys (` title ` ,
51- ` wide ` , ` className ` , ` anchorId ` ) are handled by znai and not forwarded.
51+ ` wide ` , ` className ` , ` anchorId ` , ` height ` ) are handled by znai and not forwarded.
5252* ` themeObservable ` — live access to the current znai theme.
5353
5454``` javascript {title: "themeObservable shape"}
@@ -129,6 +129,76 @@ iframes.
129129 metrics: {"requests": 1024, "latency_ms": 42, "error_rate": 0.003}
130130}
131131
132+ # Height
133+
134+ By default the block grows to fit whatever the function renders into it. Pass
135+ ` height ` to pin the block to a fixed size — content past it scrolls inside the
136+ viewport znai gives the function.
137+
138+ ` height ` accepts either a number (treated as pixels) or any CSS length string
139+ like ` "320px" ` or ` "30vh" ` .
140+
141+ The ` activityFeed ` function below appends one row per event. Without ` height ` ,
142+ all twelve rows render and the block grows to fit them:
143+
144+ ``` markdown
145+ :include-javascript-function: activityFeed {
146+ title: "deploys",
147+ events: [
148+ {time: "09:14", action: "build started", detail: "commit a31f9b on main"},
149+ {time: "09:17", action: "tests passed", detail: "248 / 248 green"},
150+ ...
151+ ]
152+ }
153+ ```
154+
155+ :include-javascript-function: activityFeed {
156+ title: "deploys",
157+ events: [
158+ {time: "09:14", action: "build started", detail: "commit a31f9b on main"},
159+ {time: "09:17", action: "tests passed", detail: "248 / 248 green"},
160+ {time: "09:18", action: "image pushed", detail: "registry.io/web@sha256: c2 ..."},
161+ {time: "09:19", action: "deploy started", detail: "rolling out to canary"},
162+ {time: "09:21", action: "canary healthy", detail: "p99 42ms, error rate 0.0%"},
163+ {time: "09:24", action: "promoted", detail: "100% of fleet now on a31f9b"},
164+ {time: "09:31", action: "alert fired", detail: "latency spike on shard 4"},
165+ {time: "09:33", action: "shard restarted", detail: "shard 4 back to baseline"},
166+ {time: "09:40", action: "config reload", detail: "feature flag billing-v2 → on"},
167+ {time: "09:47", action: "backfill queued", detail: "1.2M rows over 6 batches"},
168+ {time: "09:58", action: "backfill complete", detail: "elapsed 11m02s"},
169+ {time: "10:05", action: "deploy started", detail: "rolling out to prod-eu"}
170+ ]
171+ }
172+
173+ Add ` height ` and the same twelve events scroll inside a fixed-size box instead:
174+
175+ ``` markdown
176+ :include-javascript-function: activityFeed {
177+ title: "deploys",
178+ height: 220,
179+ events: [ /* same twelve events * /]
180+ }
181+ ```
182+
183+ :include-javascript-function: activityFeed {
184+ title: "deploys",
185+ height: 220,
186+ events: [
187+ {time: "09:14", action: "build started", detail: "commit a31f9b on main"},
188+ {time: "09:17", action: "tests passed", detail: "248 / 248 green"},
189+ {time: "09:18", action: "image pushed", detail: "registry.io/web@sha256: c2 ..."},
190+ {time: "09:19", action: "deploy started", detail: "rolling out to canary"},
191+ {time: "09:21", action: "canary healthy", detail: "p99 42ms, error rate 0.0%"},
192+ {time: "09:24", action: "promoted", detail: "100% of fleet now on a31f9b"},
193+ {time: "09:31", action: "alert fired", detail: "latency spike on shard 4"},
194+ {time: "09:33", action: "shard restarted", detail: "shard 4 back to baseline"},
195+ {time: "09:40", action: "config reload", detail: "feature flag billing-v2 → on"},
196+ {time: "09:47", action: "backfill queued", detail: "1.2M rows over 6 batches"},
197+ {time: "09:58", action: "backfill complete", detail: "elapsed 11m02s"},
198+ {time: "10:05", action: "deploy started", detail: "rolling out to prod-eu"}
199+ ]
200+ }
201+
132202# Styling With A Class Name
133203
134204Pass ` className ` to attach an arbitrary class to the parent node znai creates.
@@ -161,4 +231,5 @@ inside the parameters surfaces the page and the rendered block.
161231The function below powers the examples on this page. It reads the initial
162232theme and subscribes to future changes.
163233
164- :include-file: javascript/theme-box.js {title: "plugins/javascript/theme-box.js"}
234+ :include-file: javascript/theme-box.js {title: "plugins/javascript/theme-box.js", collapsed: true, noGap: true}
235+ :include-file: javascript/activity-feed.js {title: "plugins/javascript/activity-feed.js", collapsed: true, noGap: true}
0 commit comments