2020-01-22 16:25:04 +02:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
export function LanguageList<T>({
|
|
|
|
onClick,
|
|
|
|
languages,
|
2020-01-24 12:04:54 +02:00
|
|
|
currentLanguage,
|
2020-01-22 16:25:04 +02:00
|
|
|
}: {
|
|
|
|
languages: { lng: string; label: string }[];
|
|
|
|
onClick: (value: string) => void;
|
|
|
|
currentLanguage: string;
|
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<ul>
|
|
|
|
{languages.map((language, idx) => (
|
|
|
|
<li
|
|
|
|
key={idx}
|
|
|
|
className={currentLanguage === language.lng ? "current" : ""}
|
|
|
|
>
|
|
|
|
<a
|
|
|
|
href="/"
|
|
|
|
onClick={e => {
|
|
|
|
onClick(language.lng);
|
|
|
|
e.preventDefault();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{language.label}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|