All files / core/components LanguageSwitcher.tsx

100% Statements 5/5
100% Branches 0/0
100% Functions 3/3
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29        3x 14x   14x               1x         56x                
import { useTranslation } from 'react-i18next'
import { Globe } from 'lucide-react'
import { LOCALE_LABELS } from '@fundraising/white-labeling'
 
export const LanguageSwitcher = () => {
    const { i18n } = useTranslation()
 
    return (
        <div className="relative flex items-center border rounded-md hover:bg-black/5 transition-colors">
            <Globe
                className="absolute left-2.5 h-4 w-4 opacity-70 pointer-events-none"
                style={{ color: 'var(--header-text)' }}
            />
            <select
                value={i18n.language}
                onChange={(e) => i18n.changeLanguage(e.target.value)}
                className="h-9 w-[110px] appearance-none bg-transparent pl-9 pr-2 text-sm font-medium focus:outline-none cursor-pointer"
                style={{ color: 'var(--header-text)' }}
            >
                {Object.entries(LOCALE_LABELS).map(([code, name]) => (
                    <option key={code} value={code}>
                        {name}
                    </option>
                ))}
            </select>
        </div>
    )
}