@hanzo/commerce 4.3.0 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ 'use client'
2
+ import React, {type PropsWithChildren} from 'react'
3
+
4
+ import BuyItemPopup from './buy-item-popup'
5
+ import BuyItemMobileDrawer from './buy-item-mobile-drawer'
6
+
7
+ const BuyItemButtonWrapper: React.FC<{
8
+ skuPath: string
9
+ desktopTrigger: React.ReactNode
10
+ mobileTrigger: React.ReactNode
11
+ popupClx?: string
12
+ }> = ({
13
+ skuPath,
14
+ desktopTrigger,
15
+ mobileTrigger,
16
+ popupClx=''
17
+ }) => (<>
18
+ <BuyItemPopup skuPath={skuPath} popupClx={popupClx}>
19
+ {desktopTrigger}
20
+ </BuyItemPopup>
21
+ <BuyItemMobileDrawer skuPath={skuPath} trigger={mobileTrigger} />
22
+ </>
23
+ )
24
+
25
+
26
+
27
+ export default BuyItemButtonWrapper
@@ -40,7 +40,7 @@ const SelectCategoryItemCard: React.FC<React.HTMLAttributes<HTMLDivElement> & It
40
40
  const item = category.products[0] as LineItem
41
41
  return (
42
42
  <div className={cn('flex flex-col justify-center items-center ' + (mobilePicker ? 'h-[180px] ' : 'h-auto min-h-24'), className)}>
43
- <p className='text-lg font-semibold'>{item.titleAsOption + ', ' + formatPrice(item.price)}</p>
43
+ <p className='text-lg text-center font-semibold'>{item.titleAsOption + ', ' + formatPrice(item.price)}</p>
44
44
  </div>
45
45
  )
46
46
  }
@@ -15,9 +15,9 @@ const CloseButton: React.FC<{
15
15
  variant='ghost'
16
16
  size='icon'
17
17
  onClick={onClose}
18
- className={className}
18
+ className={'group ' + className}
19
19
  >
20
- <ChevronLeft className='w-5 h-5'/>
20
+ <ChevronLeft className='w-5 h-5 group-hover:scale-110 transition-scale transition-duration-300'/>
21
21
  </Button>
22
22
  )
23
23
 
@@ -0,0 +1,10 @@
1
+ import React from 'react'
2
+ import { type LucideProps } from 'lucide-react'
3
+
4
+ const BagIcon: React.FC<LucideProps> = (props: LucideProps) => (
5
+ <svg fill="currentColor" viewBox='0 0 20 23' {...props}>
6
+ <path fillRule="evenodd" d="M5 5a5 5 0 0 1 10 0v1h-2V5a3 3 0 1 0-6 0v1H5V5Zm0 1v4h2V6h6v4h2V6h3.5a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1h-17a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1H5Z" clipRule="evenodd"/>
7
+ </svg>
8
+ )
9
+
10
+ export default BagIcon
@@ -3,7 +3,15 @@
3
3
  import { useState } from 'react'
4
4
  import { observer } from 'mobx-react-lite'
5
5
 
6
- import { Dialog, DialogPortal, Separator, Toaster } from '@hanzo/ui/primitives'
6
+ import {
7
+ Accordion,
8
+ AccordionContent,
9
+ AccordionItem,
10
+ AccordionTrigger,
11
+ Dialog,
12
+ DialogPortal,
13
+ Toaster
14
+ } from '@hanzo/ui/primitives'
7
15
  import { cn } from '@hanzo/ui/util'
8
16
  import { useAuth } from '@hanzo/auth/service'
9
17
  import { LoginComponent, AuthWidget } from '@hanzo/auth/components'
@@ -14,6 +22,8 @@ import CartPanel from '../cart-panel'
14
22
  import Payment from './payment'
15
23
  import CloseButton from './close-button'
16
24
  import StepIndicator from './step-indicator'
25
+ import BagIcon from './icons/bag-icon'
26
+ import { formatPrice, useCommerce } from '../..'
17
27
 
18
28
  const CheckoutPanel: React.FC<{
19
29
  open: boolean
@@ -24,6 +34,7 @@ const CheckoutPanel: React.FC<{
24
34
  }) => {
25
35
 
26
36
  const auth = useAuth()
37
+ const cmmc = useCommerce()
27
38
 
28
39
  const [step, setStep] = useState<number>(1)
29
40
  const [orderId, setOrderId] = useState<string>()
@@ -75,10 +86,24 @@ const CheckoutPanel: React.FC<{
75
86
  >
76
87
  <div id='GRID' className='grid grid-cols-1 md:grid-cols-2 justify-center h-full overflow-y-auto md:overflow-y-hidden'>
77
88
  <div className='bg-background flex flex-row items-start justify-end'>
78
- <div className='h-full w-full max-w-[750px] relative flex flex-col items-center justify-start px-6 py-8 sm:py-20 '>
79
- <CloseButton onClose={onClose} className='absolute top-2 left-4 w-auto h-auto rounded-full bg-level-1 hover:bg-level-2 hover:border-muted p-2' />
80
- <AuthWidget hideLogin className='flex md:hidden absolute top-4 right-4 '/>
81
- <CartPanel noCheckout className='md:border md:border-muted-2 mt-10 w-full max-w-[550px]'/>
89
+ <div className='h-full w-full max-w-[750px] relative flex flex-col items-center justify-start px-6 pt-10 pb-0 md:pb-9'>
90
+ <CloseButton onClose={onClose} className='absolute top-3 left-3 w-auto h-auto rounded-full bg-level-1 hover:bg-level-2 hover:border-muted p-2' />
91
+ <AuthWidget hideLogin className='flex md:hidden absolute top-3 right-3'/>
92
+ <CartPanel noCheckout className='border border-muted-2 mt-10 w-full max-w-[550px] hidden md:flex'/>
93
+
94
+ <Accordion type="single" collapsible className='flex items-center justify-center py-2 w-full md:hidden'>
95
+ <AccordionItem value="cart" className='w-full border-b-0'>
96
+ <AccordionTrigger className='!no-underline'>
97
+ <div className='flex gap-4 items-center'>
98
+ <BagIcon className='w-4 h-4 sm:w-6 sm:h-6'/>
99
+ <h5 className='text-sm sm:text-xl truncate'>Order Summary {formatPrice(cmmc.cartTotal)}</h5>
100
+ </div>
101
+ </AccordionTrigger>
102
+ <AccordionContent>
103
+ <CartPanel noCheckout className='border-none w-full'/>
104
+ </AccordionContent>
105
+ </AccordionItem>
106
+ </Accordion>
82
107
  </div>
83
108
  </div>
84
109
  <div className='bg-level-1 flex flex-row items-start justify-start'>
@@ -1,4 +1,5 @@
1
1
  export { default as AddToCartWidget } from './add-to-cart-widget'
2
+ export { default as BuyItemButtonWrapper } from './buy-item/buy-item-button-wrapper'
2
3
  export { default as BuyItemButton } from './buy-item/buy-item-button'
3
4
  export { default as BuyItemCard } from './buy-item/buy-item-card'
4
5
  export { default as BuyItemPopup } from './buy-item/buy-item-popup'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "4.3.0",
3
+ "version": "4.3.2",
4
4
  "description": "Library with shopping cart components.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",