@luxfi/ui 5.5.3 → 5.6.0

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 (244) hide show
  1. package/dist/accordion.cjs +213 -0
  2. package/dist/accordion.js +186 -0
  3. package/dist/alert.cjs +553 -0
  4. package/dist/alert.js +531 -0
  5. package/dist/avatar.cjs +149 -0
  6. package/dist/avatar.js +125 -0
  7. package/dist/badge.cjs +611 -0
  8. package/dist/badge.js +589 -0
  9. package/dist/button.cjs +689 -0
  10. package/dist/button.js +664 -0
  11. package/dist/checkbox.cjs +265 -0
  12. package/dist/checkbox.js +241 -0
  13. package/dist/close-button.cjs +73 -0
  14. package/dist/close-button.js +51 -0
  15. package/dist/collapsible.cjs +702 -0
  16. package/dist/collapsible.js +679 -0
  17. package/dist/color-mode.cjs +96 -0
  18. package/dist/color-mode.js +72 -0
  19. package/dist/dialog.cjs +279 -0
  20. package/dist/dialog.js +246 -0
  21. package/dist/drawer.cjs +207 -0
  22. package/dist/drawer.js +175 -0
  23. package/dist/empty-state.cjs +93 -0
  24. package/dist/empty-state.js +71 -0
  25. package/dist/field.cjs +183 -0
  26. package/dist/field.js +160 -0
  27. package/dist/heading.cjs +46 -0
  28. package/dist/heading.js +40 -0
  29. package/dist/icon-button.cjs +491 -0
  30. package/dist/icon-button.js +470 -0
  31. package/dist/image.cjs +572 -0
  32. package/dist/image.js +551 -0
  33. package/dist/index.cjs +5779 -0
  34. package/dist/index.js +5619 -0
  35. package/dist/input-group.cjs +155 -0
  36. package/dist/input-group.js +133 -0
  37. package/dist/input.cjs +65 -0
  38. package/dist/input.js +59 -0
  39. package/dist/link.cjs +630 -0
  40. package/dist/link.js +606 -0
  41. package/dist/menu.cjs +305 -0
  42. package/dist/menu.js +269 -0
  43. package/dist/pin-input.cjs +182 -0
  44. package/dist/pin-input.js +160 -0
  45. package/dist/popover.cjs +327 -0
  46. package/dist/popover.js +294 -0
  47. package/dist/progress-circle.cjs +152 -0
  48. package/dist/progress-circle.js +128 -0
  49. package/dist/progress.cjs +117 -0
  50. package/dist/progress.js +94 -0
  51. package/dist/provider.cjs +62 -0
  52. package/dist/provider.js +40 -0
  53. package/dist/radio.cjs +177 -0
  54. package/dist/radio.js +153 -0
  55. package/dist/rating.cjs +80 -0
  56. package/dist/rating.js +58 -0
  57. package/dist/select.cjs +791 -0
  58. package/dist/select.js +757 -0
  59. package/dist/separator.cjs +57 -0
  60. package/dist/separator.js +51 -0
  61. package/dist/skeleton.cjs +370 -0
  62. package/dist/skeleton.js +346 -0
  63. package/dist/slider.cjs +138 -0
  64. package/dist/slider.js +115 -0
  65. package/dist/switch.cjs +163 -0
  66. package/dist/switch.js +140 -0
  67. package/dist/table.cjs +1044 -0
  68. package/dist/table.js +1013 -0
  69. package/dist/tabs.cjs +240 -0
  70. package/dist/tabs.js +213 -0
  71. package/dist/tag.cjs +651 -0
  72. package/dist/tag.js +628 -0
  73. package/dist/textarea.cjs +65 -0
  74. package/dist/textarea.js +59 -0
  75. package/dist/toaster.cjs +99 -0
  76. package/dist/toaster.js +96 -0
  77. package/dist/tooltip.cjs +171 -0
  78. package/dist/tooltip.js +148 -0
  79. package/dist/utils.cjs +11 -0
  80. package/dist/utils.js +9 -0
  81. package/package.json +270 -65
  82. package/src/accordion.tsx +285 -0
  83. package/src/alert.tsx +221 -0
  84. package/src/avatar.tsx +174 -0
  85. package/src/badge.tsx +158 -0
  86. package/src/button.tsx +411 -0
  87. package/src/checkbox.tsx +307 -0
  88. package/src/close-button.tsx +51 -0
  89. package/src/collapsible.tsx +126 -0
  90. package/src/color-mode.tsx +125 -0
  91. package/src/dialog.tsx +356 -0
  92. package/src/drawer.tsx +186 -0
  93. package/src/empty-state.tsx +97 -0
  94. package/src/field.tsx +202 -0
  95. package/src/heading.tsx +55 -0
  96. package/src/icon-button.tsx +192 -0
  97. package/src/image.tsx +280 -0
  98. package/src/index.ts +192 -0
  99. package/src/input-group.tsx +159 -0
  100. package/src/input.tsx +60 -0
  101. package/src/link.tsx +326 -0
  102. package/src/menu.tsx +471 -0
  103. package/src/pin-input.tsx +187 -0
  104. package/src/popover.tsx +400 -0
  105. package/src/progress-circle.tsx +180 -0
  106. package/src/progress.tsx +109 -0
  107. package/src/provider.tsx +12 -0
  108. package/src/radio.tsx +175 -0
  109. package/src/rating.tsx +79 -0
  110. package/src/select.tsx +696 -0
  111. package/src/separator.tsx +59 -0
  112. package/src/skeleton.tsx +302 -0
  113. package/src/slider.tsx +152 -0
  114. package/src/switch.tsx +158 -0
  115. package/src/table.tsx +621 -0
  116. package/src/tabs.tsx +354 -0
  117. package/src/tag.tsx +159 -0
  118. package/src/textarea.tsx +60 -0
  119. package/src/toaster.tsx +117 -0
  120. package/src/tokens.css +438 -0
  121. package/src/tooltip.tsx +184 -0
  122. package/src/utils/cn.ts +7 -0
  123. package/src/utils.ts +6 -0
  124. package/tokens.css +438 -0
  125. package/commerce/ui/conf.ts +0 -13
  126. package/commerce/ui/context.tsx +0 -123
  127. package/commerce/ui/store.ts +0 -295
  128. package/components/access-code-input.tsx +0 -71
  129. package/components/analytics.tsx +0 -23
  130. package/components/auth/auth-listener.tsx +0 -29
  131. package/components/auth/auth-token/clear-auth-token.tsx +0 -12
  132. package/components/auth/auth-token/set-auth-token.tsx +0 -16
  133. package/components/auth/common-auth-domains.ts +0 -17
  134. package/components/auth/login-panel.tsx +0 -111
  135. package/components/auth/mobile-login-button.tsx +0 -107
  136. package/components/auth/signup-panel.tsx +0 -113
  137. package/components/back-button.tsx +0 -49
  138. package/components/chat-widget.tsx +0 -85
  139. package/components/commerce/bag-button.tsx +0 -98
  140. package/components/commerce/buy-button.tsx +0 -34
  141. package/components/commerce/checkout-button.tsx +0 -129
  142. package/components/commerce/checkout-panel/cart-accordian.tsx +0 -66
  143. package/components/commerce/checkout-panel/checkout-panel-props.ts +0 -10
  144. package/components/commerce/checkout-panel/desktop-bag-carousel.tsx +0 -36
  145. package/components/commerce/checkout-panel/desktop-cp.tsx +0 -83
  146. package/components/commerce/checkout-panel/index.tsx +0 -126
  147. package/components/commerce/checkout-panel/mobile-cp.tsx +0 -67
  148. package/components/commerce/checkout-panel/policy-links.tsx +0 -29
  149. package/components/commerce/checkout-panel/steps-indicator.tsx +0 -39
  150. package/components/commerce/checkout-panel/thank-you.tsx +0 -18
  151. package/components/commerce/desktop-bag-popup.tsx +0 -78
  152. package/components/commerce/drawer/index.tsx +0 -88
  153. package/components/commerce/drawer/micro.tsx +0 -145
  154. package/components/commerce/drawer/shell.tsx +0 -85
  155. package/components/contact-dialog/contact-form.tsx +0 -116
  156. package/components/contact-dialog/disclaimer.tsx +0 -13
  157. package/components/contact-dialog/index.tsx +0 -64
  158. package/components/copyright.tsx +0 -21
  159. package/components/drawer-margin.tsx +0 -28
  160. package/components/footer.tsx +0 -78
  161. package/components/header/desktop-nav-menu.tsx +0 -204
  162. package/components/header/desktop.tsx +0 -65
  163. package/components/header/index.tsx +0 -50
  164. package/components/header/mobile-bag-drawer.tsx +0 -51
  165. package/components/header/mobile-menu-toggle-button.tsx +0 -35
  166. package/components/header/mobile-nav-menu-ai.tsx +0 -51
  167. package/components/header/mobile-nav-menu-item.tsx +0 -47
  168. package/components/header/mobile-nav-menu.tsx +0 -102
  169. package/components/header/mobile.tsx +0 -170
  170. package/components/header/theme-toggle.tsx +0 -26
  171. package/components/icons/avatar.tsx +0 -11
  172. package/components/icons/bag-icon.tsx +0 -10
  173. package/components/icons/index.ts +0 -6
  174. package/components/icons/left-arrow.tsx +0 -11
  175. package/components/icons/lux-logo.tsx +0 -10
  176. package/components/icons/right-arrow.tsx +0 -10
  177. package/components/icons/social-icon.tsx +0 -35
  178. package/components/icons/social-svg.css +0 -3
  179. package/components/index.ts +0 -26
  180. package/components/logo.tsx +0 -92
  181. package/components/main.tsx +0 -27
  182. package/components/mini-chart/index.tsx +0 -8
  183. package/components/mini-chart/mini-chart-props.ts +0 -44
  184. package/components/mini-chart/mini-chart.tsx +0 -85
  185. package/components/mini-chart/wrapper.tsx +0 -23
  186. package/components/not-found/index.tsx +0 -28
  187. package/components/not-found/not-found-content.mdx +0 -5
  188. package/components/tooltip.tsx +0 -31
  189. package/environment.d.ts +0 -6
  190. package/next/analytics/fpixel.ts +0 -16
  191. package/next/analytics/google-analytics.ts +0 -14
  192. package/next/analytics/index.ts +0 -3
  193. package/next/analytics/pixel-analytics.tsx +0 -55
  194. package/next/font/get-app-router-font-classes.ts +0 -17
  195. package/next/font/load-and-return-lux-next-fonts-on-import.ts +0 -68
  196. package/next/font/local/Druk-Wide-Bold.ttf +0 -0
  197. package/next/font/local/Druk-Wide-Medium.ttf +0 -0
  198. package/next/font/local/InterVariable-Italic.ttf +0 -0
  199. package/next/font/local/InterVariable-Italic.woff2 +0 -0
  200. package/next/font/local/InterVariable.ttf +0 -0
  201. package/next/font/local/InterVariable.woff2 +0 -0
  202. package/next/font/next-font-desc.ts +0 -28
  203. package/next/font/pages-router-font-vars.tsx +0 -18
  204. package/next/head-metadata/from-next/metadata-types.ts +0 -158
  205. package/next/head-metadata/from-next/opengraph-types.ts +0 -267
  206. package/next/head-metadata/from-next/twitter-types.ts +0 -92
  207. package/next/head-metadata/index.tsx +0 -208
  208. package/next/index.ts +0 -2
  209. package/next/middleware/determine-device-mw.ts +0 -29
  210. package/root-layout/WHY_THIS_IS_SEPARATE.txt +0 -2
  211. package/root-layout/index.tsx +0 -112
  212. package/site-def/footer/community.tsx +0 -61
  213. package/site-def/footer/company.ts +0 -37
  214. package/site-def/footer/ecosystem.ts +0 -37
  215. package/site-def/footer/index.tsx +0 -26
  216. package/site-def/footer/legal.ts +0 -28
  217. package/site-def/footer/network.ts +0 -45
  218. package/site-def/footer/svg/warpcast-logo.svg +0 -12
  219. package/site-def/index.ts +0 -4
  220. package/site-def/main-nav.tsx +0 -460
  221. package/style/cart-animation.css +0 -29
  222. package/style/checkout-animation.css +0 -23
  223. package/style/drawer-handle-overrides.css +0 -160
  224. package/style/fonts/COPY_TO_PUBLIC_FOR_NON_NEXT.txt +0 -0
  225. package/style/fonts/Druk-Wide-Bold.ttf +0 -0
  226. package/style/fonts/Druk-Wide-Medium.ttf +0 -0
  227. package/style/fonts/InterVariable-Italic.ttf +0 -0
  228. package/style/fonts/InterVariable-Italic.woff2 +0 -0
  229. package/style/fonts/InterVariable.ttf +0 -0
  230. package/style/fonts/InterVariable.woff2 +0 -0
  231. package/style/lux-colors.css +0 -85
  232. package/style/lux-fonts.css +0 -30
  233. package/style/lux-global-non-next.css +0 -52
  234. package/style/lux-global.css +0 -51
  235. package/tailwind/fontFamily.tailwind.lux.ts +0 -18
  236. package/tailwind/index.ts +0 -2
  237. package/tailwind/lux-tw-fonts.ts +0 -40
  238. package/tailwind/tailwind.config.lux-preset.ts +0 -10
  239. package/tsconfig.json +0 -15
  240. package/types/chatbot-config.ts +0 -7
  241. package/types/chatbot-suggested-question.ts +0 -7
  242. package/types/contact-info.ts +0 -11
  243. package/types/index.ts +0 -4
  244. package/types/site-def.ts +0 -46
