Skip to content

✨ feat(stories): add HostedCart stories in document package#774

Merged
acasazza merged 10 commits into
v5.0.0from
feat/hosted-cart-stories
May 25, 2026
Merged

✨ feat(stories): add HostedCart stories in document package#774
acasazza merged 10 commits into
v5.0.0from
feat/hosted-cart-stories

Conversation

@acasazza
Copy link
Copy Markdown
Member

Summary

Adds a full DocsPage story for HostedCart under Components/Cart/HostedCart in the document package.

Stories

Story Description
Default — inline cart Inline <iframe> that fills the container, height auto-adjusted by iframe-resizer
Mini cart Slide-in panel with open toggle via Controls
Mini cart — auto-open on add Opens automatically when items are added via <AddToCartButton> (openAdd=true)
Custom domain Demonstrates the customDomain prop for self-hosted cart apps

Notes

  • Uses the OrderStorage internal helper which auto-creates an order with items
  • Follows the same pattern as CheckoutLink.stories.tsx and AddToCartButton.stories.tsx
  • Type-checks clean ✅

Add DocsPage with ArgTypes, Source and 4 Canvas stories:
- Default (inline cart iframe)
- MiniCart (slide-in panel with open control)
- MiniCartOpenAdd (auto-opens on AddToCartButton)
- CustomDomain

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@acasazza acasazza added documentation Improvements or additions to documentation components Components package labels May 22, 2026
…ng, remove stale ts-expect-error

- Add HostedCart to packages/react-components/src/index.ts exports
- Capture accessToken as const token: string after null guard so closures see the narrowed type
- Remove unused @ts-expect-error on iframeResizer onMessage (type now resolves correctly)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 22, 2026

npm i https://pkg.pr.new/@commercelayer/react-components@774

commit: ed609c9

Alessandro Casazza and others added 8 commits May 22, 2026 16:12
- Remove MiniCart and MiniCartOpenAdd stories from HostedCart.stories.tsx
- Create MiniCart.stories.tsx under Components/Cart/MiniCart with its own DocsPage
  - Default story (open toggle via Controls)
  - OpenOnAdd story (auto-open with AddSampleItems trigger)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…+ AddToCartButton

- Default story: use local useState + CartLink type='mini' as trigger,
  wire handleOpen to toggle state so overlay/close button work correctly
- OpenOnAdd story: replace AddSampleItems (SDK only) with AddToCartButton
  which publishes the 'open-cart' event that HostedCart openAdd listens for
- Fix DocsPage: add Canvas for both stories, mark open argType as control:false

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The mini cart panel is position:fixed so it doesn't affect document flow.
A 500px min-height decorator ensures the canvas always has visible space
regardless of whether the panel is open or closed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
DocsPage with ArgTypes, Source and 3 Canvas stories:
- Default (link to hosted cart)
- MiniCartTrigger (type='mini' + HostedCart integration with open state)
- ChildrenProps (render prop with custom trigger)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…DOMAIN, fix JSDoc

- Destructure `target` from props (no longer swallowed by `...p`)
- Replace `location.href =` with `window.open(url, target ?? '_self')`
- Extract `resolveCartUrl` helper to deduplicate getOrganizationConfig calls
- Add `const token: string = accessToken` narrowing (same pattern as CheckoutLink/HostedCart)
- Extract `DEFAULT_DOMAIN` constant
- Make `handleClick` non-optional in ChildrenProps (always provided)
- Add `event.stopPropagation()` to handleClick
- Fix JSDoc: `<OrderContainer>` → `<Order>`
- Add `target` to parentProps and `<a target={target}>`
- Update CartLink story: add `target` argType

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply biome format --write to align all source files with the configured
formatter settings (double quotes, no semicolons, ES5 trailing commas).

Also:
- Exclude large mock file from biome (3.5 MiB exceeds 1 MiB limit)
- Fix invalid syntax in _vitest.config.mts (orphaned lines at top of file)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@acasazza acasazza requested review from gciotola and pfferrari and removed request for pfferrari May 25, 2026 09:10
@acasazza acasazza self-assigned this May 25, 2026
@acasazza acasazza requested a review from pfferrari May 25, 2026 09:13
@acasazza acasazza merged commit dbbaf0c into v5.0.0 May 25, 2026
2 checks passed
@acasazza acasazza deleted the feat/hosted-cart-stories branch May 25, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components Components package documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants