@luxfi/core 5.1.6 → 5.1.7
Sign up to get free protection for your applications and to get access to all the features.
package/commerce/ui/conf.ts
CHANGED
@@ -30,9 +30,7 @@ const CommerceUIComponent: React.FC = observer(() => {
|
|
30
30
|
// see handleCloseGesture()
|
31
31
|
const setOpen = (b: boolean): void => {
|
32
32
|
if (!b) {
|
33
|
-
console.log("ON CLOSE")
|
34
33
|
if (!drawer.closedByUser) {
|
35
|
-
console.log("syncing closed state to UI gesture")
|
36
34
|
drawer.setClosedByUser(true)
|
37
35
|
}
|
38
36
|
}
|
@@ -107,7 +105,7 @@ const CommerceUIComponent: React.FC = observer(() => {
|
|
107
105
|
<Micro
|
108
106
|
handleCheckout={handleCheckout}
|
109
107
|
handleItemClicked={handleItemClicked}
|
110
|
-
clx='w-full sm:w-[460px] sm:mx-auto md:w-[550px]'
|
108
|
+
clx='w-full px-2 sm:w-[460px] sm:mx-auto md:w-[550px]'
|
111
109
|
/>
|
112
110
|
)}
|
113
111
|
</CommerceDrawer>
|
@@ -12,17 +12,9 @@ import { useCommerceDrawer, useRecentActivity } from '../../../commerce/ui/conte
|
|
12
12
|
|
13
13
|
const CN = {
|
14
14
|
// h: mind padding!
|
15
|
-
mobile: { w: 36, h:
|
16
|
-
sm: { w: 60, h:
|
17
|
-
desktop: { w: 60, h:
|
18
|
-
}
|
19
|
-
|
20
|
-
const renderTitle = (item: LineItem): React.ReactNode => {
|
21
|
-
const toks = item.title.split(', ')
|
22
|
-
if (toks.length === 2) {
|
23
|
-
return <><p>{toks[0]},</p><p className=''>{toks[1]}</p></>
|
24
|
-
}
|
25
|
-
return <p>{item.title}</p>
|
15
|
+
mobile: { w: 36, h: 32 },
|
16
|
+
sm: { w: 60, h: 34 },
|
17
|
+
desktop: { w: 60, h: 32 },
|
26
18
|
}
|
27
19
|
|
28
20
|
const Info: React.FC<{
|
@@ -62,6 +54,7 @@ const Info: React.FC<{
|
|
62
54
|
</>)
|
63
55
|
}
|
64
56
|
|
57
|
+
const PROMPT_COMMON_CLX = 'block absolute top-0 left-0 bg-transparent duration-400 transition-opacity'
|
65
58
|
|
66
59
|
const Micro: React.FC<{
|
67
60
|
clx?: string
|
@@ -75,32 +68,45 @@ const Micro: React.FC<{
|
|
75
68
|
|
76
69
|
const drawer = useCommerceDrawer()
|
77
70
|
const recent = useRecentActivity()
|
71
|
+
const mobile = drawer.isMobile
|
78
72
|
|
79
73
|
return (
|
80
74
|
<div className={cn(
|
81
|
-
'
|
82
|
-
(drawer.showAdded ? '
|
75
|
+
(drawer.showAdded ? 'grid grid-cols-2' : 'flex justify-center items-center '),
|
76
|
+
(drawer.showAdded ? ((drawer.isMobile) ? '-mt-3' : '-mt-3') : ''),
|
83
77
|
'gap-2 md:gap-3 relative',
|
84
78
|
clx
|
85
79
|
)}>
|
86
80
|
{drawer.showAdded && (
|
87
|
-
<div className='
|
88
|
-
<p className='text-muted text-xxs md:text-xs leading-none pl-1'
|
81
|
+
<div className={'flex flex-col items-stretch ' + (drawer.isMobile ? 'justify-start' : 'group')}>
|
82
|
+
<p className={'relative text-muted text-xxs md:text-xs leading-none pl-1 self-start ' + (drawer.isMobile ? 'top-[3px]' : 'top-[1px]')}>
|
83
|
+
<span className='invisible'>scrictly for layout</span>
|
84
|
+
{drawer.isMobile ? (
|
85
|
+
<span className={PROMPT_COMMON_CLX}>tap for options:</span>
|
86
|
+
) : (<>
|
87
|
+
<span className={PROMPT_COMMON_CLX + ' group-hover:opacity-0'}>recent item:</span>
|
88
|
+
<span className={PROMPT_COMMON_CLX + ' opacity-0 group-hover:opacity-100'}>view options:</span>
|
89
|
+
</>)}
|
90
|
+
</p>
|
89
91
|
<Button
|
90
92
|
variant='ghost'
|
91
|
-
rounded='
|
93
|
+
rounded={drawer.isMobile ? 'md' : 'lg'}
|
94
|
+
size={drawer.isMobile ? 'default' : 'lg'}
|
92
95
|
onClick={handleItemClicked}
|
93
96
|
className={cn(
|
97
|
+
'box-content',
|
94
98
|
'flex flex-row justify-between items-center gap-1',
|
95
99
|
'-ml-1.5',
|
96
100
|
'overflow-hidden ',
|
97
|
-
'px-1
|
101
|
+
'px-1 md:px-2 py-[2px]',
|
102
|
+
'border border-transparent group-hover:border-muted-3',
|
103
|
+
'group-hover:!bg-transparent '
|
98
104
|
)}
|
99
105
|
>
|
100
106
|
{recent.item?.img && (<>
|
101
107
|
<Image def={recent.item.img} constrainTo={CN.mobile} preload className='sm:hidden grow-0 shrink-0'/>
|
102
|
-
<Image def={recent.item.img} constrainTo={CN.sm} preload className='hidden sm:
|
103
|
-
<Image def={recent.item.img} constrainTo={CN.desktop} preload className='hidden md:
|
108
|
+
<Image def={recent.item.img} constrainTo={CN.sm} preload className='hidden sm:block md:hidden grow-0 shrink-0'/>
|
109
|
+
<Image def={recent.item.img} constrainTo={CN.desktop} preload className='hidden md:block grow-0 shrink-0'/>
|
104
110
|
</>)}
|
105
111
|
{recent.item && (
|
106
112
|
<div className='grow w-full'>
|
@@ -112,9 +118,11 @@ const Micro: React.FC<{
|
|
112
118
|
)}
|
113
119
|
{drawer.showCheckout && (
|
114
120
|
<div className={cn(
|
115
|
-
'flex flex-col
|
116
|
-
(drawer.showAdded ? 'items-stretch' : 'items-center
|
121
|
+
'flex flex-col w-full',
|
122
|
+
(drawer.showAdded ? 'items-stretch' : 'items-center' ),
|
123
|
+
(drawer.isMobile ? 'justify-start' : 'justify-center')
|
117
124
|
)}>
|
125
|
+
{drawer.showAdded && <p className='invisible text-muted text-xxs md:text-xs leading-none pl-1 self-start'>for layout</p>}
|
118
126
|
<CheckoutButton
|
119
127
|
handleCheckout={handleCheckout}
|
120
128
|
variant='primary'
|
@@ -1,10 +1,7 @@
|
|
1
1
|
'use client'
|
2
2
|
import React, {type PropsWithChildren } from 'react'
|
3
3
|
|
4
|
-
import { X as LucideX} from 'lucide-react'
|
5
|
-
|
6
4
|
import {
|
7
|
-
Button,
|
8
5
|
Drawer,
|
9
6
|
DrawerContent,
|
10
7
|
DrawerHandle,
|
@@ -48,29 +45,36 @@ const CommerceDrawer: React.FC<PropsWithChildren &
|
|
48
45
|
fastDragSkipsToEnd={false}
|
49
46
|
dragHandleOnly={true}
|
50
47
|
handleHandleClicked={handleHandleClicked}
|
48
|
+
extendHandleDragRegion={false}
|
51
49
|
// debugOutput
|
52
50
|
{...rest}
|
53
51
|
>
|
54
52
|
<DrawerContent
|
55
53
|
defaultHandle={false}
|
56
54
|
className={cn(
|
57
|
-
|
58
|
-
(micro ? (mobile ? 'mt-4 pt-1.5' : 'mt-5 pt-4') : 'mt-5 pt-5'),
|
59
|
-
'
|
55
|
+
'border-0',
|
56
|
+
//(micro ? (mobile ? 'mt-4 pt-1.5' : 'mt-5 pt-4') : 'mt-5 pt-5'),
|
57
|
+
mobile ? 'pt-5' : 'pt-6',
|
58
|
+
'w-full h-full',
|
60
59
|
)}
|
61
60
|
// https://github.com/radix-ui/primitives/discussions/935
|
62
61
|
onOpenAutoFocus={(e) => {e.preventDefault()}}
|
63
62
|
>
|
64
63
|
<DrawerHandle
|
65
64
|
className={cn(
|
66
|
-
'absolute left-0 right-0 mx-auto z-10',
|
67
|
-
'
|
68
|
-
|
69
|
-
|
70
|
-
'[&>[vaul-handle-hitarea]]:hidden',
|
71
|
-
//(!micro ? 'bg-level-3 hover:bg-level-2 ' : 'bg-level-1 hover:bg-level-2 ')
|
65
|
+
'absolute top-0 left-0 right-0 mx-auto z-10',
|
66
|
+
'flex justify-center items-start',
|
67
|
+
'border-t rounded-t-lg border-muted-2',
|
68
|
+
mobile ? 'h-5 touch-pan-y' : 'h-6',
|
72
69
|
)}
|
73
|
-
|
70
|
+
>
|
71
|
+
<div className={cn(
|
72
|
+
// pseudo-handle
|
73
|
+
'rounded-[3px] bg-level-3',
|
74
|
+
mobile ? 'w-[155px] mt-[5px] h-1.5' : 'w-[180px] mt-[3px] h-2.5 hover:bg-level-4',
|
75
|
+
!mobile ? 'cursor-grab active:cursor-grabbing' : '',
|
76
|
+
)} />
|
77
|
+
</DrawerHandle>
|
74
78
|
{children}
|
75
79
|
</DrawerContent>
|
76
80
|
</Drawer>
|
package/package.json
CHANGED