Repository navigation
Shop elements: cart, product-list, product-page - #35
Merged
Merged
Conversation
…, demos or checks yet) Built to the Superhero Shop Worker contract (PR #1, claude/worker-stub). Not finished: catalog entries, demos, GOLDEN categories, check-shop.mjs with mutation tests, skill sections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cart, product-list and product-page join the catalogue under Offers & conversion, with SE Ranking queries, asks and demos run against a fake Worker origin. scripts/check-shop.mjs runs the cart's rules from the source (caps, no price in any request, a fresh key per attempt, the 409 clamp, 503 and network sentences), pins the built drawer's a11y, the product-list cards and the Product JSON-LD, tests fetchCatalog, and catches 38 planted faults. Fixes found in a browser pass: cart styles are global (script-built lines never carry Astro's scope attribute), the Added flash restores the button's own markup, and radio labels keep their spaces. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Three elements for the Superhero Shop add-on ("Pieces to build" item 2 in the shop design note). They are built to the Worker's public contract in ecropolis/SuperheroShop PR #1 (
claude/worker-stub, not yet merged or deployed).cart: a cart button with its count and a drawer (a native<dialog>, copied from off-canvas's pattern).crypto.randomUUID()key, then redirects to Square.product-list: a card grid built at deploy, with a from-price and sized lazy images. Sold out shows from a build-time map or one optional browser stock check.product-page: images, a plain-text description, a variation radio group whose price follows the choice, quantity, and add to cart through the cart's attribute contract. It emits Product JSON-LD with one Offer per variation.fetchCatalog(site): insrc/library/product-list/fetchCatalog.ts. It validates the catalogue and throws one sentence, so a bad catalogue fails the build.connect-src https://shop.superherotech.ai, plusimg-srcfor Square's image host.All three are in "Offers & conversion". Their
akalists name WooCommerce, the Shopify Buy Button, Ecwid and Square Online.Checks
scripts/check-shop.mjsis added tonpm run check. It covers:fetchCatalog.It catches 38 of 38 planted faults. The full chain passes:
I also walked it in a browser at desktop and phone width. That pass found three bugs, all fixed in the second commit:
The website builds against this branch (
ELEMENTS_SOURCE, exit 0) and has the three new/elements/pages. Demos show the JSON-LD as text instead of emitting it, so superherotech.ai publishes no Product markup for a fake product.Contract fields relied on
GET /v1/shops/:site/catalogcurrency,products[].id,slug,name,description,images[],variations[].id,name,price_cents,trackedGET /v1/shops/:site/stock?ids={ [variationId]: number | null }, where null means untrackedPOST /v1/shops/:site/checkout{ items: [{ variationId, quantity }], fulfillment, pickupPoint?, idempotencyKey }; then200 { url },409 { error: "short", short: [{ variationId, available }] },400 { error: "unknown_variation", ids },400 bad_pickup_pointandshipping_unavailable,403,429,503 shop_closedNot defined by the Worker's README
I read these from the Worker's source instead. Worth adding to its README before it merges:
descriptionformat. The README doesn't say. The code passes Square'sdescriptionfield through as plain text and never returns HTML, so the product page renders it as text./stockanswer. Only a code comment says so. The cart treats a missing id as "no longer sold" and removes the line./stocktakes at most 100 ids, and its error bodies arevalidation_failed, theopenShopreasons, and502 stock_unavailable. None of that is in the README./stockanswers only the shop's own origins, so a site build cannot fetch it. That is why product-list's build-timestockprop is mainly for fixtures.{ id, name, details? }is intypes.ts, not the README.{ ok: false, error, detail? }; the README shows only{ error }. Also,413 too_largeis missing from the README's table.object-fit: cover.open. It is a build-time snapshot, so the cart ignores it and trusts the 503.For Warren
_headersbudget. The site's_headersgoes from 92 to 95 of Cloudflare Pages' 100 rules. Its build warns at 95. Three more element pages will hit the cap.img-srcline namesitems-images-production.s3.us-west-2.amazonaws.com, the host in the Worker's README example. Confirm it against a real Sandbox catalogue.claude/shop-elements-skill(house-stack 0.47.0). Merge that with this PR.🤖 Generated with Claude Code