Skip to content

Commit

Permalink
Merge pull request #820 from alexstotsky/refactor-lang-menu
Browse files Browse the repository at this point in the history
(improvements) Language selection menu
  • Loading branch information
ezewer authored Jun 12, 2024
2 parents 4a18103 + cbedaf5 commit 842852b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 41 deletions.
18 changes: 0 additions & 18 deletions src/ui/LangMenu/LangMenu.container.js

This file was deleted.

27 changes: 15 additions & 12 deletions src/ui/LangMenu/LangMenu.js
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
8 changes: 0 additions & 8 deletions src/ui/LangMenu/LangMenu.props.js

This file was deleted.

4 changes: 1 addition & 3 deletions src/ui/LangMenu/index.js
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'

0 comments on commit 842852b

Please sign in to comment.