Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(improvements) Language selection menu #820

Merged
merged 7 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'