-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #820 from alexstotsky/refactor-lang-menu
(improvements) Language selection menu
- Loading branch information
Showing
4 changed files
with
16 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,33 @@ | ||
import React from 'react' | ||
import React, { useCallback } from 'react' | ||
import { useDispatch, useSelector } from 'react-redux' | ||
import _map from 'lodash/map' | ||
import _keys from 'lodash/keys' | ||
|
||
import Select from 'ui/Select' | ||
import { setLang } from 'state/base/actions' | ||
import { LANGUAGE_NAMES } from 'locales/i18n' | ||
|
||
import { propTypes, defaultProps } from './LangMenu.props' | ||
import { getLocale } from 'state/base/selectors' | ||
|
||
const items = _map(_keys(LANGUAGE_NAMES), (lang) => ({ value: lang, label: LANGUAGE_NAMES[lang] })) | ||
|
||
const LangMenu = (props) => { | ||
const { setLang, value } = props | ||
const LangMenu = () => { | ||
const dispatch = useDispatch() | ||
const currentValue = useSelector(getLocale) | ||
|
||
const handleChange = useCallback((value) => { | ||
dispatch(setLang(value)) | ||
}, [dispatch]) | ||
|
||
return ( | ||
<Select | ||
className='bitfinex-select--language' | ||
popoverClassName='bitfinex-select-menu--language' | ||
value={value} | ||
items={items} | ||
onChange={setLang} | ||
type={'Language'} | ||
value={currentValue} | ||
onChange={handleChange} | ||
className='bitfinex-select--language' | ||
popoverClassName='bitfinex-select-menu--language' | ||
/> | ||
) | ||
} | ||
|
||
LangMenu.propTypes = propTypes | ||
LangMenu.defaultProps = defaultProps | ||
|
||
export default LangMenu |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
import LangMenu from './LangMenu.container' | ||
|
||
export default LangMenu | ||
export { default } from './LangMenu' |