File tree Expand file tree Collapse file tree
apps/web/app/categories/[id]/_components/RowCategories Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ )
Original file line number Diff line number Diff line change 1+ export { RowCategories } from './RowCategories'
You can’t perform that action at this time.
0 commit comments