Skip to content

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 ​

BlockComponentsNotes
Galleryoas-carousel + oas-imageMain image slider with indicators dots
InfoTitle + oas-price + oas-tagPrice follows the chosen variant (oas-change → write value)
Variantsoas-sku (layout="popup")Bottom sheet variant picker; specs / skus contract on the component page
Action baroas-goods-actionIcon group (favorite / shop / cart badge) + main buttons
Recommendationsoas-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

Limited offer

12k sold monthly · SF Express · ships within 48h

VariantsNo variant picked · 1 unitChoose

You may also like

Add to cartBuy again

Press "Choose" to open the variant sheet; pressing "Add to cart" without a complete selection redirects you there first.

Key points:

  1. 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 declares popup explicitly to demo the mobile form.
  2. Open/close is a controlled protocol: openOverlay() opens; drag / backdrop / Esc inside the sheet are handled by the component (it removes open internally and fires oas-open-change) — the host does not take over closing.
  3. Price and summary hang off oas-change: detail { value, quantity, sku, change } — sku is the fully matched object (or null on partial selection); write back to oas-price's value only on a match; the summary text is assembled by the host (variant values + quantity).
  4. The cart badge is a data write-back: oas-action-click (detail { key, source }) → host mutates the cart item's badge in items → rewrites the whole items attribute; the favorite item likewise writes back active (aria-pressed follows automatically).
  5. 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:

  1. The terms checkbox goes in the default slot (the extension area left of the total) — a native checkbox is enough; no switch component needed. The host listens for change and writes disabled.
  2. Submit feedback in three beats: oas-submit → set loading (built-in click lock + spinner + aria-busy) → remove it on success and surface the order feedback.
  3. 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 ​

  1. Declare the gallery height explicitly: slides carry no intrinsic height — .pd-slide sets a fixed height; oas-image's fit="cover" only crops, it does not size — fill the slide via ::part(wrapper) / ::part(image) at width/height: 100% (this page's style block); pick 1:1 or 4:3 per business.
  2. specs holds selling dimensions only: dimensions that change price or stock (color / size) go into specs (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).
  3. Out-of-stock combinations gray out automatically: skus entries with stock: 0 are 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.
  4. 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.
  5. The page skeleton is host styling: .pd-page max 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.

Released under the MIT OR Apache-2.0 License.