Skip to content

feat: refactor CheckoutLink component, add stories & specs#770

Merged
acasazza merged 2 commits into
v5.0.0from
feat/769-checkout-link-refactor
May 21, 2026
Merged

feat: refactor CheckoutLink component, add stories & specs#770
acasazza merged 2 commits into
v5.0.0from
feat/769-checkout-link-refactor

Conversation

@acasazza
Copy link
Copy Markdown
Member

Closes #769

Changes

<CheckoutLink> component

  • async/await in handleClick (replaces .then())
  • target prop read in handleClick and forwarded to window.open
  • customDomain prop added (aligned with <CartLink>)
  • label widened from string to string | ReactNode
  • ChildrenProps now exposes handleClick, orderId, accessToken, and checkoutUrl: string | undefined
  • Navigation uses window.open(url, target ?? '_self') consistently
  • JSDoc updated: requirement references <Order> instead of deprecated <OrderContainer>
  • Return type narrowed to JSX.Element | null

Stories — docs package

  • Replace <OrderContainer> with <Order>
  • Add WithOrderCheckoutUrl (hostedCheckout: false) and ChildrenProps (render prop) stories
  • Add sourceState: 'shown' to Default

Stories — document package

  • New CheckoutLink.stories.tsx with full DocsPage, ArgTypes, Source blocks, and three stories

Storybook UX — document package

  • Custom storybook-manager.css with sidebar styling
  • Fix missing caret arrows on expandable sidebar items (::before pseudo-element + aria-expanded rotation)

Specs

  • New checkout-link.spec.tsx — 16 unit tests covering rendering, handleClick navigation (org config, fallback, target), and children render prop

- async/await in handleClick (replaces .then())
- target prop forwarded to window.open
- customDomain prop added (aligned with CartLink)
- label widened to string | ReactNode
- ChildrenProps exposes handleClick, orderId, accessToken
- JSDoc updated to reference <Order> instead of deprecated <OrderContainer>
- New stories in docs and document packages (Default, WithOrderCheckoutUrl, ChildrenProps)
- Storybook UX: custom sidebar CSS with caret arrows fix
- 16 unit tests covering rendering, navigation, and render prop

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@acasazza acasazza requested a review from gciotola May 20, 2026 16:13
@acasazza acasazza added enhancement New feature or request components Components package refactor labels May 20, 2026
…ckfile mismatch

Move all pnpm.overrides from package.json into pnpm-workspace.yaml (single source of truth).
Regenerate pnpm-lock.yaml so all overrides are reflected and CI --frozen-lockfile passes.

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

pkg-pr-new Bot commented May 20, 2026

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

commit: 375c7ac

@acasazza acasazza requested a review from pfferrari May 20, 2026 16:30
@acasazza acasazza self-assigned this May 20, 2026
@acasazza acasazza merged commit 0cd085a into v5.0.0 May 21, 2026
2 checks passed
@acasazza acasazza deleted the feat/769-checkout-link-refactor branch May 21, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

components Components package enhancement New feature or request refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants