Repository navigation
Let sites show their own sample products before a store connects - #1528
Open
sbolinger-godaddy wants to merge 4 commits into
Open
sbolinger-godaddy wants to merge 4 commits into
sbolinger-godaddy wants to merge 4 commits into
Conversation
`sampleProducts` takes the site's own samples as well as `true`. Card and cart parts show a sample's image, description, price and Sale badge, and `useProductCard()` and `useCartItem()` return the sample with the site's own fields, so display-only one-offs such as a category line work before and after a store connects. `useCatalog()` gives custom parts the product count, and `--commerce-card-image-aspect` sets the card image ratio. The packaged samples and default design are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 640a8d9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
…ck sample names - Close the custom card example's code fence on its own line, so the rest of the README renders. - Hide a sample's image from screen readers when the card has a title, as live cards do, so its name is read once. - Reject non-string keys and empty names in host samples. - Validate samples with a plain call instead of a side-effect useMemo. - Document that the sample type on useProductCard and useCartItem is unchecked, that sample lists should be stable, and that a failed refetch keeps the last page's count. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbennett1-godaddy
left a comment
Contributor
There was a problem hiding this comment.
A few things I noticed reading through this. None are reproduced yet, so please check my reasoning. I'd look at the key clash and the validation-in-production ones first.
…ow, and keep cart lines current - Reject host samples that use a packaged sample's key, so they never share a sample cart line with one. - Throw for invalid samples only while no store is connected; once one is, log in development and keep the live catalog. - Report entries that are not objects, and a description or imageUrl that is not a string, with the CatalogRoot error. - Compare an inline sample list by value, so an unchanged list does not rebuild every card. - Recognize packaged samples by key instead of object identity, so a copy keeps its localized name. - Refresh cart lines from a mounted catalog's sample of the same key, and list packaged samples in catalog order. - Render nothing from CartItemImage when its image fails to load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbennett1-godaddy
left a comment
Contributor
There was a problem hiding this comment.
I've re-reviewed 1632408, and all 7 earlier points are addressed (replied on each thread). There's one new edge case below.
…of throwing Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pbennett1-godaddy
approved these changes
Nov 3, 2026
pbennett1-godaddy
left a comment
Contributor
There was a problem hiding this comment.
All review points are addressed through 640a8d9, and CI is green. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A template can show its own sample products before a store is connected, with real images. Then it can keep the same customized card once the store's products load. The design follows a compound-component approach: the package adds sample data and hooks, not new display props. Elements that are only display, such as a "Bestseller" label or a category line, are the site's own components, built with the hooks.
sampleProductstakes an array as well astrue. A sample haskey,nameandprice(minor units, USD), and optionallycompareAtPrice,descriptionandimageUrl. An image is any URL the browser can load, such as a file in the site's public folder. The package doesn't upload or check it, and a broken image shows the usual placeholder. Fields of the site's own are kept as they are.CatalogRootthrows for an empty list, duplicate or empty keys, or invalid prices.useProductCard()anduseCartItem()returnsample, typed with the site's sample type (useProductCard<MySample>()). One host component can then work on a card and in the cart.useCatalog()returns{ count, isSample, status }for a custom product count.--commerce-card-image-aspecttheme property sets the ratio of card images and their loading placeholders. It defaults to square.unbound, never reach Commerce and can't check out.truestill shows the six packaged samples with no images. There are no new action, link or badge parts.Changeset
@godaddy/gd-commerce-storefrontminor)Test Plan
extensibility.test.tsx:/configrequestsonEventuseCatalogreports loading and error statesimageUrl/descriptionundefinedmainand against this branch. All 59 screenshots are pixel-identical, including the packaged sample catalog and sample drawer. (One canvas-tote product image sometimes differs by a single pixel between runs; reruns match, so this is rendering noise.)routine.htmlis modeled on a skincare template, built only from public parts and hooks, with images in the app'spublic/folder.npm run routinepasses 5 checks: template samples, sample cart, live products in the same card tree, toggling the store without a reload, and phone width.Photos are from Unsplash. The connected store is the test app's mock catalog.
For review
🤖 Generated with Claude Code