|
1 | | -import React, {useState} from 'react'; |
| 1 | +import React, {useContext, useState} from 'react'; |
2 | 2 | import MenuIcon from '@mui/icons-material/Menu'; |
3 | | -import {Menu, MenuItem, IconButton} from '@mui/material'; |
| 3 | +import {IconButton, ToggleButtonGroup, ToggleButton} from '@mui/material'; |
4 | 4 | import {Link} from 'react-router-dom'; |
| 5 | +import HStack from "../../../../../components/HStack"; |
| 6 | +import LogoBar from "../../../../../components/LogoBar"; |
| 7 | +import VStack from "../../../../../components/VStack"; |
| 8 | +import featureFlags from "../../../../../featureFlags"; |
| 9 | +import LandingPageHollowButton from "../../../components/LandingPageButton"; |
| 10 | +import {LanguageContext} from "../../../../../language/LanguageContext"; |
5 | 11 | import useTranslation from "../../../../../language/useTranslation"; |
| 12 | +import Divider from "@mui/material/Divider"; |
| 13 | +import globalStyles from "../../../../../styles/styles"; |
6 | 14 |
|
7 | | -const HeaderBarMobile = () => { |
8 | | - const [anchorEl, setAnchorEl] = useState(null); |
| 15 | +const HeaderBarMobile = ({isApp}) => { |
| 16 | + const [showDropdown, setShowDropdown] = useState(false); |
9 | 17 |
|
10 | | - const handleClick = (event) => { |
11 | | - setAnchorEl(event.currentTarget); |
12 | | - }; |
| 18 | + const {language, setLanguage} = useContext(LanguageContext); |
| 19 | + const {t} = useTranslation(); |
13 | 20 |
|
14 | | - const handleClose = () => { |
15 | | - setAnchorEl(null); |
| 21 | + const handleLanguageChange = (event, newLanguage) => { |
| 22 | + if (newLanguage !== null) { |
| 23 | + setLanguage(newLanguage); |
| 24 | + } |
16 | 25 | }; |
17 | 26 |
|
18 | | - // const {language, setLanguage} = useContext(LanguageContext); TODO |
19 | | - const { t } = useTranslation(); |
20 | | - |
21 | 27 | return ( |
22 | | - <> |
23 | | - <IconButton |
24 | | - aria-controls="simple-menu" |
25 | | - aria-haspopup="true" |
26 | | - onClick={handleClick} |
27 | | - > |
28 | | - <MenuIcon sx={{ fontSize: '32px' }} /> |
29 | | - </IconButton> |
30 | | - <Menu |
31 | | - id="simple-menu" |
32 | | - anchorEl={anchorEl} |
33 | | - keepMounted |
34 | | - open={Boolean(anchorEl)} |
35 | | - onClose={handleClose} |
36 | | - > |
37 | | - <MenuItem component={Link} to="/#how-it-works" onClick={handleClose}>{t('menu.howWorks')}</MenuItem> |
38 | | - <MenuItem component={Link} to="/#principles" onClick={handleClose}>{t('menu.principles')}</MenuItem> |
39 | | - <MenuItem component={Link} to="/#about-us" onClick={handleClose}>{t('menu.aboutUs')}</MenuItem> |
40 | | - </Menu> |
41 | | - </> |
| 28 | + <VStack gap={5}> |
| 29 | + <HStack gap={5} justifyContent={'space-between'} alignItems={'center'} sx={{width: '100%'}}> |
| 30 | + <HStack alignItems={'center'}> |
| 31 | + <Link to={"/"} style={{textDecoration: 'none', color: "black", width: '100%'}}> |
| 32 | + <LogoBar size={'large'}/> |
| 33 | + </Link> |
| 34 | + </HStack> |
| 35 | + <IconButton |
| 36 | + aria-controls="simple-menu" |
| 37 | + aria-haspopup="true" |
| 38 | + onClick={() => setShowDropdown(!showDropdown)} |
| 39 | + > |
| 40 | + <MenuIcon sx={{fontSize: '32px'}}/> |
| 41 | + </IconButton> |
| 42 | + </HStack> |
| 43 | + { |
| 44 | + showDropdown && ( |
| 45 | + <VStack gap={2} alignItems={'center'} |
| 46 | + sx={{ |
| 47 | + paddingBottom: '16px', |
| 48 | + borderBottom: '1px solid rgba(0, 0, 0, 0.12)', |
| 49 | + }} |
| 50 | + > |
| 51 | + {isApp ? null : |
| 52 | + featureFlags.newFeedbackSection ? ( |
| 53 | + <> |
| 54 | + <LandingPageHollowButton text={t('menu.improve')} to={'/#feedback'}/> |
| 55 | + <Divider sx={{width: '100%', backgroundColor: globalStyles.colorLightGreyTransparent}}/> |
| 56 | + </> |
| 57 | + ) |
| 58 | + : null |
| 59 | + } |
| 60 | + {isApp ? null : |
| 61 | + featureFlags.newCollaborationSection ? ( |
| 62 | + <> |
| 63 | + <LandingPageHollowButton text={t('menu.collaborate')} to={'/#collaboration'}/> |
| 64 | + <Divider sx={{width: '100%', backgroundColor: globalStyles.colorLightGreyTransparent}}/> |
| 65 | + </> |
| 66 | + ) |
| 67 | + : null |
| 68 | + } |
| 69 | + {isApp ? null : |
| 70 | + featureFlags.newActivityLog ? |
| 71 | + (<> |
| 72 | + <LandingPageHollowButton text={t('menu.activityLog')} to={'/activity-log'}/> |
| 73 | + <Divider sx={{width: '100%', backgroundColor: globalStyles.colorLightGreyTransparent}}/> |
| 74 | + </> |
| 75 | + ) |
| 76 | + : null |
| 77 | + } |
| 78 | + { |
| 79 | + isApp ? null : ( |
| 80 | + <> |
| 81 | + <LandingPageHollowButton text={t('menu.aboutUs')} to={"/#about-us"}/> |
| 82 | + <Divider sx={{width: '100%', backgroundColor: globalStyles.colorLightGreyTransparent}}/> |
| 83 | + </> |
| 84 | + ) |
| 85 | + } |
| 86 | + { |
| 87 | + featureFlags.newLanguageToggle && ( |
| 88 | + <ToggleButtonGroup |
| 89 | + value={language} |
| 90 | + exclusive |
| 91 | + onChange={handleLanguageChange} |
| 92 | + aria-label="language selection" |
| 93 | + size="small" |
| 94 | + > |
| 95 | + <ToggleButton |
| 96 | + value="en" |
| 97 | + aria-label="english" |
| 98 | + sx={{padding: '8px'}} |
| 99 | + > |
| 100 | + EN |
| 101 | + </ToggleButton> |
| 102 | + <ToggleButton |
| 103 | + value="de" |
| 104 | + aria-label="german" |
| 105 | + sx={{padding: '8px'}} |
| 106 | + > |
| 107 | + DE |
| 108 | + </ToggleButton> |
| 109 | + </ToggleButtonGroup> |
| 110 | + ) |
| 111 | + } |
| 112 | + </VStack>) |
| 113 | + } |
| 114 | + |
| 115 | + |
| 116 | + </VStack> |
42 | 117 | ) |
43 | 118 | } |
44 | 119 |
|
|
0 commit comments