@hanzo/commerce 7.1.27 → 7.1.29

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,15 +19,23 @@ 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
+ triggerClx?: string
24
+ panelClx?: string
25
+ scrollAfter: number
26
+ scrollHeightClx: string
22
27
  }> = observer(({
23
28
  icon,
24
- className=''
29
+ clx='',
30
+ panelClx='',
31
+ triggerClx='',
32
+ scrollAfter,
33
+ scrollHeightClx
25
34
  }) => {
26
35
  const cmmc = useCommerce()
27
36
  return (
28
- <Accordion type="single" collapsible className={className}>
29
- <AccordionItem value="cart" className='w-full border-b-0'>
37
+ <Accordion type="single" collapsible className={clx}>
38
+ <AccordionItem value="cart" className={'w-full border-b-0 ' + triggerClx}>
30
39
  <AccordionTrigger className='!no-underline group flex justify-between'>
31
40
  <div className='flex gap-0 items-center'>
32
41
  {icon}
@@ -42,9 +51,9 @@ const CartAccordian: React.FC<{
42
51
  </AccordionTrigger>
43
52
  <AccordionContent className='data-[state=open]:mb-4'>
44
53
  <CartPanel
45
- className='w-full '
46
- scrollAfter={4}
47
- scrollHeightClx='h-[350px]'
54
+ className={cn('w-full', panelClx)}
55
+ scrollAfter={scrollAfter}
56
+ scrollHeightClx={scrollHeightClx}
48
57
  itemClx='mt-2'
49
58
  totalClx='sticky px-1 pr-2 border-t -bottom-[1px] bg-background'
50
59
  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
 
@@ -41,8 +40,6 @@ const CartLineItem: React.FC<{
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/commerce",
3
- "version": "7.1.27",
3
+ "version": "7.1.29",
4
4
  "description": "e-commerce framework.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",