Skip to content

feat(docs): Record example heights in the screenshot index and catalog - #123

Merged
techniq merged 1 commit into
nextfrom
techniq/docs-example-heights
Dec 2, 2026
Merged

techniq merged 1 commit into
nextfrom
techniq/docs-example-heights

Conversation

@techniq

@techniq techniq commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Records each example's rendered height so a docs page can hold the example's space before it renders. LayerChart wants this for its WebGL layer toggle: an example renders nothing while its WebGL version loads, so without a known height the page jumps when it arrives.

Changes

  • generate-screenshots: measures the .example element's height after the page is ready (before .screenshot-hidden controls are hidden, as they take up space on the page) and writes it as height on each entry in <screenshots-dir>/index.json.
    • Unchanged examples keep their recorded height.
    • Unchanged examples with no recorded height yet (every example, on the first run after this) are opened and measured without re-encoding their images, so the first run fills in heights without --all or touching the screenshots.
    • On an error, the previous height is kept, like the checksum.
  • generate-catalog --screenshots <dir>: reads heights from that screenshot index into each catalog example's height. Without the flag, heights are carried over from the existing catalog, the way example dates already are.
  • ExampleInfo.height?: number, plus a note and the flag in the CLI guide.

Heights are measured at the screenshot viewport (800px), so they're exact for content of a fixed height (ex. a chart with height={300}) and close for content that scales with width.

Testing

Ran both generators from the built package against LayerChart's docs dev server, on a scratch copy of its screenshot index:

  • With one example's images removed: it was captured fresh and the other 4 unchanged examples were only measured (300 / 300 / 300 / 370px); index.json got all 5 heights.
  • A second run skipped all 5 without re-measuring.
  • writeExampleCatalogs({ screenshotsDir }) copied the heights into the catalog; examples without one have no height.

svelte-check: 0 errors (1 existing warning in Step.svelte). Prettier is clean.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying layerstack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 851f4e0
Status:🚫  Build failed.

View logs

@changeset-bot

changeset-bot Bot commented Dec 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 851f4e0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@layerstack/docs Minor
@layerstack/docs-site Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Dec 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@layerstack/docs

npm i https://pkg.pr.new/@layerstack/docs@123

@layerstack/svelte-actions

npm i https://pkg.pr.new/@layerstack/svelte-actions@123

@layerstack/svelte-state

npm i https://pkg.pr.new/@layerstack/svelte-state@123

@layerstack/svelte-stores

npm i https://pkg.pr.new/@layerstack/svelte-stores@123

@layerstack/svelte-table

npm i https://pkg.pr.new/@layerstack/svelte-table@123

@layerstack/tailwind

npm i https://pkg.pr.new/@layerstack/tailwind@123

@layerstack/utils

npm i https://pkg.pr.new/@layerstack/utils@123

commit: 851f4e0

@techniq
techniq merged commit 0c37946 into next Dec 2, 2026
4 of 6 checks passed
@techniq
techniq deleted the techniq/docs-example-heights branch December 2, 2026 18:43
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
layerstack ✅ Ready (View Log) Visit Preview 851f4e0

This branch was successfully deployed

1 active deployment
Preview — 851f4e0d Deployed Dec 2, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant