11import { useCallback , useMemo } from 'react' ;
22import { useSearchParams } from 'react-router' ;
33
4- import { Box , Chip , ChipDelete , IconButton , Input , List , ListItem , ListItemButton , ListItemContent , ListItemDecorator , Stack , Typography } from '@mui/joy' ;
4+ import { Box , Chip , ChipDelete , IconButton , Input , Stack , Typography } from '@mui/joy' ;
55
66import categories from '@/data/categories' ;
77import icons from '@/data/icons' ;
@@ -10,6 +10,7 @@ import useSearch from '@/hooks/useSearch';
1010import { ILibraryIcon } from '@/types' ;
1111
1212import Amicon , { aiFilterXmark , aiMagnifyingGlass } from '@studio384/amicons' ;
13+ import clsx from 'clsx' ;
1314
1415import IconCard from './Components/IconCard' ;
1516import Pagination from './Components/Pagination' ;
@@ -99,40 +100,30 @@ export default function Icons() {
99100 } }
100101 >
101102 < Box sx = { { position : 'sticky' , top : 58 + 16 , overflow : 'auto' , maxHeight : 'calc(100dvh - 58px - 16px)' , alignSelf : 'flex-start' } } >
102- < List
103- sx = { {
104- p : 0 ,
105- my : 2 ,
106- gap : 0.25 ,
107- '--ListItem-paddingY' : 0 ,
108- '--ListItem-radius' : 'var(--joy-radius-md)' ,
109- '--ListItem-paddingLeft' : '.5rem' ,
110- '--ListItem-paddingRight' : '.5rem' ,
111- '--ListItemDecorator-size' : '1.5rem'
112- } }
113- >
103+ < div className = "flex flex-col gap-0.5" >
114104 { categories . map ( ( _category ) => {
115105 const categoryIcons = searchableList . filter ( ( icon ) => icon . categories . includes ( _category . slug as never ) ) ;
116106
117107 return (
118- < ListItem key = { _category . slug } >
119- < ListItemButton onClick = { ( ) => setSearchQuery ( 'c' , _category . slug ) } selected = { searchCategories . includes ( _category . slug ) } color = "primary" >
120- < ListItemDecorator sx = { { opacity : categoryIcons . length === 0 ? 0.5 : 1 } } >
121- < Amicon icon = { _category . icon } />
122- </ ListItemDecorator >
123- < ListItemContent >
124- < Typography noWrap sx = { { opacity : categoryIcons . length === 0 ? 0.5 : 1 } } >
125- { _category . title }
126- </ Typography >
127- </ ListItemContent >
128- < ListItemContent sx = { { fontFamily : 'display' , textAlign : 'right' , opacity : categoryIcons . length === 0 ? 0.5 : 1 } } >
129- { categoryIcons . length }
130- </ ListItemContent >
131- </ ListItemButton >
132- </ ListItem >
108+ < button
109+ key = { _category . slug }
110+ onClick = { ( ) => setSearchQuery ( 'c' , _category . slug ) }
111+ data-selected = { searchCategories . includes ( _category . slug ) || undefined }
112+ data-noicons = { categoryIcons . length === 0 ? true : undefined }
113+ className = { clsx (
114+ 'group grid h-8 grid-cols-[min-content_auto_min-content] items-center gap-2 rounded-sm px-2.5 text-start text-sm hover:cursor-pointer hover:bg-indigo-200 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-indigo-500 data-selected:focus-visible:outline-indigo-700' ,
115+ {
116+ 'bg-indigo-500 text-white hover:bg-indigo-600' : searchCategories . includes ( _category . slug )
117+ }
118+ ) }
119+ >
120+ < Amicon icon = { _category . icon } className = "text-indigo-600 group-data-noicons:opacity-50 group-data-selected:text-white" />
121+ < span className = "truncate group-data-noicons:opacity-50" > { _category . title } </ span >
122+ < span className = "font-display text-indigo-600 group-data-noicons:opacity-50 group-data-selected:text-white" > { categoryIcons . length } </ span >
123+ </ button >
133124 ) ;
134125 } ) }
135- </ List >
126+ </ div >
136127 </ Box >
137128 < Stack gap = { 2 } sx = { { my : 2 } } >
138129 < Stack direction = "row" gap = { 1 } justifyContent = "space-between" alignItems = "center" >
0 commit comments