forked from EpamLifeSciencesTeam/cmwl_pipeline_fe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* flexDirection was removed from App styles * props were passed via spread operator in CmwlInput * boolean props were explicitly passed in CmwlInput * code style refactoring in CmwlTypographyLink * inputChangedHandler was curried * useClasses was added for combining class names via a map from string to boolean * theme.spacing was used in styles instead of hardcoded px units * localization provider was implemented using React contexts in combination with hooks * locale switcher was implemented and added to the Dashboard
- Loading branch information
Aleksei Litkovetc
committed
Mar 1, 2021
1 parent
10936de
commit d93cebe
Showing
17 changed files
with
331 additions
and
115 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React, { ChangeEvent, FC, useContext } from 'react'; | ||
import { LocaleContext, LocaleLanguage } from '../../../context/LocaleContext'; | ||
import { Avatar, MenuItem, Select } from '@material-ui/core'; | ||
import { ReactComponent as USAIcon } from '../../../assets/flags/UnitedStates.svg'; | ||
import { ReactComponent as RussiaIcon } from '../../../assets/flags/Russia.svg'; | ||
import { useLocaleSwitcherStyles } from './LocaleSwitcherStyles'; | ||
|
||
export const LocaleSwitcher: FC = () => { | ||
const classes = useLocaleSwitcherStyles(); | ||
const { locale, setLocale } = useContext(LocaleContext); | ||
|
||
const localeItems = [ | ||
{ | ||
locale: LocaleLanguage.en, | ||
icon: <USAIcon /> | ||
}, | ||
{ | ||
locale: LocaleLanguage.ru, | ||
icon: <RussiaIcon /> | ||
} | ||
]; | ||
|
||
const menuItems = () => { | ||
return localeItems.map(item => ( | ||
<MenuItem key={item.locale} value={item.locale} className={classes.menuItem}> | ||
<Avatar className={classes.avatar}> | ||
{item.icon} | ||
</Avatar> | ||
</MenuItem> | ||
)); | ||
}; | ||
|
||
const onChangeSelectHandler = (event: ChangeEvent<{ value: unknown }>) => { | ||
setLocale(event.target.value as LocaleLanguage); | ||
}; | ||
|
||
return ( | ||
<Select value={locale} | ||
onChange={onChangeSelectHandler} | ||
disableUnderline={true} | ||
classes={{ | ||
icon: classes.hideIcon, | ||
select: classes.select | ||
}} | ||
MenuProps={{ | ||
getContentAnchorEl: null, | ||
anchorOrigin: { | ||
vertical: 'bottom', | ||
horizontal: 'left' | ||
} | ||
}}> | ||
{menuItems()} | ||
</Select> | ||
); | ||
}; |
Oops, something went wrong.