From 3cd9081939d2f22221065018cb501441528257fc Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 3 Jul 2020 22:09:22 +0300 Subject: feat: adapt header for mobile devices --- src/components/Header/Header.tsx | 78 ++++++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 294c250..c6c1608 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -11,25 +11,33 @@ import NotificationsIcon from '@material-ui/icons/Notifications'; import HomeIcon from '@material-ui/icons/Home'; import { useAuth } from '../../hooks/useAuth'; import { useNavigate } from '../../hooks/useNavigate'; +import { isMobile } from 'react-device-detect'; import SearchBar from './SearchBar'; -const useStyles = makeStyles({ - root: { +const useStyles = makeStyles(theme => ({ + mobile: { + top: 'auto', + bottom: 0 + }, + toolbar: { display: 'flex', - justifyContent: 'space-around', + justifyContent: 'space-around' + }, + browserToolbar: { width: '60%', margin: 'auto' }, logo: { fontWeight: 'bold', - cursor: 'pointer' + cursor: 'pointer', + color: 'white' }, avatar: { - width: 24, - height: 24 + width: theme.spacing(3), + height: theme.spacing(3) } -}); +})); const Header: React.FC = () => { const classes = useStyles(); @@ -53,31 +61,57 @@ const Header: React.FC = () => { navigate('notifications'); }; - return ( + const FeedButton = ( + + + + ); + + const NotificationsButton = ( + + + + ); + + const ProfileButton = ( + + { user?.avatarUrl + ? + : + } + + ); + + const BrowserVersion = ( - + Which
- - - - - - - - { - user?.avatarUrl - ? - : - } - + {FeedButton} + {NotificationsButton} + {ProfileButton}
); + + const MobileVersion = ( + + + + W + + {FeedButton} + {NotificationsButton} + {ProfileButton} + + + ); + + return isMobile ? MobileVersion : BrowserVersion; }; export default Header; -- cgit v1.2.3