/* global React, useLocale */ // Jullia — the language switch. A compact trigger (the current code, a hairline // chevron) that opens a small dropdown of the other two. No flags — just the // codes, set mono, wide tracking. Closes on selection or on an outside click. function LanguageSwitch({ size = 'sm', align = 'right', style = {} }) { const { locale, setLocale } = useLocale(); const locales = window.JULLIA_LOCALES || ['ua', 'pl', 'en']; const labels = window.JULLIA_LOCALE_LABELS || {}; const [open, setOpen] = React.useState(false); const rootRef = React.useRef(null); const fontSize = size === 'lg' ? 'var(--text-sm)' : 'var(--text-2xs)'; React.useEffect(() => { if (!open) return undefined; const onDocDown = (e) => { if (rootRef.current && !rootRef.current.contains(e.target)) setOpen(false); }; document.addEventListener('mousedown', onDocDown); return () => document.removeEventListener('mousedown', onDocDown); }, [open]); const choose = (l) => { setLocale(l); setOpen(false); }; return (
{open && (
{locales.filter((l) => l !== locale).map((l) => ( ))}
)}
); } window.LanguageSwitch = LanguageSwitch;