Skip to content

Commit 4695225

Browse files
committed
Fix landing bench
1 parent 668eab3 commit 4695225

File tree

3 files changed

+77
-6
lines changed

3 files changed

+77
-6
lines changed

apps/landing/src/app/Bench.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Box, Flex, Text, VStack } from '@devup-ui/react'
1+
import { Flex, Text, VStack } from '@devup-ui/react'
22

3+
import { BenchBox } from './BenchBox'
34
import { DevupUICard } from './DevupUICard'
45
import { OtherCard } from './OtherCard'
56

@@ -86,10 +87,7 @@ export function Bench() {
8687
<Flex display={[null, null, null, null, 'none']}>
8788
<DevupUICard />
8889
</Flex>
89-
<Box
90-
overflow={['auto', null, null, null, 'visible']}
91-
scrollbarWidth="none"
92-
>
90+
<BenchBox>
9391
<Flex
9492
alignItems="flex-end"
9593
flexWrap={[null, null, null, null, 'wrap']}
@@ -105,7 +103,7 @@ export function Bench() {
105103
<OtherCard key={item.title} {...item} />
106104
))}
107105
</Flex>
108-
</Box>
106+
</BenchBox>
109107
</VStack>
110108
</VStack>
111109
)

apps/landing/src/app/BenchBox.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use client'
2+
3+
import { Box } from '@devup-ui/react'
4+
import { useRef } from 'react'
5+
import { useCallback, useState } from 'react'
6+
import { ReactNode } from 'react'
7+
8+
interface BenchBoxProps {
9+
children: ReactNode
10+
}
11+
export function BenchBox({ children }: BenchBoxProps) {
12+
const scrollRef = useRef<HTMLDivElement>(null)
13+
const [isDragging, setIsDragging] = useState(false)
14+
const [startX, setStartX] = useState(0)
15+
const [scrollLeft, setScrollLeft] = useState(0)
16+
17+
const handleMouseDown = useCallback((e: React.MouseEvent) => {
18+
if (!scrollRef.current) return
19+
20+
setIsDragging(true)
21+
setStartX(e.pageX - scrollRef.current.offsetLeft)
22+
setScrollLeft(scrollRef.current.scrollLeft)
23+
scrollRef.current.style.cursor = 'grabbing'
24+
scrollRef.current.style.userSelect = 'none'
25+
}, [])
26+
27+
const handleMouseMove = useCallback(
28+
(e: React.MouseEvent) => {
29+
if (!isDragging || !scrollRef.current) return
30+
31+
e.preventDefault()
32+
const x = e.pageX - scrollRef.current.offsetLeft
33+
const walk = (x - startX) * 2 // 스크롤 속도 조절
34+
scrollRef.current.scrollLeft = scrollLeft - walk
35+
},
36+
[isDragging, startX, scrollLeft],
37+
)
38+
39+
const handleMouseUp = useCallback(() => {
40+
if (!scrollRef.current) return
41+
42+
setIsDragging(false)
43+
scrollRef.current.style.cursor = 'grab'
44+
scrollRef.current.style.userSelect = 'auto'
45+
}, [])
46+
47+
const handleMouseLeave = useCallback(() => {
48+
if (!scrollRef.current) return
49+
50+
setIsDragging(false)
51+
scrollRef.current.style.cursor = 'grab'
52+
scrollRef.current.style.userSelect = 'auto'
53+
}, [])
54+
55+
return (
56+
<Box
57+
ref={scrollRef}
58+
cursor={['grab', null, null, null, 'default']}
59+
onMouseDown={handleMouseDown}
60+
onMouseLeave={handleMouseLeave}
61+
onMouseMove={handleMouseMove}
62+
onMouseUp={handleMouseUp}
63+
overflow={['auto', null, null, null, 'visible']}
64+
scrollbarWidth="none"
65+
style={{
66+
WebkitOverflowScrolling: 'touch', // iOS에서 부드러운 스크롤
67+
}}
68+
>
69+
{children}
70+
</Box>
71+
)
72+
}

apps/landing/src/app/OtherCard.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export function OtherCard({
2525
gap={['20px', null, '40px']}
2626
h={[null, null, null, null, '318px']}
2727
justifyContent="space-between"
28+
maxW={[null, null, null, null, '300px']}
2829
minW={[null, null, '240px', null, 'none']}
2930
p={[6, null, '30px']}
3031
>

0 commit comments

Comments
 (0)