Skip to content

shop: show twelve cards at a time with a Show more button - #31

Merged
Aswinmcw merged 1 commit into
mainfrom
feat/shop-grid-show-more
Sep 3, 2026
Merged

shop: show twelve cards at a time with a Show more button#31
Aswinmcw merged 1 commit into
mainfrom
feat/shop-grid-show-more

Conversation

@Aswinmcw

@Aswinmcw Aswinmcw commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

The shop grid rendered all 80 products at once, which on a 390px phone is a ~9,000px block that pushed How It Works, the quote form and the footer far below anything a visitor would scroll to. It now shows 12 (three desktop rows / six phone rows) and a Show N more button with "Showing 12 of 80".

  • renderProducts() slices to shopLimit. The limit resets to the first page whenever the category, price band or search changes (keyed on the filter state rather than reset by every caller).
  • "Show more" appends the next 12 and moves focus to the first new card so keyboard/screen-reader users continue from where they were.
  • openSharedProduct() (the /p/<slug> → homepage handoff) extends the page far enough to reach the requested card instead of silently doing nothing when it is past the first twelve.
  • Server side, rewriteHome() renders the identical first page: every card is still in the HTML for crawlers (that is how they reach all product pages), but cards past SHOP_PAGE carry .is-overflow (display: none) and #shopMore is prefilled, so the first paint and the JS redraw agree and nothing shifts.
  • SHOP_PAGE lives in both src/seo.js and main.js and must match; the comments say so.

Measured locally on a 390px viewport: the shop section went from ~9,000px to 3,207px.

Test plan

  • npm test green
  • Playwright vs wrangler dev: 12 cards after load → 24 after Show more, focus on first new card; selecting a category resets to 12 with "Show 6 more / Showing 12 of 18"; back to All resets; no console errors; no sideways layout on mobile
  • After deploy: view-source / shows .product-card.is-overflow from the 13th card and a prefilled #shopMore

Made with Cursor

@Aswinmcw
Aswinmcw requested review from a team and Aswin-coder as code owners September 3, 2026 09:15

@Aswincloud-Bot Aswincloud-Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Auto-approved: @Aswinmcw is a member of @Aswincloud/admins.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 3, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
3d-printing b54243f Commit Preview URL

Branch Preview URL
Sep 03 2026, 09:47 AM

@Aswinmcw
Aswinmcw added this pull request to the merge queue Sep 3, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Sep 3, 2026
The grid rendered every product at once — 80 cards, a ~9,000px stretch of a
phone screen — and buried How It Works, the quote form and the footer under
the catalogue. Twelve at a time is three desktop rows or six on a phone; the
button says how many are left and how many are shown.

- renderProducts() slices to shopLimit; a change of filter or search resets
  to the first page (keyed on the filter state, since renderProducts has a
  dozen callers). "Show more" focuses the first newly-added card.
- openSharedProduct() extends the page to reach a /p/<slug> handoff that
  sits past the first twelve rather than doing nothing.
- The Worker renders the same first page: cards past SHOP_PAGE carry
  .is-overflow (display: none) so every product link stays in the HTML for
  crawlers, and #shopMore is pre-filled so the first paint matches what
  main.js redraws.

Co-authored-by: Cursor <cursoragent@cursor.com>
@Aswinmcw
Aswinmcw force-pushed the feat/shop-grid-show-more branch from b6fb895 to b54243f Compare September 3, 2026 09:47
@Aswinmcw
Aswinmcw added this pull request to the merge queue Sep 3, 2026
Merged via the queue into main with commit afc7d63 Sep 3, 2026
6 checks passed
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.

3 participants