Skip to content

Commit 6de079c

Browse files
committed
refactor: replace custom SortTab with shadcn Tabs for sort controls
Swapped the hand-rolled SortTab pill buttons for shadcn/ui Tabs (Radix TabsPrimitive). Gets us keyboard navigation, ARIA roles, and consistent styling from the design system for free. Removed 18 lines of custom component, added 6 lines of shadcn usage.
1 parent 673de1c commit 6de079c

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

frontend/src/components/RepoList.tsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from './ui/dialog'
1919
import { Button } from './ui/button'
2020
import { Input } from './ui/input'
21+
import { Tabs, TabsList, TabsTrigger } from './ui/tabs'
2122
import type { Repository } from '../types'
2223
import { RepoGridSkeleton } from './ui/Skeleton'
2324

@@ -187,24 +188,6 @@ const RepoCard = ({ repo, index, onSelect, onDeleteClick }: {
187188
)
188189
}
189190

190-
const SortTab = ({ label, active, onClick }: {
191-
label: string
192-
active: boolean
193-
onClick: () => void
194-
}) => (
195-
<button
196-
onClick={onClick}
197-
className={cn(
198-
'text-xs px-3 py-1 rounded-full transition-colors',
199-
active
200-
? 'bg-primary/10 text-primary font-medium'
201-
: 'text-muted-foreground hover:text-foreground',
202-
)}
203-
>
204-
{label}
205-
</button>
206-
)
207-
208191
export function RepoList({ repos, selectedRepo, onSelect, onDelete, onAddClick, loading }: RepoListProps) {
209192
const [sortMode, setSortMode] = useState<SortMode>('recent')
210193
const [deleteTarget, setDeleteTarget] = useState<Repository | null>(null)
@@ -255,10 +238,14 @@ export function RepoList({ repos, selectedRepo, onSelect, onDelete, onAddClick,
255238
return (
256239
<div className="space-y-4">
257240
{/* Sort bar */}
258-
<div className="flex items-center gap-1">
259-
<SortTab label="Recent" active={sortMode === 'recent'} onClick={() => setSortMode('recent')} />
260-
<SortTab label="Name" active={sortMode === 'name'} onClick={() => setSortMode('name')} />
261-
<SortTab label="Size" active={sortMode === 'size'} onClick={() => setSortMode('size')} />
241+
<div className="flex items-center">
242+
<Tabs value={sortMode} onValueChange={(v) => setSortMode(v as SortMode)}>
243+
<TabsList className="h-8">
244+
<TabsTrigger value="recent" className="text-xs px-3">Recent</TabsTrigger>
245+
<TabsTrigger value="name" className="text-xs px-3">Name</TabsTrigger>
246+
<TabsTrigger value="size" className="text-xs px-3">Size</TabsTrigger>
247+
</TabsList>
248+
</Tabs>
262249
<span className="ml-auto text-xs text-muted-foreground">{repos.length} repos</span>
263250
</div>
264251

0 commit comments

Comments
 (0)