@hanzo/commerce 7.1.26 → 7.1.28

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.
@@ -68,7 +68,7 @@ const AddToCartWidget: React.FC<{
68
68
 
69
69
  const inc = (event: React.MouseEvent<HTMLElement>) => {
70
70
  item.increment()
71
- event.stopPropagation()
71
+ event.stopPropagation() // in case we're part of a larger selection UI
72
72
  sendGAEvent('add_to_cart', {
73
73
  items: [{
74
74
  item_id: item.sku,
@@ -94,7 +94,7 @@ const AddToCartWidget: React.FC<{
94
94
 
95
95
  const dec = (event: React.MouseEvent<HTMLElement>) => {
96
96
  item.decrement()
97
- event.stopPropagation()
97
+ event.stopPropagation() // in case we're part of a larger selection UI
98
98
  sendGAEvent('remove_from_cart', {
99
99
  items: [{
100
100
  item_id: item.sku,
@@ -10,6 +10,7 @@ import {
10
10
  AccordionItem,
11
11
  AccordionTrigger,
12
12
  } from '@hanzo/ui/primitives'
13
+ import { cn } from '@hanzo/ui/util'
13
14
 
14
15
  import { formatCurrencyValue } from '../../util'
15
16
  import { useCommerce } from '../../context'
@@ -18,14 +19,20 @@ import CartPanel from './cart-panel'
18
19
 
19
20
  const CartAccordian: React.FC<{
20
21
  icon?: React.ReactNode
21
- className?: string
22
+ clx?: string
23
+ panelClx?: string
24
+ scrollAfter: number
25
+ scrollHeightClx: string
22
26
  }> = observer(({
23
27
  icon,
24
- className=''
28
+ clx='',
29
+ panelClx='',
30
+ scrollAfter,
31
+ scrollHeightClx
25
32
  }) => {
26
33
  const cmmc = useCommerce()
27
34
  return (
28
- <Accordion type="single" collapsible className={className}>
35
+ <Accordion type="single" collapsible className={clx}>
29
36
  <AccordionItem value="cart" className='w-full border-b-0'>
30
37
  <AccordionTrigger className='!no-underline group flex justify-between'>
31
38
  <div className='flex gap-0 items-center'>
@@ -42,9 +49,9 @@ const CartAccordian: React.FC<{
42
49
  </AccordionTrigger>
43
50
  <AccordionContent className='data-[state=open]:mb-4'>
44
51
  <CartPanel
45
- className='w-full '
46
- scrollAfter={4}
47
- scrollHeightClx='h-[350px]'
52
+ className={cn('w-full', panelClx)}
53
+ scrollAfter={scrollAfter}
54
+ scrollHeightClx={scrollHeightClx}
48
55
  itemClx='mt-2'
49
56
  totalClx='sticky px-1 pr-2 border-t -bottom-[1px] bg-background'
50
57
  showShipping
@@ -10,7 +10,6 @@ import type { LineItem } from '../../../types'
10
10
  import { formatCurrencyValue } from '../../../util'
11
11
  import AddToCartWidget from '../../add-to-cart-widget'
12
12
  import { useCommerce } from '../../../context'
13
- import { computed } from 'mobx'
14
13
 
15
14
  const DEF_IMG_SIZE=40
16
15
 
@@ -35,14 +34,12 @@ const CartLineItem: React.FC<{
35
34
  imgSizePx=DEF_IMG_SIZE,
36
35
  showPromoCode=false,
37
36
  itemClicked,
38
- //selected=false
37
+ selected=false
39
38
  }) => {
40
39
 
41
40
  const cmmc = useCommerce()
42
41
  const promoPrice = showPromoCode ? cmmc.itemPromoPrice(item) : undefined
43
42
 
44
- const selected = item.sku === cmmc.currentItem?.sku
45
-
46
43
  return (
47
44
  <div
48
45
  className={cn(
@@ -1,19 +1,18 @@
1
1
  'use client'
2
2
  import React, { useLayoutEffect, type PropsWithChildren } from 'react'
3
+ import { reaction } from 'mobx'
3
4
  import { observer } from 'mobx-react-lite'
4
5
 
5
6
  import { Button, ScrollArea } from '@hanzo/ui/primitives'
6
7
  import { cn } from '@hanzo/ui/util'
7
8
 
9
+ import type { LineItem } from '../../../types'
8
10
  import { useCommerce } from '../../../context'
9
11
  import { sendFBEvent, sendGAEvent } from '../../../util/analytics'
10
12
 
11
13
  import CartLineItem from './cart-line-item'
12
14
  import TotalArea from './total-area'
13
15
 
14
- import type { LineItem } from '../../../types'
15
- import { autorun, reaction } from 'mobx'
16
-
17
16
  const CartPanel: React.FC<PropsWithChildren & {
18
17
  /** fix size and scroll after 'scrollAfter items in teh cart. */
19
18
  scrollAfter?: number
@@ -57,18 +56,12 @@ const CartPanel: React.FC<PropsWithChildren & {
57
56
  if (!cmmc.cartEmpty && !cmmc.currentItem) {
58
57
  cmmc.setCurrentItem(cmmc.cartItems[0].sku)
59
58
  }
60
-
61
- autorun(() => {
62
- console.log('AUTORUN: ' + cmmc.currentItem?.sku)
63
- })
64
59
  // return mobx disposer
65
60
  return reaction(() => (
66
61
  cmmc.cartItems.length
67
62
  ),
68
63
  (itemCount) => {
69
64
  if (itemCount > 0) {
70
- console.log("REACTION, COUNT: ", itemCount)
71
- console.log("REACTION, CURRENT FIRST SKU: ", cmmc.cartItems[0].sku)
72
65
  cmmc.setCurrentItem(cmmc.cartItems[0].sku)
73
66
  }
74
67
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "7.1.26",
3
+ "version": "7.1.28",
4
4
  "description": "e-commerce framework.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",