Product detail skeleton (scenario recipe)
A page-level assembly demo: five blocks built entirely from existing components —
oas-carousel(gallery) +oas-price(price) +oas-sku(variant popup) +oas-goods-action(mobile action bar) +oas-submit-bar(checkout variant) +oas-product-card(recommendations). No new component API; the page skeleton and linkage logic are all host code.
Page structure and roles
| Block | Components | Notes |
|---|---|---|
| Gallery | oas-carousel + oas-image | Main image slider with indicators dots |
| Info | Title + oas-price + oas-tag | Price follows the chosen variant (oas-change → write value) |
| Variants | oas-sku (layout="popup") | Bottom sheet variant picker; specs / skus contract on the component page |
| Action bar | oas-goods-action | Icon group (favorite / shop / cart badge) + main buttons |
| Recommendations | oas-product-card (horizontal) | "You may also like", layout="horizontal" leading-image form |
Detail page skeleton
Five blocks: open the variant sheet → price and summary follow → cart badge increments
Canvas sneakers, classic low-top
VariantsNo variant picked · 1 unitChoose
You may also like
Press "Choose" to open the variant sheet; pressing "Add to cart" without a complete selection redirects you there first.
Key points:
- The sku popup is one component, two forms:
layout="popup"pins the bottom sheet (the same panel DOM node is carried over, not rebuilt); below 480px viewport width auto-switches to the sheet and wide screens embed automatically — this page declarespopupexplicitly to demo the mobile form. - Open/close is a controlled protocol:
openOverlay()opens; drag / backdrop / Esc inside the sheet are handled by the component (it removesopeninternally and firesoas-open-change) — the host does not take over closing. - Price and summary hang off
oas-change: detail{ value, quantity, sku, change }—skuis the fully matched object (ornullon partial selection); write back tooas-price'svalueonly on a match; the summary text is assembled by the host (variant values + quantity). - The cart badge is a data write-back:
oas-action-click(detail{ key, source }) → host mutates the cart item'sbadgeinitems→ rewrites the wholeitemsattribute; the favorite item likewise writes backactive(aria-pressedfollows automatically). - The incomplete-selection guard lives in the host: when "Add to cart / Buy now" is pressed with an incomplete combination, the host opens the variant sheet to guide completion — business rules stay out of the component.
Checkout variant: agree-to-terms gating
submit-bar + terms checkbox: disabled until agreed, loading on submit
Agree to unlock "Place order"; the button enters loading while submitting.
Key points:
- The terms checkbox goes in the default slot (the extension area left of the total) — a native
checkboxis enough; no switch component needed. The host listens forchangeand writesdisabled. - Submit feedback in three beats:
oas-submit→ setloading(built-in click lock + spinner +aria-busy) → remove it on success and surface the order feedback. - goods-action and submit-bar are two page forms: detail pages use goods-action (multiple entries + favorite), checkout / confirmation pages use submit-bar (total + one main button) — pick by page role; do not stack two action bars on one screen.
Key code
html
<!-- Page skeleton (five blocks; copy and swap the data) -->
<div class="pd-page">
<section class="pd-gallery" aria-label="Product gallery">
<oas-carousel indicators>
<div class="pd-slide"><oas-image src="…" alt="…" fit="cover"></oas-image></div>
</oas-carousel>
</section>
<section class="pd-info">
<oas-price id="price" value="329" original="459" size="lg"></oas-price>
<div class="pd-sku-row">
<span id="sku-summary">No variant picked</span>
<oas-button id="sku-open">Choose</oas-button>
</div>
</section>
<oas-goods-action id="action" items="…" actions="…"></oas-goods-action>
</div>
<oas-sku id="sku" layout="popup" specs="…" skus="…"></oas-sku>ts
// Three linkages (host side)
skuOpen.addEventListener('oas-click', () => sku.openOverlay())
sku.addEventListener('oas-change', (e) => {
const { value, quantity, sku: matched } = e.detail
summary.textContent = (value ? Object.values(value).join(' / ') : 'No variant picked') + ' · ' + quantity + ' unit(s)'
if (matched) price.setAttribute('value', String(matched.price))
})
action.addEventListener('oas-action-click', (e) => {
// sku.value is a controlled getter that always returns an object (empty when nothing is picked) — test its keys, never write !sku.value (always truthy, the guard would never fire)
if (e.detail.key === 'add' && Object.keys(sku.value ?? {}).length < 2) return sku.openOverlay() // combination incomplete (2 spec groups here, catches partial picks) → guide selection
// the full demo below gates both add and buy; only add is shown here — buy works the same
// …business handling; rewrite items after mutating badge / favorite state
})Notes
- Declare the gallery height explicitly: slides carry no intrinsic height —
.pd-slidesets a fixed height;oas-image'sfit="cover"only crops, it does not size — fill the slide via::part(wrapper)/::part(image)atwidth/height: 100%(this page's style block); pick 1:1 or 4:3 per business. specsholds selling dimensions only: dimensions that change price or stock (color / size) go intospecs(cartesian product); descriptive attributes like origin / material render in the host's info section and must not enter the combination table (see the sku page's specs guidance).- Out-of-stock combinations gray out automatically:
skusentries withstock: 0are unselectable and marked "out of stock" in the sheet; when everything is out the quantity control disables — stock expression is built in; feed the data correctly and that is all. - Action bar accessible name: a page with a single bar can keep the default i18n name; the demo's
label="Product actions"shows the custom form — screen-reader users rely on it to tell which bar this is. - The page skeleton is host styling:
.pd-pagemax width, block gaps and borders are page-level CSS (token-based); the component library does not ship a "detail page layout" — that is exactly what this recipe layer is for.