terriajs
Version:
Geospatial data visualization platform.
28 lines • 1.58 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { useTranslation } from "react-i18next";
import Box from "../../../../Styled/Box";
import { RawButton } from "../../../../Styled/Button";
import Icon from "../../../../Styled/Icon";
import { TextSpan } from "../../../../Styled/Text";
import Ul, { Li } from "../../../../Styled/List";
import MenuPanel from "../../../StandardUserInterface/customizable/MenuPanel";
import Styles from "../../MenuBar/menu-bar.scss";
const stripLangLocale = (lang = "") => lang.split("-")[0];
const LangPanel = (props) => {
const { t, i18n } = useTranslation();
if (!props.terria.configParameters.languageConfiguration?.languages) {
return null;
}
return (
//@ts-expect-error - not yet ready to tackle tsfying MenuPanel
_jsx(MenuPanel, { theme: {
btn: Styles.langBtn,
icon: Icon.GLYPHS.globe
}, btnText: props.smallScreen
? t("languagePanel.changeLanguage")
: stripLangLocale(i18n.language), mobileIcon: Icon.GLYPHS.globe, smallScreen: props.smallScreen, children: _jsx(Box, { paddedRatio: 3, children: _jsx(Ul, { spaced: true, lined: true, fullWidth: true, column: true, css: `
padding-left: 0;
`, children: Object.entries(props.terria.configParameters.languageConfiguration.languages).map(([key, value]) => (_jsx(Li, { children: _jsx(RawButton, { onClick: () => i18n.changeLanguage(key), children: _jsx(TextSpan, { isLink: true, children: value }) }) }, key))) }) }) }));
};
export default LangPanel;
//# sourceMappingURL=LangPanel.js.map