Files
0pt/components/locale-switcher.tsx

31 lines
965 B
TypeScript

"use client";
import { useLocale, type Locale } from "@/components/locale-provider";
const LOCALES: Locale[] = ["en", "sv"];
export function LocaleSwitcher() {
const { locale, setLocale } = useLocale();
return (
<div className="flex items-center gap-1 font-mono text-[11px] uppercase tracking-[0.12em]">
{LOCALES.map((l, i) => (
<span key={l} className="flex items-center gap-1">
<button
type="button"
onClick={() => setLocale(l)}
aria-pressed={locale === l}
className="px-1 py-0.5 transition-colors"
style={{
color: locale === l ? "var(--foreground)" : "var(--muted-foreground)",
borderBottom: locale === l ? "1px solid var(--accent-red)" : "1px solid transparent",
}}
>
{l}
</button>
{i === 0 ? <span className="text-border">/</span> : null}
</span>
))}
</div>
);
}