@luxfi/core 5.3.7 → 10.0.1

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.
Files changed (196) hide show
  1. package/package.json +9 -53
  2. package/tsconfig.json +3 -8
  3. package/types/asset.ts +28 -0
  4. package/types/contract.ts +13 -0
  5. package/types/deposit-address.ts +9 -0
  6. package/types/exchange.ts +25 -0
  7. package/types/index.ts +21 -4
  8. package/types/network-type.ts +16 -0
  9. package/types/network.ts +58 -0
  10. package/types/swap-status.ts +58 -0
  11. package/types/transaction-type.ts +5 -0
  12. package/types/utila.ts +36 -0
  13. package/commerce/ui/conf.ts +0 -13
  14. package/commerce/ui/context.tsx +0 -123
  15. package/commerce/ui/store.ts +0 -290
  16. package/components/access-code-input.tsx +0 -71
  17. package/components/auth/auth-listener.tsx +0 -29
  18. package/components/auth/auth-token/clear-auth-token.tsx +0 -12
  19. package/components/auth/auth-token/set-auth-token.tsx +0 -16
  20. package/components/auth/common-auth-domains.ts +0 -16
  21. package/components/auth/login-panel.tsx +0 -107
  22. package/components/back-button.tsx +0 -49
  23. package/components/chat-widget.tsx +0 -85
  24. package/components/commerce/_to_deprecate_checkout-widget/const.ts +0 -13
  25. package/components/commerce/_to_deprecate_checkout-widget/index.tsx_ +0 -188
  26. package/components/commerce/_to_deprecate_checkout-widget/obs-string-set.ts +0 -48
  27. package/components/commerce/_to_deprecate_checkout-widget/use-anim-clx-set.ts +0 -59
  28. package/components/commerce/bag-button.tsx +0 -98
  29. package/components/commerce/buy-button.tsx +0 -34
  30. package/components/commerce/checkout-button.tsx +0 -129
  31. package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
  32. package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
  33. package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
  34. package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
  35. package/components/commerce/checkout-panel/index.tsx +0 -126
  36. package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
  37. package/components/commerce/checkout-panel/policy-links.tsx +0 -29
  38. package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
  39. package/components/commerce/checkout-panel/thank-you.tsx +0 -18
  40. package/components/commerce/desktop-bag-popup.tsx +0 -78
  41. package/components/commerce/desktop-nav-menu.tsx +0 -194
  42. package/components/commerce/drawer/index.tsx +0 -88
  43. package/components/commerce/drawer/micro.tsx +0 -145
  44. package/components/commerce/drawer/shell.tsx +0 -85
  45. package/components/commerce/mobile-bag-drawer.tsx +0 -51
  46. package/components/commerce/mobile-login-button.tsx +0 -108
  47. package/components/commerce/mobile-menu-toggle-button.tsx +0 -35
  48. package/components/commerce/mobile-nav-menu-ai.tsx +0 -51
  49. package/components/commerce/mobile-nav-menu-item.tsx +0 -50
  50. package/components/commerce/mobile-nav-menu.tsx +0 -102
  51. package/components/contact-dialog/contact-form.tsx +0 -113
  52. package/components/contact-dialog/disclaimer.tsx +0 -13
  53. package/components/contact-dialog/index.tsx +0 -64
  54. package/components/copyright.tsx +0 -21
  55. package/components/drawer-margin.tsx +0 -28
  56. package/components/footer.tsx +0 -78
  57. package/components/header/desktop.tsx +0 -51
  58. package/components/header/index.tsx +0 -50
  59. package/components/header/mobile.tsx +0 -163
  60. package/components/header/theme-toggle.tsx +0 -26
  61. package/components/icons/24k-gold-card.tsx +0 -43
  62. package/components/icons/ai-chat-act.tsx +0 -47
  63. package/components/icons/ai-chat.tsx +0 -29
  64. package/components/icons/anodized-titanium.tsx +0 -45
  65. package/components/icons/avatar.tsx +0 -11
  66. package/components/icons/bag-icon.tsx +0 -10
  67. package/components/icons/blog-act.tsx +0 -14
  68. package/components/icons/blog.tsx +0 -20
  69. package/components/icons/bridge-act.tsx +0 -18
  70. package/components/icons/bridge.tsx +0 -68
  71. package/components/icons/changelog-act.tsx +0 -15
  72. package/components/icons/changelog.tsx +0 -21
  73. package/components/icons/chrome.tsx +0 -45
  74. package/components/icons/coins-act.tsx +0 -29
  75. package/components/icons/coins.tsx +0 -20
  76. package/components/icons/compare-cards-act.tsx +0 -30
  77. package/components/icons/compare-cards.tsx +0 -21
  78. package/components/icons/credit-act.tsx +0 -29
  79. package/components/icons/credit.tsx +0 -20
  80. package/components/icons/customer-support-act.tsx +0 -27
  81. package/components/icons/customer-support.tsx +0 -21
  82. package/components/icons/customers-act.tsx +0 -65
  83. package/components/icons/customers.tsx +0 -33
  84. package/components/icons/developer-docs-act.tsx +0 -26
  85. package/components/icons/developer-docs.tsx +0 -20
  86. package/components/icons/exchange-act.tsx +0 -27
  87. package/components/icons/exchange.tsx +0 -21
  88. package/components/icons/explorer-act.tsx +0 -27
  89. package/components/icons/explorer.tsx +0 -22
  90. package/components/icons/faqs-act.tsx +0 -27
  91. package/components/icons/faqs.tsx +0 -21
  92. package/components/icons/github.tsx +0 -14
  93. package/components/icons/guides-act.tsx +0 -26
  94. package/components/icons/guides.tsx +0 -21
  95. package/components/icons/gun-metal.tsx +0 -44
  96. package/components/icons/index.tsx +0 -43
  97. package/components/icons/integrations-act.tsx +0 -41
  98. package/components/icons/integrations.tsx +0 -25
  99. package/components/icons/irradescent.tsx +0 -41
  100. package/components/icons/launch-subnet.tsx +0 -21
  101. package/components/icons/launchsubnet-act.tsx +0 -29
  102. package/components/icons/left-arrow.tsx +0 -11
  103. package/components/icons/lux-finance-act.tsx +0 -34
  104. package/components/icons/lux-finance.tsx +0 -23
  105. package/components/icons/lux-logo.tsx +0 -10
  106. package/components/icons/lux-pass-act.tsx +0 -41
  107. package/components/icons/lux-pass.tsx +0 -25
  108. package/components/icons/lux-quests-act.tsx +0 -15
  109. package/components/icons/lux-quests.tsx +0 -21
  110. package/components/icons/market-act.tsx +0 -39
  111. package/components/icons/market.tsx +0 -24
  112. package/components/icons/mirrored-titanium.tsx +0 -46
  113. package/components/icons/more-benefits-act.tsx +0 -29
  114. package/components/icons/more-benefits.tsx +0 -21
  115. package/components/icons/open-source-act.tsx +0 -41
  116. package/components/icons/open-source.tsx +0 -26
  117. package/components/icons/right-arrow.tsx +0 -10
  118. package/components/icons/safe-act.tsx +0 -77
  119. package/components/icons/safe.tsx +0 -37
  120. package/components/icons/search.tsx +0 -12
  121. package/components/icons/secure-delivery.tsx +0 -13
  122. package/components/icons/shop-act.tsx +0 -29
  123. package/components/icons/shop.tsx +0 -20
  124. package/components/icons/social-icon.tsx +0 -35
  125. package/components/icons/social-svg.css +0 -3
  126. package/components/icons/sterling-silver-card.tsx +0 -44
  127. package/components/icons/templates-act.tsx +0 -29
  128. package/components/icons/templates.tsx +0 -21
  129. package/components/icons/validators-act.tsx +0 -42
  130. package/components/icons/validators.tsx +0 -41
  131. package/components/icons/view-all-card-act.tsx +0 -28
  132. package/components/icons/view-all-card.tsx +0 -20
  133. package/components/icons/wallet-act.tsx +0 -29
  134. package/components/icons/wallet.tsx +0 -20
  135. package/components/icons/warpcast.tsx +0 -58
  136. package/components/icons/youtube-logo.tsx +0 -59
  137. package/components/index.ts +0 -25
  138. package/components/logo.tsx +0 -89
  139. package/components/main.tsx +0 -27
  140. package/components/mini-chart/index.tsx +0 -8
  141. package/components/mini-chart/mini-chart-props.ts +0 -44
  142. package/components/mini-chart/mini-chart.tsx +0 -85
  143. package/components/mini-chart/wrapper.tsx +0 -23
  144. package/components/not-found/index.tsx +0 -28
  145. package/components/not-found/not-found-content.mdx +0 -5
  146. package/components/scripts.tsx +0 -24
  147. package/components/tooltip.tsx +0 -31
  148. package/environment.d.ts +0 -6
  149. package/next/analytics/fpixel.ts +0 -16
  150. package/next/analytics/google-analytics.ts +0 -14
  151. package/next/analytics/index.ts +0 -3
  152. package/next/analytics/pixel-analytics.tsx +0 -55
  153. package/next/font/get-app-router-font-classes.ts +0 -12
  154. package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
  155. package/next/font/local/Druk-Wide-Bold.ttf +0 -0
  156. package/next/font/local/Druk-Wide-Medium.ttf +0 -0
  157. package/next/font/local/InterVariable-Italic.ttf +0 -0
  158. package/next/font/local/InterVariable-Italic.woff2 +0 -0
  159. package/next/font/local/InterVariable.ttf +0 -0
  160. package/next/font/local/InterVariable.woff2 +0 -0
  161. package/next/font/next-font-desc.ts +0 -28
  162. package/next/font/pages-router-font-vars.tsx +0 -18
  163. package/next/head-metadata/from-next/metadata-types.ts +0 -158
  164. package/next/head-metadata/from-next/opengraph-types.ts +0 -267
  165. package/next/head-metadata/from-next/twitter-types.ts +0 -92
  166. package/next/head-metadata/index.tsx +0 -208
  167. package/next/index.ts +0 -1
  168. package/next/middleware/determine-device-mw.ts +0 -16
  169. package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
  170. package/root-layout/index.tsx +0 -112
  171. package/server-actions/TO-DO.txt +0 -1
  172. package/server-actions/firebase-app.ts +0 -14
  173. package/server-actions/index.ts +0 -5
  174. package/server-actions/store-contact.ts +0 -51
  175. package/site-def/footer/community.tsx +0 -67
  176. package/site-def/footer/company.ts +0 -37
  177. package/site-def/footer/ecosystem.ts +0 -37
  178. package/site-def/footer/index.tsx +0 -26
  179. package/site-def/footer/legal.ts +0 -28
  180. package/site-def/footer/network.ts +0 -45
  181. package/site-def/footer/svg/warpcast-logo.svg +0 -12
  182. package/site-def/index.ts +0 -3
  183. package/site-def/main-nav.tsx +0 -458
  184. package/style/cart-animation.css +0 -29
  185. package/style/checkout-animation.css +0 -23
  186. package/style/drawer-handle-overrides.css +0 -160
  187. package/style/lux-colors.css +0 -85
  188. package/style/lux-global.css +0 -51
  189. package/tailwind/fontFamily.tailwind.lux.ts +0 -18
  190. package/tailwind/index.ts +0 -2
  191. package/tailwind/lux-tw-fonts.ts +0 -40
  192. package/tailwind/tailwind.config.lux-preset.ts +0 -10
  193. package/types/chatbot-config.ts +0 -7
  194. package/types/chatbot-suggested-question.ts +0 -7
  195. package/types/contact-info.ts +0 -11
  196. package/types/site-def.ts +0 -43
