import { Shield, CheckCircle2, Users } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import type { TrustFilterLevel } from '@/lib/trustFilter'; import { Button } from '@/components/ui/button'; import { DropdownMenu, DropdownMenuContent, DropdownMenuCheckboxItem, DropdownMenuTrigger, DropdownMenuLabel, DropdownMenuSeparator, } from '@/components/ui/dropdown-menu'; import { cn } from '@/lib/utils'; import { useTranslation } from '@/contexts/language'; interface TrustFilterProps { value: TrustFilterLevel; onChange: (value: TrustFilterLevel) => void; className?: string; compact?: boolean; } const TRUST_LEVELS = [ { value: 'all' as const, labelKey: 'chromeUi.trust.all', descKey: 'chromeUi.trust.allDesc', icon: Users, color: 'text-gray-400', }, { value: 'verified' as const, labelKey: 'chromeUi.trust.verified', descKey: 'chromeUi.trust.verifiedDesc', icon: CheckCircle2, color: 'text-green-500', }, { value: 'trusted' as const, labelKey: 'chromeUi.trust.trusted', descKey: 'chromeUi.trust.trustedDesc', icon: Shield, color: 'text-yellow-500', }, { value: 'following' as const, labelKey: 'chromeUi.trust.following', descKey: 'chromeUi.trust.followingDesc', icon: CheckCircle2, color: 'text-green-500', }, ]; export function TrustFilter({ value, onChange, className, compact = false }: TrustFilterProps) { const { t } = useTranslation(); const currentLevel = TRUST_LEVELS.find((l) => l.value === value) || TRUST_LEVELS[0]; const Icon = currentLevel.icon; if (compact) { return ( {t('chromeUi.filterByTrustLevel')} {TRUST_LEVELS.map((level) => ( onChange(level.value)} className="flex flex-col items-start py-3" >
{t(level.labelKey)}

{t(level.descKey)}

))}
); } return (
{TRUST_LEVELS.map((level) => { const Icon = level.icon; const isActive = value === level.value; return ( ); })}
); } /** * Helper function to filter items by trust score */