excalidraw/src/components/LanguageList.tsx

33 lines
646 B
TypeScript
Raw Normal View History

import React from "react";
export function LanguageList<T>({
onClick,
languages,
2020-01-24 12:04:54 +02:00
currentLanguage,
}: {
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>
);
}