mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-10 01:52:04 +05:30
32 lines
929 B
JavaScript
32 lines
929 B
JavaScript
|
// @flow
|
||
|
import React from 'react';
|
||
|
import { connect } from 'react-redux';
|
||
|
import { create as createPopup } from 'components/ui/popup/actions';
|
||
|
import { localeFlags } from 'components/i18n';
|
||
|
import LANGS from 'i18n/index.json';
|
||
|
import LanguageSwitcher from '../LanguageSwitcher';
|
||
|
import styles from './link.scss';
|
||
|
|
||
|
function LanguageLink({
|
||
|
userLang,
|
||
|
showLanguageSwitcherPopup,
|
||
|
}: {
|
||
|
userLang: string,
|
||
|
showLanguageSwitcherPopup: Function,
|
||
|
}) {
|
||
|
return (
|
||
|
<span className={styles.languageLink} onClick={showLanguageSwitcherPopup}>
|
||
|
<span className={styles.languageIcon} style={{
|
||
|
backgroundImage: `url('${localeFlags.getIconUrl(userLang)}')`
|
||
|
}} />
|
||
|
{LANGS[userLang].name}
|
||
|
</span>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export default connect((state) => ({
|
||
|
userLang: state.user.lang,
|
||
|
}), {
|
||
|
showLanguageSwitcherPopup: () => createPopup(LanguageSwitcher),
|
||
|
})(LanguageLink);
|