UNPKG

pagamio-frontend-commons-lib

Version:

Pagamio library for Frontend reusable components like the form engine and table container

19 lines (18 loc) 902 B
import { jsx as _jsx } from "react/jsx-runtime"; import { Dropdown } from 'flowbite-react'; import { useTranslation } from '../hooks'; export const LocaleSwitcher = ({ className, localeNames = { en: 'English', es: 'Español', fr: 'Français', pt: 'Português', }, }) => { const { locale, setLocale, availableLocales } = useTranslation(); const options = availableLocales .filter((code) => localeNames[code]) .map((code) => ({ value: code, label: localeNames[code] ?? code, })); return (_jsx(Dropdown, { style: { backgroundColor: 'white', color: 'white' }, label: localeNames[locale] ?? locale, className: `min-w-[120px] bg-white text-black z-[100] text-sm ${className ?? ''}`, inline: true, children: options.map((option) => (_jsx(Dropdown.Item, { onClick: () => setLocale(option.value), children: option.label }, option.value))) })); };