@@ -1,113 +0,0 @@
1
- 'use client'
2
-
3
- import Link from 'next/link'
4
- import { useRouter } from 'next/navigation'
5
-
6
- import { setCookie } from 'cookies-next'
7
-
8
- import { cn } from '@hanzo/ui/util'
9
- import { Button, Carousel, CarouselContent, CarouselItem } from '@hanzo/ui/primitives'
10
- import { LoginPanel as Login, SignupPanel as Signup } from '@hanzo/auth/components'
11
-
12
- import { LuxLogo } from '../icons'
13
- import Logo from '../logo'
14
- import { EmblaAutoplay } from '..'
15
- import { legal } from '../../site-def/footer'
16
-
17
- const SignupPanel: React.FC<{
18
- close: () => void
19
- getStartedUrl?: string
20
- redirectUrl?: string
21
- className?: string
22
- reviews: { text: string, author: string, href: string }[]
23
- setIsLogin?: React.Dispatch<React.SetStateAction<boolean>>
24
- }> = ({
25
- close,
26
- getStartedUrl = '/',
27
- redirectUrl,
28
- className = '',
29
- reviews,
30
- setIsLogin
31
- }) => {
32
- const router = useRouter()
33
-
34
- const termsOfServiceUrl = legal.find(({ title }) => title === 'Terms and Conditions')?.href || ''
35
- const privacyPolicyUrl = legal.find(({ title }) => title === 'Privacy Policy')?.href || ''
36
- const domains = ['lux.id', 'lux.credit', 'lux.market', 'lux.network', 'lux.shop', 'wallet.lux.network', 'safe.lux.network', 'lux.finance', 'lux.exchange', 'lux.quest']
37
-
38
- // TODO :aa shouldn't this happen in @hanzo/auth: components/LoginPanel ??
39
- // Otherwise, the functionality is split across modules! (and client/fw!)
40
- // (This was never my intent w the onLoginChanged callback.)
41
- const onLogin = (token: string) => {
42
- for (let i = 0; i < domains.length; i++) {
43
- setCookie('auth-token', token, {
44
- domain: domains[i],
45
- path: '/',
46
- sameSite: 'none',
47
- secure: true,
48
- httpOnly: false,
49
- expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // 30 days
50
- })
51
- }
52
-
53
- redirectUrl && router.push(redirectUrl)
54
- }
55
-
56
- return (
57
- <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
58
- <div className='hidden md:flex w-full h-full bg-[radial-gradient(circle_at_24.1%_68.8%_,_rgba(15,14,14,0)_,_rgba(9,9,9,99.4))] flex-row items-end justify-end overflow-y-auto min-h-screen'>
59
- <div className='h-full w-full max-w-[750px] px-8 pt-0'>
60
- <div className='h-full w-full max-w-[550px] mx-auto flex flex-col justify-between min-h-screen py-10'>
61
- <Button
62
- variant='ghost'
63
- onClick={close}
64
- className='w-fit !min-w-0 p-2'
65
- >
66
- <Logo size='md' textClx='!cursor-pointer' variant='text-only' />
67
- </Button>
68
- <Carousel
69
- options={{ align: 'center', loop: true }}
70
- className='w-full'
71
- plugins={[EmblaAutoplay({ delay: 5000, stopOnInteraction: true })]}
72
- >
73
- <CarouselContent>
74
- {reviews.map(({ text, author, href }, index) => (
75
- <CarouselItem key={index}>
76
- <Link href={href} className='flex flex-col gap-3 cursor-pointer'>
77
- <p>“{text}“</p>
78
- <p className='text-sm'>{author}</p>
79
- </Link>
80
- </CarouselItem>
81
- ))}
82
- </CarouselContent>
83
- </Carousel>
84
- </div>
85
- </div>
86
- </div>
87
- <div className='w-full h-full bg-background flex flex-row items-center'>
88
- <div className='w-full max-w-[750px] relative flex flex-col items-center px-8 pt-0 text-center'>
89
- <div className='relative h-full w-full max-w-[400px] mx-auto flex flex-col gap-4 items-center py-10'>
90
- <Button
91
- variant='ghost'
92
- onClick={close}
93
- className='block md:hidden absolute rounded-full p-2 left-0 h-auto hover:bg-background'
94
- >
95
- <LuxLogo className='w-5 h-5' />
96
- </Button>
97
- <Signup
98
- getStartedUrl={getStartedUrl}
99
- redirectUrl={redirectUrl}
100
- className='w-full max-w-sm'
101
- termsOfServiceUrl={termsOfServiceUrl}
102
- privacyPolicyUrl={privacyPolicyUrl}
103
- onLoginChanged={onLogin}
104
- setIsLogin={setIsLogin}
105
- />
106
- </div>
107
- </div>
108
- </div>
109
- </div>
110
- )
111
- }
112
-
113
- export default SignupPanel
@@ -1,49 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
- import { useRouter } from 'next/navigation'
4
-
5
- import { ChevronLeft } from 'lucide-react'
6
-
7
-
8
- import {
9
- Button,
10
- buttonVariants,
11
- } from '@hanzo/ui/primitives'
12
-
13
- import type { VariantProps } from '@hanzo/ui/util'
14
-
15
- const BackButton: React.FC<{
16
- variant?: VariantProps<typeof buttonVariants>['variant']
17
- size?: VariantProps<typeof buttonVariants>['size']
18
- onBack?: () => void
19
- clx?: string
20
- iconClx?: string
21
- }> = ({
22
- variant='ghost',
23
- size='default',
24
- clx='',
25
- iconClx='',
26
- onBack
27
- }) => {
28
-
29
- const router = useRouter()
30
- const back = () => {
31
- if (onBack) {
32
- onBack()
33
- }
34
- router.back()
35
- }
36
-
37
- return (
38
- <Button
39
- variant={variant}
40
- size={size}
41
- onClick={back}
42
- className={clx}
43
- >
44
- <ChevronLeft className={iconClx}/>
45
- </Button>
46
- )
47
- }
48
-
49
- export default BackButton
@@ -1,85 +0,0 @@
1
- 'use client'
2
- import React from 'react'
3
-
4
- import { Button, Card } from '@hanzo/ui/primitives'
5
- import { cn } from '@hanzo/ui/util'
6
-
7
- import { LuxLogo } from './icons'
8
- import type { ChatbotSuggestedQuestion } from '../types'
9
-
10
- const ChatWidget: React.FC<{
11
- title: string
12
- chatbotUrl: string
13
- subtitle?: string
14
- question?: string
15
- buttonClx?: string
16
- /*
17
- ChatBotSuggestQuestion.icon
18
- Currently supports these icons from remix icons (https://remixicon.com/):
19
- GlobalLineIcon,
20
- ShieldFlashLineIcon,
21
- BankCardLineIcon,
22
- GroupLineIcon,
23
- QuestionnaireLineIcon
24
- */
25
- suggestedQuestions?: ChatbotSuggestedQuestion[]
26
- }> = ({
27
- title,
28
- chatbotUrl,
29
- subtitle,
30
- question,
31
- suggestedQuestions,
32
- buttonClx=''
33
- }) => {
34
-
35
- const [showChatbot, setShowChatbot] = React.useState<boolean>(false)
36
-
37
- const onClick = () => { setShowChatbot(!showChatbot) }
38
-
39
- const searchParams = new URLSearchParams()
40
- if (question) {
41
- searchParams.append('question', question)
42
- }
43
- if (suggestedQuestions) {
44
- searchParams.append('sQuestions', suggestedQuestions.map(({ message }) => message).join(','))
45
- searchParams.append('sHeadings', suggestedQuestions.map(({ heading }) => heading).join(','))
46
- searchParams.append('sIcons', suggestedQuestions.map(({ icon }) => icon).join(','))
47
- }
48
-
49
- const iframeSrc = `${chatbotUrl}?${searchParams.toString()}`
50
-
51
- return (<>
52
- <div className={
53
- 'fixed bottom-0 sm:bottom-16 right-0 w-full h-full ' +
54
- 'sm:max-w-[400px] sm:max-h-[550px] sm:px-4 z-floating ' +
55
- (showChatbot ? 'flex' : 'hidden')
56
- }>
57
- <Card className='flex flex-col h-full w-full'>
58
- <div className='flex px-4 py-2 h-12 bg-level-0 items-center justify-between'>
59
- <h1 className='font-semibold font-heading'>{title} <span className='opacity-60'>{subtitle}</span></h1>
60
- <Button onClick={onClick} variant='link' size='icon' className='w-fit sm:hidden'>
61
- <LuxLogo width={24} height={24}/>
62
- </Button>
63
- </div>
64
- <iframe src={iframeSrc} className='h-full' />
65
- </Card>
66
- </div>
67
-
68
- <LuxLogo
69
- width={28}
70
- height={28}
71
- onClick={onClick}
72
- className={cn(
73
- // z-index should be below anything in commerce-iu (buy drawer and checkout widget)
74
- 'fixed bottom-5 right-[24px] md:z-floating z-16 cursor-pointer',
75
- 'hover:drop-shadow-[0_2px_6px_rgba(255,255,255,1)]',
76
- 'transition-transform',
77
- showChatbot ? 'rotate-180' : '',
78
- buttonClx
79
- )}
80
- strokeWidth={1}
81
- />
82
- </>)
83
- }
84
-
85
- export default ChatWidget
@@ -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 { Bag } 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 && c) ? 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
- <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 { Bag } 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
- <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