Skip to content

ProductCard: aspect ratio prop, skeleton sizing fix, dedup related skeleton#233

Merged
laugharn merged 1 commit intomainfrom
product-card-skeleton-aspect-ratio
May 1, 2026
Merged

ProductCard: aspect ratio prop, skeleton sizing fix, dedup related skeleton#233
laugharn merged 1 commit intomainfrom
product-card-skeleton-aspect-ratio

Conversation

@laugharn
Copy link
Copy Markdown
Contributor

@laugharn laugharn commented May 1, 2026

Summary

Three related edits in one PR — together they remove a layout-shift regression, dedupe a skeleton that had drifted, and add a routine catalog feature.

  1. Aspect ratio prop on the product card. `ProductCard`, `ProductCardSkeleton`, and `ProductsSlider` accept an optional `aspectRatio: "landscape" | "portrait" | "square"` (default `"square"`). The image container picks the matching `aspect-*` class via a `data-[aspect-ratio=…]` selector. Existing call sites are unaffected.

  2. Skeleton reserves the right height. The rendered card title is `line-clamp-2`, but the skeleton reserved height for one line plus a short price bar — every grid jumped upward by ~one line the moment data resolved. Three `h-4` bars (two for the wrapping title, one for the price) inside `py-2.5 h-18 box-content grid gap-2` now match the rendered card.

  3. Collapse the duplicate skeleton in `RelatedProductsSectionSkeleton`. It was rendering its own inline tile mirroring what `ProductCardSkeleton` does. The two implementations drifted — that's how (2) regressed. With (2) fixed, the related-products fallback renders `` for each tile and stays in sync automatically. The local `Fallback` helper is renamed to `RelatedProductsSectionSkeleton` and exported so consumers can render it at a parent fallback (e.g. a page-level Suspense) when needed.

Includes a `packages/plugin/template-rollout-log/` entry for downstream forks.

Test plan

  • `tsc --noEmit` clean
  • `pnpm lint` clean (preexisting warnings only)
  • Home page: featured-products grid renders without a vertical jump when products resolve. Skeleton bars fill the same vertical space the title and price take after load.
  • PDP: related-products fallback also has no jump when recommendations resolve.
  • Pass `aspectRatio="portrait"` to a `ProductsSlider` and confirm cards render at 3:4 with the matching skeleton shape.

🤖 Generated with Claude Code

…eleton

Three related edits:

1. Add an optional aspectRatio prop (landscape | portrait | square,
   default square) to ProductCard, ProductCardSkeleton, and
   ProductsSlider. The image container picks the matching aspect-*
   class via a data-[aspect-ratio=...] selector. Existing call sites
   are unaffected.

2. Fix the skeleton's content area. The rendered card title is
   line-clamp-2 but the skeleton reserved height for one line plus a
   short price bar, so the layout jumped upward when data resolved.
   Three h-4 bars (two title, one price) inside py-2.5 h-18
   box-content grid gap-2 now match the rendered card.

3. Collapse the duplicate skeleton in RelatedProductsSectionSkeleton.
   It was rendering its own inline tile that mirrored what
   ProductCardSkeleton does, and the two had drifted — that's how
   (2) crept in. With (2) fixed, the related-products fallback can
   render <ProductCardSkeleton aspectRatio={...} /> for each tile
   and stay in sync. The Fallback helper is renamed to
   RelatedProductsSectionSkeleton and exported so consumers can
   render it at a parent fallback (e.g. a page-level Suspense).

Adds a template-rollout-log entry for downstream forks.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

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

Project Deployment Actions Updated (UTC)
shop-docs Ready Ready Preview, Comment May 1, 2026 0:18am
shop-template Ready Ready Preview, Comment, Open in v0 May 1, 2026 0:18am

@laugharn laugharn merged commit 9ec47d0 into main May 1, 2026
6 checks passed
@laugharn laugharn deleted the product-card-skeleton-aspect-ratio branch May 1, 2026 00:30
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