@@ -1,188 +0,0 @@
1
- 'use client'
2
- import React, { useRef } from 'react'
3
- import { createPortal } from 'react-dom'
4
- import { usePathname, useRouter } from 'next/navigation'
5
- import { observer } from 'mobx-react-lite'
6
-
7
- import { cn } from '@hanzo/ui/util'
8
- import { useStepAnimation } from '@hanzo/ui/util-client'
9
-
10
- import { Image } from '@hanzo/ui/primitives'
11
-
12
- import CheckoutButton from '../checkout-button'
13
- import useAnimationClxSet from './use-anim-clx-set'
14
- import CONST from './const'
15
- import type { LineItem } from '@hanzo/commerce/types'
16
-
17
- const transStyle = (t: { transition: string, from : string, to: string } | undefined) : any => (
18
- t ? {
19
- transitionProperty: t.transition,
20
- transitionTimingFunction: CONST.animTimingFn,
21
- transitionDuration: `${CONST.animDurationMs}ms`
22
- } : {}
23
- )
24
-
25
- const transClx = (on: boolean, t: { transition: string, from : string, to: string } | undefined) : string => (
26
- on ? (t?.from ?? '') : (t?.to ?? '')
27
- )
28
-
29
- const VARS: any = {
30
- BR: {
31
- pos: 'bottom-[24px] right-[66px]',
32
- width: 'w-initial',
33
- centerText: false,
34
- coClx: 'w-auto',
35
- infoClx: 'w-auto',
36
- activeItemAnim: {
37
- co: {
38
- transition: 'none',
39
- from : 'px-3 gap-2.5',
40
- to: ''
41
- },
42
- coText: {
43
- transition: 'max-width',
44
- from : 'max-w-[100px]',
45
- to: 'max-w-[0px]'
46
- },
47
- info: {
48
- transition: 'transform, opacity',
49
- from : 'scale-x-100 opacity-100 origin-right',
50
- to: 'scale-x-0 opacity-0 origin-right'
51
- }
52
- },
53
- showArrow: true
54
- },
55
- TR: {
56
- pos: 'top-[48px] md:top-[80px] right-[28px]',
57
- width: 'w-initial',
58
- centerText: false,
59
- showQuantity: false,
60
- showArrow: true,
61
- coClx: 'w-auto px-3 gap-1',
62
- infoClx: 'w-auto',
63
- activeItemAnim: {
64
- co: {
65
- transition: 'none',
66
- from : 'px-3 gap-2.5',
67
- to: ''
68
- },
69
- coText: {
70
- transition: 'max-width',
71
- from : 'max-w-[100px]',
72
- to: 'max-w-[0px]'
73
- },
74
- info: {
75
- transition: 'transform',
76
- from : 'scale-x-100 origin-right',
77
- to: 'scale-x-0 origin-right'
78
- }
79
- },
80
- },
81
- TRIO: {
82
- pos: 'top-[48px] md:top-[70px] right-[28px]',
83
- centerText: false,
84
- showQuantity: true,
85
- showArrow: true,
86
- width: 'w-initial',
87
- coClx: 'hidden',
88
- infoClx: 'w-auto',
89
- activeItemAnim: {
90
- info: {
91
- transition: 'transform, opacity',
92
- from : 'scale-x-100 opacity-100',
93
- to: 'scale-x-50 opacity-0'
94
- }
95
- },
96
- }
97
- }
98
-
99
- const v = 'TR'
100
-
101
- const CheckoutWidget: React.FC<{
102
- clx?: string
103
- }> = observer(({
104
- clx=''
105
- }) => {
106
-
107
- const router = useRouter()
108
-
109
- const isCheckout = usePathname() === '/checkout'
110
- const clxSet = useAnimationClxSet(isCheckout)
111
-
112
- // for rendering content after recentActivity.item() would return false
113
- const persistentRef = useRef<LineItem | undefined>(undefined)
114
-
115
- // Doing double duty of being initial step fn for StepAnimation,
116
- // and also capturing the item for persistentRef :)
117
- const initialStepFn = (): boolean => {
118
- if (!!recentActivity.item && !persistentRef.current) {
119
- persistentRef.current = recentActivity.item
120
- }
121
- return !!recentActivity.item
122
- }
123
- const steps = useStepAnimation(initialStepFn, [CONST.animDurationMs, CONST.animDurationMs, CONST.animDurationMs])
124
-
125
- const handleCheckout = () => { router.push('/checkout')}
126
-
127
- return globalThis?.document?.body && createPortal(
128
- (<div
129
- className={cn(
130
- VARS[v].width,
131
- 'z-below-modal-2 fixed ',
132
- VARS[v].pos,
133
- 'rounded-lg',
134
- 'flex',
135
- steps.notPast(0) ? 'bg-background' : '',
136
- steps.notPast(1) ? 'gap-2' : '',
137
- clxSet.asArray.join(' ')
138
- )}
139
- style={steps.notPast(1) ? {} : VARS[v].coClx?.includes('hidden') ? {} : CONST.shadowStyle}
140
- >
141
- <div
142
- className={cn(
143
- 'flex flex-row justify-between items-center',
144
- transClx(steps.notPast(0), VARS[v].activeItemAnim.info),
145
- VARS[v].itemClx,
146
- steps.notPast(1) ? 'px-3 border rounded-lg bg-level-1 border-muted-3' : ''
147
- )}
148
- style={transStyle(VARS[v].activeItemAnim.info)}
149
- >
150
- {steps.notPast(1) && persistentRef.current?.img && (
151
- <Image def={persistentRef.current.img} constrainTo={CONST.itemImgConstraint} preload className='grow-0 shrink-0'/>
152
- )}
153
- {steps.notPast(1) && persistentRef.current && (<div className='text-foreground grow ml-1'>
154
- <p className='whitespace-nowrap text-ellipsis text-sm'>{persistentRef.current.title}</p>
155
- <p className='whitespace-nowrap text-clip text-xxs' >recently added...</p>
156
- </div>)}
157
- </div>
158
- <CheckoutButton
159
- handleCheckout={handleCheckout}
160
- centerText={VARS[v].centerText ?? !steps.notPast(0)}
161
- variant='primary'
162
- rounded='lg'
163
- showQuantity={VARS[v].showQuantity ?? true}
164
- showArrow={VARS[v].showArrow ?? true}
165
- className={cn(
166
- // for setting and unsetting 'gap'
167
- transClx((VARS[v].activeItemAnim.coText ? steps.notPast(3) : true), VARS[v].activeItemAnim.co),
168
- VARS[v].coClx
169
- )}
170
- style={transStyle(VARS[v].activeItemAnim.co)}
171
- >
172
- <div
173
- className={cn(
174
- 'overflow-hidden',
175
- 'flex justify-center items-center',
176
- transClx(steps.notPast(2), VARS[v].activeItemAnim.coText),
177
- )}
178
- style={transStyle(VARS[v].activeItemAnim.coText)}
179
- >
180
- Checkout
181
- </div>
182
- </CheckoutButton>
183
- </div>),
184
- globalThis?.document?.body
185
- )
186
- })
187
-
188
- export default CheckoutWidget
@@ -1,48 +0,0 @@
1
- import {
2
- action,
3
- computed,
4
- makeObservable,
5
- observable
6
- } from 'mobx'
7
-
8
- class ObsStringSet {
9
-
10
- private _set = observable.set(new Set<string>())
11
-
12
- constructor(initial: string[] = []) {
13
- initial.forEach((el) => {this._set.add(el)})
14
- makeObservable(this, {
15
- add: action,
16
- remove: action,
17
- asArray: computed
18
- })
19
- }
20
-
21
- add = (v: string | string[]): void => {
22
- if (Array.isArray(v)) {
23
- v.forEach((el) => {this._set.add(el)})
24
- }
25
- else {
26
- this._set.add(v)
27
- }
28
- }
29
-
30
- remove = (v: string | string[]): void => {
31
- if (Array.isArray(v)) {
32
- v.forEach((el) => {this._set.delete(el)})
33
- }
34
- else {
35
- this._set.delete(v)
36
- }
37
- }
38
-
39
- has = (v: string): boolean => (
40
- this._set.has(v)
41
- )
42
-
43
- get asArray() {
44
- return Array.from(this._set)
45
- }
46
- }
47
-
48
- export default ObsStringSet
@@ -1,59 +0,0 @@
1
- import { useEffect, useRef } from 'react'
2
- import { reaction, runInAction} from 'mobx'
3
-
4
- import { useCommerce } from '@hanzo/commerce'
5
-
6
- import ObsStringSet from './obs-string-set'
7
- import { useSelectAndBuy } from '../../../commerce/ui/context'
8
-
9
- export default (isCheckout: boolean): ObsStringSet => {
10
-
11
- const ui = useSelectAndBuy()
12
- const cmmc = useCommerce()
13
-
14
- const clxSetRef = useRef<ObsStringSet>(new ObsStringSet(
15
- (cmmc.cartEmpty || ui.currentSkuPath || isCheckout) ? ['hidden'] : []
16
- ))
17
-
18
- useEffect(() => (
19
- reaction(
20
- () => ({
21
- microOpen: !(cmmc.cartEmpty || !!ui.currentSkuPath || isCheckout),
22
- buyOpen: !!ui.currentSkuPath
23
- }),
24
- (val, prev) => {
25
-
26
- runInAction(() => {
27
- if (!val.microOpen && prev.microOpen) {
28
- clxSetRef.current.add('checkout-widget-disappears')
29
- }
30
- else if (val.microOpen && !prev.microOpen) {
31
- clxSetRef.current.remove('hidden')
32
- clxSetRef.current.add('checkout-widget-appears')
33
- }
34
- if (!val.buyOpen && prev.buyOpen) {
35
- clxSetRef.current.add('checkout-widget-appears-after-buy-drawer-closes')
36
- }
37
- else {
38
- clxSetRef.current.remove('checkout-widget-appears-after-buy-drawer-closes')
39
- }
40
- })
41
-
42
- setTimeout(() => {runInAction(() => {
43
- clxSetRef.current.remove(['checkout-widget-appears', 'checkout-widget-appears-after-buy-drawer-closes'])
44
- if (clxSetRef.current.has('checkout-widget-disappears') ) {
45
- clxSetRef.current.remove('checkout-widget-disappears')
46
- clxSetRef.current.add('hidden')
47
- }
48
- })}, 800)
49
- },
50
- {equals: (val, prev) => (
51
- val.microOpen === prev.microOpen
52
- &&
53
- val.buyOpen === prev.buyOpen
54
- )}
55
- )
56
- ), [isCheckout])
57
-
58
- return clxSetRef.current
59
- }
@@ -1,98 +0,0 @@
1
- 'use client'
2
- import React, { useEffect, useRef } from 'react'
3
- import { observable, type IObservableValue, reaction, runInAction } from 'mobx'
4
- import { observer } from 'mobx-react-lite'
5
-
6
- import { buttonVariants } from '@hanzo/ui/primitives'
7
- import { cn, type VariantProps } from '@hanzo/ui/util'
8
- import { useCommerce } from '@hanzo/commerce'
9
-
10
- import * as Icons from '../icons'
11
-
12
- const BagButton: React.FC<{
13
- showIfEmpty?: boolean
14
- animateOnHover?: boolean
15
- animateOnQuantityChange?: boolean
16
- size?: VariantProps<typeof buttonVariants>['size']
17
- className?: string
18
- iconClx?: string
19
- onClick?: () => void
20
- }> = observer(({
21
- showIfEmpty=false,
22
- animateOnHover=true,
23
- animateOnQuantityChange=true,
24
- size='default',
25
- className='',
26
- iconClx='',
27
- onClick
28
- }) => {
29
-
30
- const c = useCommerce()
31
- const wiggleRef = useRef<IObservableValue<'more' | 'less' | 'none'>>(observable.box('none'))
32
-
33
- useEffect(() => (
34
- // return IReactionDisposer
35
- animateOnQuantityChange ? reaction(
36
- () => (c.cartQuantity),
37
- (curr, prev) => {
38
- if (curr > prev) {
39
- runInAction(() => {wiggleRef.current.set('more')})
40
- }
41
- else {
42
- runInAction(() => {wiggleRef.current.set('less')})
43
- }
44
- setTimeout(() => {
45
- // Note that this doesn't actually stop the animation
46
- // just resets the styles
47
- runInAction(() => {wiggleRef.current.set('none')})
48
- }, 800)
49
- }
50
- ) : undefined
51
- ), [])
52
-
53
- // undefined means context is not installed, ie commerce functions are not in use
54
- if (!c || (!showIfEmpty && c.cartEmpty)) {
55
- return <div /> // trigger code needs non-null
56
- }
57
-
58
-
59
- return (
60
- <div
61
- aria-label="Bag"
62
- role='button'
63
- onClick={onClick}
64
- className={cn(
65
- buttonVariants({ variant: 'ghost', size, rounded: 'md' }),
66
- // Overides the bg change on hover --not a "hover effect"
67
- 'relative group p-0 aspect-square hover:bg-background',
68
- ((wiggleRef.current.get() === 'more') ?
69
- 'item-added-to-cart-animation'
70
- :
71
- (wiggleRef.current.get() === 'less') ? 'item-removed-from-cart-animation' : ''),
72
- className
73
- )}
74
- >
75
- {!c.cartEmpty && (
76
- <div className={
77
- 'z-above-content flex flex-col justify-center items-center ' +
78
- 'absolute left-0 right-0 top-0 bottom-0 ' +
79
- 'leading-none font-sans font-bold text-primary-fg text-xs '
80
- }>
81
- <div className='h-[3px] w-full' />
82
- <div>{c.cartQuantity}</div>
83
- </div>
84
- )}
85
- <Icons.bag width='24' height='28' className={cn(
86
- 'relative -top-[3px] fill-primary',
87
- iconClx,
88
- (animateOnHover ?
89
- 'group-hover:fill-primary-hover group-hover:scale-105 transition-scale transition-duration-300'
90
- :
91
- ''
92
- )
93
- )} aria-hidden="true" />
94
- </div>
95
- )
96
- })
97
-
98
- export default BagButton
@@ -1,34 +0,0 @@
1
- 'use client'
2
- import React, {type PropsWithChildren} from 'react'
3
-
4
- import { Button, buttonVariants } from '@hanzo/ui/primitives'
5
- import { type VariantProps } from '@hanzo/ui/util'
6
-
7
- import { cn } from '@hanzo/ui/util'
8
- import { useSelectAndBuy } from '../../commerce/ui/context'
9
-
10
- const BuyButton: React.FC<
11
- PropsWithChildren &
12
- VariantProps<typeof buttonVariants> &
13
- {
14
- skuPath: string
15
- className?: string
16
- }
17
- > = ({
18
- skuPath,
19
- children,
20
- className='',
21
- ...rest
22
- }) => {
23
-
24
- const buyOptions = useSelectAndBuy()
25
- const handleClick = (): void => { buyOptions.showVariants(skuPath) }
26
-
27
- return (
28
- <Button onClick={handleClick} {...rest} className={cn(className, '')}>
29
- {children}
30
- </Button>
31
- )
32
- }
33
-
34
- export default BuyButton
@@ -1,129 +0,0 @@
1
- 'use client'
2
- import React, { useEffect, useRef } from 'react'
3
- import { observable, type IObservableValue, reaction, runInAction } from 'mobx'
4
- import { observer } from 'mobx-react-lite'
5
-
6
- import { Button, type ButtonProps } from '@hanzo/ui/primitives'
7
- import { cn } from '@hanzo/ui/util'
8
- import { useCommerce } from '@hanzo/commerce'
9
-
10
- import * as Icons from '../icons'
11
-
12
- const IconAndQuantity: React.FC<{
13
- animateOnQuantityChange?: boolean
14
- showArrow?: boolean
15
- showQuantity?: boolean
16
- clx?: string
17
- iconClx?: string
18
- digitClx?: string
19
- }> = observer(({
20
- animateOnQuantityChange=false,
21
- showArrow=true,
22
- showQuantity=true,
23
- clx='',
24
- iconClx='',
25
- digitClx=''
26
- }) => {
27
-
28
- const cmmc = useCommerce()
29
- const wiggleRef = useRef<IObservableValue<'more' | 'less' | 'none'>>(observable.box('none'))
30
-
31
- useEffect(() => (
32
- // return IReactionDisposer
33
- animateOnQuantityChange ? reaction(
34
- () => (cmmc.cartQuantity),
35
- (curr, prev) => {
36
- if (curr > prev) {
37
- runInAction(() => {wiggleRef.current.set('more') })
38
- }
39
- else {
40
- runInAction(() => {wiggleRef.current.set('less') })
41
- }
42
- setTimeout(() => {
43
- // Note that this doesn't actually stop the animation
44
- // just resets the styles
45
- runInAction(() => {wiggleRef.current.set('none') })
46
- }, 800)
47
- }
48
- ) : undefined
49
- ), [])
50
-
51
- return (
52
- <div className={cn('flex items-center justify-center', clx)}>
53
- {showQuantity && (
54
- <div className={cn(
55
- 'relative flex items-center justify-center mr-1',
56
- ((wiggleRef.current.get() === 'more') ?
57
- 'item-added-to-cart-animation'
58
- :
59
- (wiggleRef.current.get() === 'less') ? 'item-removed-from-cart-animation' : ''),
60
- )} >
61
- {cmmc.cartQuantity > 0 && (
62
- <div className={cn(
63
- 'z-above-content flex flex-col justify-center items-center',
64
- 'absolute left-0 right-0 top-0 bottom-0',
65
- digitClx
66
- )}>
67
- <div style={{/* color: 'white' tailwind bug? ,*/ fontSize: '11px', position: 'relative', top: '1px' }}>{cmmc.cartQuantity}</div>
68
- </div>
69
- )}
70
- <Icons.bag width='19' height='24' className={cn('relative -top-[3px] opacity-70' , iconClx)} aria-hidden="true" />
71
- </div>
72
- )}
73
- {showArrow && (<span style={{fontSize: '17px',}}>&rsaquo;</span>)}
74
- </div>
75
- )
76
- })
77
-
78
- const CheckoutButton: React.FC<ButtonProps & {
79
- handleCheckout: () => void
80
- showQuantity?: boolean
81
- showArrow?: boolean
82
- animateOnQuantityChange?: boolean
83
- centerText?: boolean
84
- }> = ({
85
- handleCheckout,
86
- variant='primary',
87
- rounded='lg',
88
- className,
89
- showQuantity=true,
90
- showArrow=true,
91
- animateOnQuantityChange=true,
92
- centerText=true,
93
- children,
94
- ...rest
95
- }) => {
96
-
97
- return (
98
- <Button
99
- {...rest}
100
- onClick={handleCheckout}
101
- variant={variant}
102
- rounded={rounded}
103
- className={cn(
104
- 'flex justify-between items-stretch group',
105
- showQuantity ? (centerText ? 'px-1.5' : 'pl-2.5 pr-1.5') : '',
106
- className,
107
- )}
108
- >
109
- {centerText && ( // must scale this one too, as it effects layout
110
- <IconAndQuantity
111
- showArrow={showArrow}
112
- showQuantity={showQuantity}
113
- clx='invisible group-hover:scale-105 transition-scale transition-duration-300'
114
- />
115
- )}
116
- {children ?? (<div className='flex justify-center items-center'>Checkout</div>)}
117
- <IconAndQuantity
118
- clx='group-hover:scale-105 transition-scale transition-duration-300'
119
- animateOnQuantityChange={animateOnQuantityChange}
120
- showArrow={showArrow}
121
- showQuantity={showQuantity}
122
- iconClx='fill-background'
123
- digitClx='text-foreground group-hover:opacity-80 leading-none font-bold font-sans'
124
- />
125
- </Button>
126
- )
127
- }
128
-
129
- export default CheckoutButton
@@ -1,66 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { observer } from 'mobx-react-lite'
4
-
5
- import { ChevronRight } from 'lucide-react'
6
-
7
- import {
8
- Accordion,
9
- AccordionContent,
10
- AccordionItem,
11
- AccordionTrigger,
12
- } from '@hanzo/ui/primitives'
13
- import { cn } from '@hanzo/ui/util'
14
-
15
- import { useCommerce, CartPanel, formatCurrencyValue } from '@hanzo/commerce'
16
-
17
- const CartAccordian: React.FC<{
18
- icon?: React.ReactNode
19
- clx?: string
20
- triggerClx?: string
21
- panelClx?: string
22
- scrollAfter: number
23
- scrollHeightClx: string
24
- }> = observer(({
25
- icon,
26
- clx='',
27
- panelClx='',
28
- triggerClx='',
29
- scrollAfter,
30
- scrollHeightClx
31
- }) => {
32
- const cmmc = useCommerce()
33
- return (
34
- <Accordion type="single" collapsible className={clx}>
35
- <AccordionItem value="cart" className='w-full border-b-0'>
36
- <AccordionTrigger className={'!no-underline group flex justify-between '} headerClx={ triggerClx}>
37
- <div className='flex gap-0 items-center'>
38
- {icon}
39
- <h5 className='text-sm sm:text-xl grow'>
40
- <span className='group-data-[state=open]:hidden' >Order Total:</span>
41
- <span className='group-data-[state=closed]:hidden' >Your Order</span>
42
- </h5>
43
- </div>
44
- <div className='flex gap-1 items-center'>
45
- <h5 className='text-sm sm:text-xl grow truncate'>{formatCurrencyValue(cmmc.promoAppliedCartTotal)}</h5>
46
- <ChevronRight className="h-5 w-5 -mr-2 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-90" />
47
- </div>
48
- </AccordionTrigger>
49
- <AccordionContent className='data-[state=open]:mb-4'>
50
- <CartPanel
51
- className={cn('w-full', panelClx)}
52
- scrollAfter={scrollAfter}
53
- scrollHeightClx={scrollHeightClx}
54
- listClx='mt-0'
55
- itemClx='mt-0.5 mb-0'
56
- totalClx='sticky px-1 pr-2 border-t -bottom-[1px] bg-background'
57
- showShipping
58
- showPromoCode
59
- />
60
- </AccordionContent>
61
- </AccordionItem>
62
- </Accordion>
63
- )
64
- })
65
-
66
- export default CartAccordian
@@ -1,10 +0,0 @@
1
- interface CheckoutPanelProps {
2
- step: number
3
- stepNames: string[]
4
- onLeave:() => void
5
- clx?: string
6
- }
7
-
8
- export {
9
- type CheckoutPanelProps as default
10
- }
@@ -1,36 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { observer } from 'mobx-react-lite'
4
-
5
- import {
6
- useCommerce,
7
- CarouselItemSelector,
8
- type CarouselItemSelectorPropsExt
9
- } from '@hanzo/commerce'
10
-
11
- const DesktopBagCarousel: React.FC<{
12
- constrainTo: {w: number, h: number}
13
- className?: string
14
- }> = observer(({
15
- constrainTo,
16
- className=''
17
-
18
- }) => {
19
- const cmmc = useCommerce()
20
- return (
21
- <CarouselItemSelector
22
- items={cmmc.cartItems}
23
- selectedItemRef={cmmc}
24
- scrollable={false} // ignored
25
- selectSku={cmmc.setCurrentItem.bind(cmmc)}
26
- clx={className}
27
- ext={{
28
- options: {loop: true},
29
- constrainTo,
30
- imageOnly: true
31
- } satisfies CarouselItemSelectorPropsExt}
32
- />
33
- )
34
- })
35
-
36
- export default DesktopBagCarousel