@hanzo/commerce 1.0.10 → 1.0.11

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.
@@ -1,17 +1,16 @@
1
1
  'use client'
2
2
  import React, { type PropsWithChildren, useState } from 'react'
3
+ import { useRouter } from 'next/navigation'
3
4
  import { observer } from 'mobx-react-lite'
4
5
 
5
6
  import { Button } from '@hanzo/ui/primitives'
6
7
  import { cn } from '@hanzo/ui/util'
8
+ import { useAuth } from '@hanzo/auth/service'
7
9
 
8
10
  import { persistCart, useCommerce } from '../service'
9
11
  import { formatPrice } from '../util'
10
12
 
11
13
  import CartLineItem from './cart-line-item'
12
- import { useRouter } from 'next/navigation'
13
- import { useAuth } from '@hanzo/auth/service'
14
-
15
14
 
16
15
  const Cart: React.FC<PropsWithChildren & {
17
16
  className?: string
@@ -24,14 +23,14 @@ const Cart: React.FC<PropsWithChildren & {
24
23
  hideCheckout=false
25
24
  }) => {
26
25
  const [loadingCheckout, setLoadingCheckout] = useState(false)
27
- const c = useCommerce()
26
+ const cmmc = useCommerce()
28
27
  const router = useRouter()
29
28
  const auth = useAuth()
30
29
 
31
30
  const checkout = async () => {
32
31
  setLoadingCheckout(true)
33
32
  if (auth.user) {
34
- await persistCart(c.cartItems, auth.user.email)
33
+ await persistCart(cmmc.cartItems, auth.user.email)
35
34
  }
36
35
  router.push('/checkout')
37
36
  }
@@ -41,14 +40,14 @@ const Cart: React.FC<PropsWithChildren & {
41
40
  {children}
42
41
  <div className='mt-2'>
43
42
  {!!children && <div className='h-[1px] w-pr-80 mx-auto bg-muted-3'/>}
44
- {c.cartItems.length === 0 ? (
43
+ {cmmc.cartItems.length === 0 ? (
45
44
  <p className='text-center mt-4'>No items in cart</p>
46
45
  ) : (<>
47
- {c.cartItems.map((item, i) => (<CartLineItem isMobile={isMobile} item={item} key={item.sku} className='mb-4 sm:mb-2'/>))}
48
- <p className='mt-6 text-right border-t pt-1'>TOTAL: {c.cartTotal === 0 ? '0' : formatPrice(c.cartTotal)}</p>
46
+ {cmmc.cartItems.map((item, i) => (<CartLineItem isMobile={isMobile} item={item} key={item.sku} className='mb-4 sm:mb-2'/>))}
47
+ <p className='mt-6 text-right border-t pt-1'>TOTAL: {cmmc.cartTotal === 0 ? '0' : formatPrice(cmmc.cartTotal)}</p>
49
48
  </>)}
50
49
  </div>
51
- {c.cartItems.length > 0 && !hideCheckout && (
50
+ {cmmc.cartItems.length > 0 && !hideCheckout && (
52
51
  <>
53
52
  {!auth.loggedIn ? (
54
53
  <Button size='lg' variant='secondary' rounded='lg' className='mt-12 mx-auto' onClick={() => router.push('/login?redirectUrl=checkout')}>Login</Button>
@@ -83,13 +83,13 @@ const SelectItemInCategoryView: React.FC<React.HTMLAttributes<HTMLDivElement> &
83
83
  <Skeleton className={'min-h-[120px] w-pr-60 mx-auto ' + className} />
84
84
  ) : (
85
85
  <div /* id='CV_AVAIL_AMOUNTS' */ className={cn(
86
- 'w-full md:w-auto flex flex-col justify-start items-center',
86
+ 'sm:w-pr-80 sm:mx-auto md:w-full flex flex-col justify-start items-center',
87
87
  (soleOption ? 'gap-2' : mobilePicker ? 'gap-4' : 'gap-8'),
88
88
  className
89
89
  )}>
90
90
  <div className='w-full flex flex-col justify-start items-center'>
91
91
  <h6 className='text-center font-semibold'>{`Available size${soleOption ? '' : 's'}`}</h6>
92
- <div className={'h-[1px] bg-muted-3 ' + (mobilePicker ? 'w-pr-55' : 'w-pr-70') } />
92
+ <div className={'h-[1px] bg-muted-3 ' + (mobilePicker ? 'w-pr-55' : 'w-pr-80') } />
93
93
  </div>
94
94
  {soleOption ? (
95
95
  <p>{category.products[0].titleAsOption}</p>
@@ -107,8 +107,8 @@ const SelectItemInCategoryView: React.FC<React.HTMLAttributes<HTMLDivElement> &
107
107
  products={category.products}
108
108
  selectedSku={lineItemRef.item?.sku ?? undefined}
109
109
  onValueChange={handleItemSelected}
110
- groupClx='block xs:columns-2 xs:px-3 columns-3 gap-2 lg:columns-2 lg:gap-6 w-full lg:auto'
111
- itemClx='flex flex-row gap-2 items-center mb-3 xs:mb-5'
110
+ groupClx='grid grid-cols-2 gap-0 gap-y-3 gap-x-8 '
111
+ itemClx='flex flex-row gap-2 items-center'
112
112
  />
113
113
  )
114
114
  )}
@@ -128,11 +128,11 @@ const SelectItemInCategoryView: React.FC<React.HTMLAttributes<HTMLDivElement> &
128
128
  waiting() ? (<Skeleton className={'h-12 w-pr-80 mx-auto ' + className} />) : (
129
129
 
130
130
  <div className={cn('flex flex-col justify-start items-center mb-6', className)}>
131
- <h3 className='text-lg lg:text-xl font-heading text-center'>
132
- <span className='xs:inline sm:hidden md:inline lg:hidden'>
131
+ <h3 className='text-base md:text-lg lg:text-2xl md:mt-[2vw] font-nav text-center'>
132
+ <span className='xs:inline md:hidden'>
133
133
  {category.title.split(', ').map((s, i) => (<p key={i}>{s}</p>))}
134
134
  </span>
135
- <span className='xs:hidden sm:inline md:hidden lg:inline'>
135
+ <span className='xs:hidden md:inline '>
136
136
  {category.title}
137
137
  </span>
138
138
  </h3>
@@ -174,12 +174,17 @@ const SelectItemInCategoryView: React.FC<React.HTMLAttributes<HTMLDivElement> &
174
174
  ) : (
175
175
  <div /* id='CV_OUTERMOST' */>
176
176
  <div /* id='CV_OUTER' */ className={cn('w-full flex flex-row justify-between items-stretch gap-6 sm:gap-4', className)} {...props}>
177
- <div /* id='CV_IMAGE_COL' */ className={'relative ' + (!isLoading ? 'w-pr-33' : '')}>
178
- <CategoryImage className='' />
177
+ <div /* id='CV_IMAGE_COL_SEP' */ className={'relative ' + (!isLoading ? 'md:hidden sm:min-w-[185px] xl:flex xl:w-pr-40' : '')}>
178
+ <CategoryImage className='w-full' />
179
179
  </div>
180
- <div /* id='CV_CONTENT_COL */ className='w-pr-66'>
180
+ <div /* id='CV_CONTENT_COL */ className='flex flex-col gap-y-6 xl:w-pr-60'>
181
+ <div /* id='CV_MD_IMAGE_AND_TITLE */ className='hidden md:flex xl:hidden flex-row gap-x-3'>
182
+ <CategoryImage className='min-w-pr-30' />
183
+ <TitleArea className='grow' />
184
+ </div>
185
+
181
186
  <div /* id='CV_CONTENT' */ className={'flex flex-col gap-2.5 ' + (isLoading ? 'justify-between h-full' : '')}>
182
- <TitleArea className='' />
187
+ <TitleArea className='md:hidden xl:flex' />
183
188
  <Desc className='' />
184
189
  </div>
185
190
  <div /* id='CV_CTA_AREA_BIG' */ className='hidden lg:flex p-4 flex-col justify-start items-center gap-6'>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Library with shopping cart components.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -33,7 +33,7 @@
33
33
  "react-mobile-picker": "^1.0.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@hanzo/auth": "^1.0.9",
36
+ "@hanzo/auth": "^1.0.12",
37
37
  "@hanzo/ui": "^1.0.8",
38
38
  "firebase": "^10.8.0",
39
39
  "mobx": "^6.12.0",