Skip to content

Commit

Permalink
Merge pull request #2338 from graphcommerce-org/chore/pass-sx-prop-to…
Browse files Browse the repository at this point in the history
…-EmptyCart-component

Chore/pass sx prop to empty cart component
  • Loading branch information
paales authored Aug 5, 2024
2 parents 1f5f892 + 9a68f02 commit 90b8475
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-chefs-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphcommerce/magento-cart': patch
---

Pass sx props to EmptyCart component
2 changes: 1 addition & 1 deletion examples/magento-graphcms/pages/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function CartPage() {
</OverlayStickyBottom>
</>
) : (
<EmptyCart>{error && <ApolloCartErrorAlert error={error} />}</EmptyCart>
<EmptyCart disableMargin>{error && <ApolloCartErrorAlert error={error} />}</EmptyCart>
)}
</WaitForQueries>
</>
Expand Down
2 changes: 1 addition & 1 deletion examples/magento-graphcms/pages/checkout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function ShippingPage() {
}
>
{shippingPage.error && <ApolloCartErrorFullPage error={shippingPage.error} />}
{!shippingPage.error && !cartExists && <EmptyCart />}
{!shippingPage.error && !cartExists && <EmptyCart disableMargin />}
{!shippingPage.error && cartExists && (
<ComposedForm>
<LayoutHeader
Expand Down
4 changes: 3 additions & 1 deletion examples/magento-graphcms/pages/checkout/item/[url].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function CartItemEdit(props: Props) {
}
>
{!cartItem && (
<EmptyCart>{cart.error && <ApolloCartErrorAlert error={cart.error} />}</EmptyCart>
<EmptyCart disableMargin>
{cart.error && <ApolloCartErrorAlert error={cart.error} />}
</EmptyCart>
)}
{cartItem && (
<EditCartItemForm
Expand Down
2 changes: 1 addition & 1 deletion examples/magento-graphcms/pages/checkout/payment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function PaymentPage() {
}
>
{billingPage.error && <ApolloCartErrorFullPage error={billingPage.error} />}
{!billingPage.error && !cartExists && <EmptyCart />}
{!billingPage.error && !cartExists && <EmptyCart disableMargin />}
{cartExists && !billingPage.error && (
<>
<LayoutHeader
Expand Down
12 changes: 8 additions & 4 deletions packages/magento-cart/components/EmptyCart/EmptyCart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import {
FullPageMessageProps,
} from '@graphcommerce/next-ui'
import { Trans } from '@lingui/react'
import { Button } from '@mui/material'
import { Button, SxProps, Theme } from '@mui/material'
import React from 'react'

type EmptyCartProps = { children?: React.ReactNode } & Pick<FullPageMessageProps, 'button'>
type EmptyCartProps = {
children?: React.ReactNode
sx?: SxProps<Theme>
} & Pick<FullPageMessageProps, 'button' | 'disableMargin'>

export function EmptyCart(props: EmptyCartProps) {
const { children, button } = props
const { children, button, ...rest } = props

return (
<FullPageMessage
sx={(theme) => ({ mt: { md: theme.spacings.md } })}
title={<Trans id='Your cart is empty' />}
icon={<IconSvg src={iconShoppingBag} size='xxl' />}
button={
Expand All @@ -24,6 +27,7 @@ export function EmptyCart(props: EmptyCartProps) {
</Button>
)
}
{...rest}
>
{children ?? <Trans id='Discover our collection and add items to your cart!' />}
</FullPageMessage>
Expand Down

0 comments on commit 90b8475

Please sign in to comment.