Skip to content

feat(web): scaffold accelerated checkout buttons element - #789

Draft
rsomlette wants to merge 2 commits into
mainfrom
wallets/component-shell
Draft

rsomlette wants to merge 2 commits into
mainfrom
wallets/component-shell

Conversation

@rsomlette

@rsomlette rsomlette commented Sep 17, 2026

Copy link
Copy Markdown

What

Adds a first-class Wallets view to the web playground (pnpm sample, /wallets.html) for testing <shopify-accelerated-checkout-buttons>, built with the same shell, settings panel, state, storage, and event-log patterns as the existing checkout demo.

Related: https://github.com/shop/issues-checkout/issues/14751

Settings (persisted in localStorage)

  • Store: storefront domain, Storefront access token, country, language
  • Purchase source toggle:
    • Existing cart — product grid + cart builder → "Create cart" calls cartCreate via the Storefront API and writes the returned GID to cart-id
    • Buy now — same product grid in selectable-card mode (click to pick a variant) → sets variant-id, optional selling-plan-id
  • Options: wallet count (0 = all), layout (horizontal / vertical)

Center workspace

  • Element mount with live attribute dump (always visible)
  • Product grid (always visible, loaded from /products.json)
    • Cart mode: Add to cart / quantity controls / cart banner with lines + derived permalink
    • Buy now mode: selectable cards with selected indicator
  • Cart banner (cart mode only) with "Create cart" button

Events panel

  • Every settings change logs property writes + reflected attributes
  • cart.creating / cart.created / cart.error events from the Storefront API call
  • Future element events (wallets.render, wallets.error) wired in — names centralised in WALLETS_EVENT_TYPES
  • New entries flash with an accent highlight animation (shared with the checkout demo)

Element scaffold changes

  • Added layout attribute/property (horizontal default, vertical)
  • Added log-level attribute/property (shared Logger from src/logger.ts)
  • Extracted wallets.types.tsWalletsAttributes, WalletsProperties, WalletsLayout interfaces (mirrors checkout.types.ts)
  • Class now implements WalletsAttributes, WalletsProperties
  • Shadow DOM uses createTemplate(html...) + cloneNode (matches checkout element)
  • JSDoc @attribute annotations for the custom elements manifest
  • Widened renderProducts / renderCart / selectGeneratedCartUrl / createProductLoader to accept interfaces so both demos share the same view code

New files

File Purpose
src/wallets.types.ts Attribute, property, and layout type interfaces
sample/storefront-api.ts cartCreate Storefront API helper (testable, injectable fetcher)
sample/wallets-main.ts Entry point
sample/wallets-state.ts Store and state types
sample/wallets-storage.ts localStorage persistence
sample/wallets-dom.ts DOM refs
sample/wallets-shell.ts HTML shell for tests
sample/wallets-render.ts Top-level render
sample/views/wallets-settings.ts Settings panel render
sample/views/wallets-element.ts Element attribute dump render
sample/views/wallets-log.ts Event log render
sample/views/log-entries.ts Shared incremental log renderer with flash animation
+ .test.ts for each

Checks

  • pnpm test — 353 tests pass
  • pnpm lint — typecheck + sample:typecheck + oxlint + format ✅
  • pnpm build + pnpm sample:build
  • No runtime dependencies added, no changes to the checkout demo behavior

Add ShopifyAcceleratedCheckoutButtons custom element as an empty,
accessible placeholder under the @shopify/checkout-kit/wallets subpath.

- src/wallets.ts: element class with attribute-backed scalar properties
  (store-domain, country, language, cart-id, variant-id, selling-plan-id,
  wallet-count) and bidirectional attribute/property reflection.
- src/wallets-web-component.ts: side-effect registration of the
  <shopify-accelerated-checkout-buttons> tag.
- src/wallets-index.ts: package entry point re-exporting the class.
- src/wallets.test.ts: vitest/happy-dom tests covering registration,
  reflection, walletCount coercion, placeholder rendering, and
  connect/disconnect idempotency.
- sample/wallets.html: local dev page demonstrating property reflection.
- Build wiring: package.json exports, sideEffects, vite multi-entry,
  and sample vite alias.

No runtime dependencies, no network calls, no wallet logic.

Assisted-By: devx/9eeb3f82-e284-440b-a1e8-a2ebb0299422
@github-actions github-actions Bot added the #gsd:50662 Rebase Checkout Kit on UCP label Sep 17, 2026
@rsomlette
rsomlette force-pushed the wallets/component-shell branch 3 times, most recently from 01408ae to 562d50a Compare September 17, 2026 20:19
@rsomlette
rsomlette force-pushed the wallets/component-shell branch from 562d50a to 0d78a48 Compare September 17, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

#gsd:50662 Rebase Checkout Kit on UCP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant