Skip to content

Commit cfd5bcd

Browse files
feat: CategoryItem 및 RowCategories 컴포넌트 추가
1 parent 659a5e7 commit cfd5bcd

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Column } from '@repo/ui/components/Layout'
2+
import { Icon } from '@repo/ui/components/Icon'
3+
import { Text } from '@repo/ui/components/Text'
4+
import { cn } from '@repo/ui/utils/cn'
5+
import type { Category } from '@/_apis/schemas/category'
6+
7+
type Props = {
8+
category: Category
9+
isActive: boolean
10+
onClick: VoidFunction
11+
}
12+
13+
export const CategoryItem = ({ category, isActive, onClick }: Props) => {
14+
const { iconKey, name } = category
15+
16+
return (
17+
<Column
18+
as={'button'}
19+
onClick={onClick}
20+
className={'w-10 items-center gap-1'}
21+
>
22+
<Icon type={iconKey} size={26} />
23+
<Text
24+
fontSize={'xs'}
25+
fontWeight={isActive ? 'semibold' : 'light'}
26+
className={'text-nowrap'}
27+
>
28+
{name}
29+
</Text>
30+
<hr
31+
className={cn('border-main w-full rounded-full border-2', {
32+
invisible: !isActive,
33+
})}
34+
/>
35+
</Column>
36+
)
37+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { Category } from '@/_apis/schemas/category'
2+
import { Flex } from '@repo/ui/components/Layout'
3+
import { CategoryItem } from './CategoryItem'
4+
import { cn } from '@repo/ui/utils/cn'
5+
6+
type Props = {
7+
categories: Category[]
8+
id: string
9+
setIdFunc: (id: string) => void
10+
}
11+
12+
export const RowCategories = ({ id, categories, setIdFunc }: Props) => {
13+
return (
14+
<div className={'relative'}>
15+
<Flex className={'scrollbar-hide gap-4 overflow-x-auto'}>
16+
{categories.map((category) => (
17+
<CategoryItem
18+
key={category.id}
19+
category={category}
20+
isActive={id === category.id}
21+
onClick={() => {
22+
setIdFunc(category.id)
23+
}}
24+
/>
25+
))}
26+
</Flex>
27+
<ScrollHintGradient />
28+
</div>
29+
)
30+
}
31+
32+
const ScrollHintGradient = () => (
33+
<div
34+
className={cn(
35+
'absolute',
36+
'right-[-1px] top-0',
37+
'h-full w-10',
38+
'z-10',
39+
'bg-gradient-to-l from-white to-transparent',
40+
)}
41+
/>
42+
)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { RowCategories } from './RowCategories'

0 commit comments

Comments
 (0)