import React, { ComponentProps } from 'react'; import { ScrollArea } from './ui/scroll-area'; import { cn } from '@/utils/style'; import { Badge } from './ui/badge'; import { useNavigate, useRouterState } from '@tanstack/react-router'; export interface CommonListItem { id: string; title: string; content: React.ReactNode; tags: string[]; href: string; } interface CommonListProps { items: CommonListItem[]; } export const CommonList: React.FC = React.memo((props) => { const { location } = useRouterState(); const navigate = useNavigate(); return (
{props.items.map((item) => { const isSelected = item.href === location.pathname; return ( ); })}
); }); CommonList.displayName = 'CommonList'; /** * TODO */ function getBadgeVariantFromLabel( label: string ): ComponentProps['variant'] { if (['work'].includes(label.toLowerCase())) { return 'default'; } if (['personal'].includes(label.toLowerCase())) { return 'outline'; } return 'secondary'; }