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/components/Header/Header.tsx') 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 From f6bb137ccf414ba36610c0ceea598c95683dce60 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 3 Jul 2020 23:00:04 +0300 Subject: refactor: use mui-breakpoints --- src/components/Header/Header.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/components/Header/Header.tsx') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index c6c1608..e7f9f47 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -3,15 +3,16 @@ import { AppBar, Toolbar, IconButton, - Typography, Avatar + Typography, + Avatar, + useMediaQuery } from '@material-ui/core'; -import { makeStyles } from '@material-ui/core/styles'; +import { makeStyles, useTheme } from '@material-ui/core/styles'; import AccountCircle from '@material-ui/icons/AccountCircle'; 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'; @@ -43,6 +44,8 @@ const Header: React.FC = () => { const classes = useStyles(); const { user } = useAuth(); const { navigate } = useNavigate(); + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const handleHome = (): void => { navigate('home'); -- cgit v1.2.3 From c3a9c9251e704d702d16c74016d347b209ed8bc6 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 3 Jul 2020 23:23:56 +0300 Subject: fix: make iconbutton round --- src/components/Header/Header.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components/Header/Header.tsx') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index e7f9f47..bf831d4 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -34,7 +34,7 @@ const useStyles = makeStyles(theme => ({ cursor: 'pointer', color: 'white' }, - avatar: { + round: { width: theme.spacing(3), height: theme.spacing(3) } @@ -79,7 +79,7 @@ const Header: React.FC = () => { const ProfileButton = ( { user?.avatarUrl - ? + ? : } @@ -105,7 +105,7 @@ const Header: React.FC = () => { - W + W {FeedButton} {NotificationsButton} -- cgit v1.2.3 From b52743cc950e9633a2da41f72d3462286c629967 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 4 Jul 2020 00:08:57 +0300 Subject: style: remove eslint errors --- src/components/Header/Header.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/components/Header/Header.tsx') diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index bf831d4..41aeec7 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -78,7 +78,8 @@ const Header: React.FC = () => { const ProfileButton = ( - { user?.avatarUrl + { + user?.avatarUrl ? : } -- cgit v1.2.3