Skip to content

docs(useLightbox): add hook docs and a gallery grid example block - #9752

Merged
cixzhang merged 3 commits into
meta:mainfrom
Geervan:docs/use-lightbox
Nov 4, 2026
Merged

cixzhang merged 3 commits into
meta:mainfrom
Geervan:docs/use-lightbox

Conversation

@Geervan

@Geervan Geervan commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #9491

useLightbox is a public hook exported from @astryxdesign/core/Lightbox (and @astryxdesign/core), but previously lacked a standalone HookDoc (useLightbox.doc.mjs) and a runnable example block conforming to architecture:knowledge-contracts INV28. As a result, astryx hook useLightbox did not recognize it and the hook had no dedicated page in the docsite.

This PR adds:

  1. packages/core/src/Lightbox/useLightbox.doc.mjs defining parameters (options.media, options.hasZoom, options.hasAutoPlay), return values (open, close, isOpen, index, element, triggerProps, getTriggerProps), usage guidelines, and best practices.
  2. packages/cli/assets/templates/blocks/components/Lightbox/LightboxHookUsage.{tsx,doc.mjs} providing a minimal, runnable example block (useLightbox — Gallery Grid) displaying a 3-column thumbnail grid with six photos from local template assets, spreading lightbox.getTriggerProps(i) onto each thumbnail and rendering lightbox.element.
  3. Updated internal/shadcn-registry/routes.lock.json and a paired .changeset/hook-doc-use-lightbox.md.

Acceptance Criteria Checklist

  • Template block names useLightbox in exampleFor and renders in the Examples section of the hook's docsite page.
  • Visibly driven by the hook: removing useLightbox breaks the example (thumbnails lose button semantics, keyboard focus, and activation handlers, and the lightbox element is omitted).
  • Conforms to architecture:knowledge-contracts INV28 (minimal, public entry points only, covers core params and return values).
  • HookDoc matches actual types in useLightbox.tsx and Lightbox.tsx.

Verification

  • node scripts/check-knowledge.mjs — PASS
  • node scripts/check-changesets.mjs — PASS (78 valid changesets)
  • node scripts/check-package-boundaries.js — PASS
  • pnpm -F @astryxdesign/core typecheck — PASS
  • pnpm -F @astryxdesign/cli typecheck:template-docs — PASS
  • pnpm vitest run packages/core/src/Lightbox/useLightbox.test.tsx packages/core/src/Lightbox/Lightbox.test.tsx — PASS (63/63 tests)
  • pnpm -F @astryxdesign/docsite test src/__tests__/example-coverage.test.ts — PASS (useLightbox verified present with hook doc and example block)
  • node packages/cli/clients/cli/bin/astryx.mjs hook useLightbox — PASS (formats documentation)
  • node packages/cli/clients/cli/bin/astryx.mjs search useLightbox — PASS (finds hook and template block)

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 6:52pm UTC

Request Review

@Geervan
Geervan requested a review from josephfarina as a code owner November 3, 2026 13:58
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 10:03 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 6ddd3fc

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Lightbox · Storybook 50.6 kB (0) · 10.2 kB CSS (0) 820 (0) ✓ · ✓ · ✓

Package size:

  • @astryxdesign/cli 3.31 MB packed (+337 B); no new dependencies
  • @astryxdesign/core 6.11 MB packed (+1.1 kB); no new dependencies

API changes: none in this pull request

Committed API report behind this build: core 50 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up. The hook doc and the gallery example match the hook, and the example works as the issue describes: a click opens the viewer at that photo, the arrow keys move through the gallery, and Escape returns focus to the thumbnail. Two fixes are needed before this can merge:

  • Remove the template-blank entry from internal/shadcn-registry/routes.lock.json, because the docsite generator skips scaffold templates, so apps/docsite/scripts/generate-data.mjs now fails with "Generated ShadCN names or routes changed" (rerunning it with UPDATE_SHADCN_ROUTE_LOCK=1 writes the correct file).
  • Add "/templates/LightboxHookUsage/", after "/templates/LightboxGallery/", in apps/sandbox/scripts/next-export-routes.json, because apps/sandbox/src/route-manifest.test.ts fails without the new block's page.

[Automated review]

Comment on lines +4984 to +4988
{
"name": "template-blank",
"path": "templates/blank",
"aliases": []
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template-blank entry is not something the generator produces: the Blank page template is a scaffold, and apps/docsite/scripts/generate-data.mjs skips scaffolds. With it, the route-lock check in generate-data.mjs fails with "Generated ShadCN names or routes changed". Please delete these five lines, or regenerate the lock with UPDATE_SHADCN_ROUTE_LOCK=1 node apps/docsite/scripts/generate-data.mjs.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick follow-up: the stray route-lock entry is gone, the sandbox route is in, and the docsite build and the sandbox route test now pass. One fix is still needed before this can merge:

  • In LightboxHookUsage.tsx, key the thumbnails by photo.alt instead of photo.src, because astryx template and the ShadCN install replace all six photos with the same placeholder, so the copied example logs React "Encountered two children with the same key" errors.

The hook doc and the example otherwise match the hook: a click opens the viewer at that photo, the arrow keys move through the gallery, and Escape returns focus to the thumbnail.

[Automated review]

<Grid columns={3} gap={2} width={304}>
{PHOTOS.map((photo, i) => (
<img
key={photo.src}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When someone copies this block with astryx template LightboxHookUsage or the ShadCN install, every /template-assets/ photo becomes the same placeholder image, so all six keys become one string and React logs "Encountered two children with the same key". The alts are unique and survive the copy:

key={photo.alt}

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready to merge. Keying the thumbnails by photo.alt fixes the last item from the earlier review: the copied example now renders without duplicate-key errors.

The hook doc matches useLightbox's options and return values. The gallery-grid example opens the viewer at the clicked photo, moves through the gallery with the arrow keys, and returns focus to the thumbnail on Escape. Docsite data generation, the production build and the sandbox route test pass on this revision; CI is still waiting for a maintainer's ci:run label.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 4, 2026
@cixzhang cixzhang closed this Nov 4, 2026
@cixzhang cixzhang reopened this Nov 4, 2026
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 4, 2026
@cixzhang
cixzhang merged commit ff5b5ac into meta:main Nov 4, 2026
107 of 111 checks passed
cixzhang added a commit that referenced this pull request Nov 4, 2026
…tion, and the recorded module resolutions follow core (#9851)

* test(cli): the recorded module resolutions follow useLightbox's doc and drop the deleted usePressPin

#9752 gave useLightbox its own doc; #9756 deleted the internal
Layer/usePressPin.ts. Each was green alone because PR checks skip this
fixture test; main test-node fails on both lines.

* test(Tokenizer): the sheet-row test passes presentation, not the removed experimental prop

#9808 added the test with experimental.presentation; #9836 removed that
prop. Each was green alone; together main typecheck fails (TS2769).
Same change as #9847, folded in here so one pull request turns main green.

Co-authored-by: Xinzi Zhou <[email protected]>

This branch was successfully deployed

1 active deployment
Preview — 6ddd3fcc Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(useLightbox): add hook docs and a minimal live example

2 participants