Repository navigation
docs(useLightbox): add hook docs and a gallery grid example block - #9752
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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-blankentry frominternal/shadcn-registry/routes.lock.json, because the docsite generator skips scaffold templates, soapps/docsite/scripts/generate-data.mjsnow fails with "Generated ShadCN names or routes changed" (rerunning it withUPDATE_SHADCN_ROUTE_LOCK=1writes the correct file). - Add
"/templates/LightboxHookUsage/",after"/templates/LightboxGallery/",inapps/sandbox/scripts/next-export-routes.json, becauseapps/sandbox/src/route-manifest.test.tsfails without the new block's page.
[Automated review]
| { | ||
| "name": "template-blank", | ||
| "path": "templates/blank", | ||
| "aliases": [] | ||
| }, |
There was a problem hiding this comment.
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.
…Usage to sandbox routes
There was a problem hiding this comment.
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 byphoto.altinstead ofphoto.src, becauseastryx templateand 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} |
There was a problem hiding this comment.
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}There was a problem hiding this comment.
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]
…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]>
Fixes #9491
useLightboxis 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 toarchitecture:knowledge-contractsINV28. As a result,astryx hook useLightboxdid not recognize it and the hook had no dedicated page in the docsite.This PR adds:
packages/core/src/Lightbox/useLightbox.doc.mjsdefining parameters (options.media,options.hasZoom,options.hasAutoPlay), return values (open,close,isOpen,index,element,triggerProps,getTriggerProps), usage guidelines, and best practices.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, spreadinglightbox.getTriggerProps(i)onto each thumbnail and renderinglightbox.element.internal/shadcn-registry/routes.lock.jsonand a paired.changeset/hook-doc-use-lightbox.md.Acceptance Criteria Checklist
useLightboxinexampleForand renders in the Examples section of the hook's docsite page.useLightboxbreaks the example (thumbnails lose button semantics, keyboard focus, and activation handlers, and the lightbox element is omitted).architecture:knowledge-contractsINV28 (minimal, public entry points only, covers core params and return values).useLightbox.tsxandLightbox.tsx.Verification
node scripts/check-knowledge.mjs— PASSnode scripts/check-changesets.mjs— PASS (78 valid changesets)node scripts/check-package-boundaries.js— PASSpnpm -F @astryxdesign/core typecheck— PASSpnpm -F @astryxdesign/cli typecheck:template-docs— PASSpnpm 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 (useLightboxverified 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)