From 3cd9081939d2f22221065018cb501441528257fc Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> 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 = ( + <IconButton onClick={handleFeed}> + <HomeIcon /> + </IconButton> + ); + + const NotificationsButton = ( + <IconButton onClick={handleNotifications}> + <NotificationsIcon /> + </IconButton> + ); + + const ProfileButton = ( + <IconButton onClick={handleProfile}> + { user?.avatarUrl + ? <Avatar className={classes.avatar} src={user?.avatarUrl} /> + : <AccountCircle /> + } + </IconButton> + ); + + const BrowserVersion = ( <AppBar position="fixed"> - <Toolbar className={classes.root}> + <Toolbar className={`${classes.toolbar} ${classes.browserToolbar}`}> <Typography variant="h5" className={classes.logo} onClick={handleHome}> Which </Typography> <SearchBar /> <div> - <IconButton onClick={handleFeed}> - <HomeIcon /> - </IconButton> - <IconButton onClick={handleNotifications}> - <NotificationsIcon /> - </IconButton> - <IconButton onClick={handleProfile}> - { - user?.avatarUrl - ? <Avatar className={classes.avatar} src={user?.avatarUrl} /> - : <AccountCircle /> - } - </IconButton> + {FeedButton} + {NotificationsButton} + {ProfileButton} </div> </Toolbar> </AppBar> ); + + const MobileVersion = ( + <AppBar position="fixed" className={classes.mobile}> + <Toolbar className={classes.toolbar}> + <IconButton onClick={handleHome}> + <Typography className={classes.logo}>W</Typography> + </IconButton> + {FeedButton} + {NotificationsButton} + {ProfileButton} + </Toolbar> + </AppBar> + ); + + return isMobile ? MobileVersion : BrowserVersion; }; export default Header; -- cgit v1.2.3 From f74dedfce4ade65cfe023c973a6c137a56c88ab5 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 22:09:54 +0300 Subject: feat: adapt HomePage for mobile devices --- src/pages/HomePage/HomePage.tsx | 4 ++-- src/pages/Page.tsx | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 8995630..35130d8 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -61,7 +61,7 @@ const HomePage: React.FC = () => { return ( <Grid container spacing={4}> - <Grid item xs={4}> + <Grid item xs={12} md={4}> <Grid container direction="column" spacing={1} alignItems="center"> <Grid item> <img src={`${process.env.PUBLIC_URL}/which-logo-512.png`} alt="logo" className={classes.logo} /> @@ -76,7 +76,7 @@ const HomePage: React.FC = () => { </Grid> </Grid> </Grid> - <Grid item xs={5}> + <Grid item xs={12} md={5}> <Grid container direction="column" spacing={6}> <Grid item> <Typography variant="h4"> Which one to choose? </Typography> diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 24487f3..c2b422e 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { SnackbarProvider } from 'notistack'; +import { isMobile } from 'react-device-detect'; + import ProfilePage from './ProfilePage/ProfilePage'; import FeedPage from './FeedPage/FeedPage'; import AuthPage from './AuthPage/AuthPage'; @@ -8,9 +10,10 @@ import HomePage from './HomePage/HomePage'; import NotificationsPage from './NotificationsPage/NotificationsPage'; import { useNavigate } from '../hooks/useNavigate'; + const useStyles = makeStyles(theme => ({ root: { - margin: theme.spacing(15, 5, 5, 8) + margin: isMobile ? theme.spacing(5, 2) : theme.spacing(15, 5, 5, 8) } })); -- cgit v1.2.3 From 6a216b903899d1481f93ebff40e246f60c4c3e89 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 22:44:38 +0300 Subject: feat: adapt all pages to mobile view --- src/components/PollCard/PollCard.tsx | 8 +------- src/pages/FeedPage/FeedPage.tsx | 15 +++------------ src/pages/FeedPage/PollSubmission.tsx | 9 ++++++--- src/pages/FeedPage/PollSubmissionImage.tsx | 5 ++++- src/pages/Page.tsx | 2 +- src/pages/ProfilePage/ProfilePage.tsx | 14 +++----------- 6 files changed, 18 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index f5a5762..ca85d11 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -26,14 +26,8 @@ const DATE_FORMAT = { }; const useStyles = makeStyles(theme => ({ - root: { - maxWidth: theme.spacing(75), - height: 488, - margin: '40px auto' - }, images: { height: theme.spacing(50), - width: 300 }, imagesBlock: { display: 'flex' @@ -103,7 +97,7 @@ const PollCard: React.FC<PropTypes> = ({ initialPoll }) => { const dominant: Which = left.votes >= right.votes ? 'left' : 'right'; return ( - <Card className={classes.root}> + <Card> <UserStrip user={author} info={date} /> <div className={classes.imagesBlock}> <CardActionArea onDoubleClick={handleLeft}> diff --git a/src/pages/FeedPage/FeedPage.tsx b/src/pages/FeedPage/FeedPage.tsx index 8149c8c..0b7d44a 100644 --- a/src/pages/FeedPage/FeedPage.tsx +++ b/src/pages/FeedPage/FeedPage.tsx @@ -1,24 +1,15 @@ import React, { useState, useEffect } from 'react'; import { Poll } from 'which-types'; -import { makeStyles } from '@material-ui/core/styles'; +import { Container } from '@material-ui/core/'; import Feed from '../../components/Feed/Feed'; import { get } from '../../requests'; import PollSubmission from './PollSubmission'; import { useAuth } from '../../hooks/useAuth'; - -const useStyles = makeStyles(theme => ({ - root: { - width: theme.spacing(75), - margin: '0 auto' - } -})); - const FeedPage: React.FC = () => { const [polls, setPolls] = useState<Poll[]>([]); const { isAuthenticated } = useAuth(); - const classes = useStyles(); useEffect(() => { get('/feed').then(response => { @@ -33,10 +24,10 @@ const FeedPage: React.FC = () => { }; return ( - <div className={classes.root}> + <Container maxWidth="sm" disableGutters> {isAuthenticated() && <PollSubmission addPoll={addPoll} />} <Feed polls={polls} /> - </div> + </Container> ); }; diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx index b067914..5c8efbb 100644 --- a/src/pages/FeedPage/PollSubmission.tsx +++ b/src/pages/FeedPage/PollSubmission.tsx @@ -21,8 +21,11 @@ interface PropTypes{ const useStyles = makeStyles(theme => ({ root: { + marginBottom: theme.spacing(4) + }, + images: { height: theme.spacing(50), - display: 'flex' + display: 'flex', } })); @@ -63,11 +66,11 @@ const PollSubmission: React.FC<PropTypes> = ({ addPoll }) => { return ( <ClickAwayListener onClickAway={handleClickAway}> - <Card> + <Card className={classes.root}> <Collapse in={expanded} timeout="auto" unmountOnExit> {user && <UserStrip user={user} info="" />} <Divider /> - <div className={classes.root}> + <div className={classes.images}> <PollSubmissionImage url={contents.left.url} setUrl={setUrl('left')} /> <PollSubmissionImage url={contents.right.url} setUrl={setUrl('right')} /> </div> diff --git a/src/pages/FeedPage/PollSubmissionImage.tsx b/src/pages/FeedPage/PollSubmissionImage.tsx index a8ec437..8835989 100644 --- a/src/pages/FeedPage/PollSubmissionImage.tsx +++ b/src/pages/FeedPage/PollSubmissionImage.tsx @@ -28,6 +28,9 @@ const useStyles = makeStyles({ display: 'flex', justifyContent: 'center', alignItems: 'center' + }, + text: { + textAlign: 'center' } }); @@ -56,7 +59,7 @@ const PollSubmissionImage: React.FC<PropTypes> = ({ url, setUrl }) => { const Upload = ( <> <CloudUploadIcon fontSize="large" color="primary" /> - <Typography variant="h5"> Upload an image </Typography> + <Typography variant="h5" className={classes.text}> Upload an image </Typography> </> ); diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index c2b422e..4c46ea8 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -13,7 +13,7 @@ import { useNavigate } from '../hooks/useNavigate'; const useStyles = makeStyles(theme => ({ root: { - margin: isMobile ? theme.spacing(5, 2) : theme.spacing(15, 5, 5, 8) + margin: isMobile ? theme.spacing(2) : theme.spacing(15, 5, 5, 8) } })); diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 4710ae8..9a8f69a 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { User, Poll } from 'which-types'; -import { makeStyles } from '@material-ui/core/styles'; +import { Container } from '@material-ui/core'; import ProfileInfo from './ProfileInfo'; import Feed from '../../components/Feed/Feed'; @@ -9,20 +9,12 @@ import { useAuth } from '../../hooks/useAuth'; import { useNavigate } from '../../hooks/useNavigate'; -const useStyles = makeStyles(theme => ({ - root: { - width: theme.spacing(75), - margin: '0 auto' - } -})); - const ProfilePage: React.FC = () => { const [userInfo, setUserInfo] = useState<User>(); const [polls, setPolls] = useState<Poll[]>([]); const [totalVotes, setTotalVotes] = useState<number>(0); const { page, navigate } = useNavigate(); const { user } = useAuth(); - const classes = useStyles(); useEffect(() => { const id = page?.id || user?._id; @@ -44,7 +36,7 @@ const ProfilePage: React.FC = () => { }, [navigate, page, user]); return ( - <div className={classes.root}> + <Container maxWidth="sm"> <ProfileInfo userInfo={userInfo} setUserInfo={setUserInfo} @@ -52,7 +44,7 @@ const ProfilePage: React.FC = () => { totalVotes={totalVotes} /> <Feed polls={[...polls]} /> - </div> + </Container> ); }; -- cgit v1.2.3 From f6bb137ccf414ba36610c0ceea598c95683dce60 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 23:00:04 +0300 Subject: refactor: use mui-breakpoints --- src/components/Header/Header.tsx | 9 ++++++--- src/pages/Page.tsx | 8 ++++++-- src/pages/ProfilePage/ProfilePage.tsx | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src') 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'); diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 4c46ea8..91b7214 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -1,7 +1,6 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { SnackbarProvider } from 'notistack'; -import { isMobile } from 'react-device-detect'; import ProfilePage from './ProfilePage/ProfilePage'; import FeedPage from './FeedPage/FeedPage'; @@ -13,7 +12,12 @@ import { useNavigate } from '../hooks/useNavigate'; const useStyles = makeStyles(theme => ({ root: { - margin: isMobile ? theme.spacing(2) : theme.spacing(15, 5, 5, 8) + [theme.breakpoints.down('sm')]: { + margin: theme.spacing(2) + }, + [theme.breakpoints.up('md')]: { + margin: theme.spacing(15, 5, 5, 8) + } } })); diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 9a8f69a..b7a4a75 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -36,7 +36,7 @@ const ProfilePage: React.FC = () => { }, [navigate, page, user]); return ( - <Container maxWidth="sm"> + <Container maxWidth="sm" disableGutters> <ProfileInfo userInfo={userInfo} setUserInfo={setUserInfo} -- cgit v1.2.3 From c3a9c9251e704d702d16c74016d347b209ed8bc6 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> 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') 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 = ( <IconButton onClick={handleProfile}> { user?.avatarUrl - ? <Avatar className={classes.avatar} src={user?.avatarUrl} /> + ? <Avatar className={classes.round} src={user?.avatarUrl} /> : <AccountCircle /> } </IconButton> @@ -105,7 +105,7 @@ const Header: React.FC = () => { <AppBar position="fixed" className={classes.mobile}> <Toolbar className={classes.toolbar}> <IconButton onClick={handleHome}> - <Typography className={classes.logo}>W</Typography> + <Typography className={`${classes.logo} ${classes.round}`}>W</Typography> </IconButton> {FeedButton} {NotificationsButton} -- cgit v1.2.3 From f95dbb6c7f119276dd9a15dc82f48c61b745d8c1 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 23:42:06 +0300 Subject: feat: hide grid overflow in HomePage --- src/pages/HomePage/HomePage.tsx | 128 +++++++++++++++++++++------------------- 1 file changed, 67 insertions(+), 61 deletions(-) (limited to 'src') diff --git a/src/pages/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 35130d8..f00289a 100644 --- a/src/pages/HomePage/HomePage.tsx +++ b/src/pages/HomePage/HomePage.tsx @@ -16,6 +16,10 @@ import { useAuth } from '../../hooks/useAuth'; import { get } from '../../requests'; const useStyles = makeStyles(theme => ({ + root: { + overflow: 'hidden', + padding: theme.spacing(0, 2) + }, logo: { width: theme.spacing(20), height: theme.spacing(20) @@ -60,77 +64,79 @@ const HomePage: React.FC = () => { const MUILink = <Link href="https://material-ui.com">Material-UI</Link>; return ( - <Grid container spacing={4}> - <Grid item xs={12} md={4}> - <Grid container direction="column" spacing={1} alignItems="center"> - <Grid item> - <img src={`${process.env.PUBLIC_URL}/which-logo-512.png`} alt="logo" className={classes.logo} /> - </Grid> - <Grid item> - <Rating value={rating} readOnly size="large" /> - </Grid> - <Grid item> - <Typography variant="h5" className={classes.score}> - User score: {rating.toFixed(1)} - </Typography> + <div className={classes.root}> + <Grid container spacing={4}> + <Grid item xs={12} md={4}> + <Grid container direction="column" spacing={1} alignItems="center"> + <Grid item> + <img src={`${process.env.PUBLIC_URL}/which-logo-512.png`} alt="logo" className={classes.logo} /> + </Grid> + <Grid item> + <Rating value={rating} readOnly size="large" /> + </Grid> + <Grid item> + <Typography variant="h5" className={classes.score}> + User score: {rating.toFixed(1)} + </Typography> + </Grid> </Grid> </Grid> - </Grid> - <Grid item xs={12} md={5}> - <Grid container direction="column" spacing={6}> - <Grid item> - <Typography variant="h4"> Which one to choose? </Typography> - <Divider /> - <Typography> - <p> - Have you ever found yourself stuck between two options, not being able to choose any? - This is exactly the problem we are going to solve! - </p> - <p>Share your minor everyday uncertainties with the whole world and see what others think!</p> - <Button variant="contained" color="primary" size="large" onClick={handleLetsGo}> - {'let\'s go!'} - </Button> - {!isAuthenticated() && ( + <Grid item xs={12} md={5}> + <Grid container direction="column" spacing={6}> + <Grid item> + <Typography variant="h4"> Which one to choose? </Typography> + <Divider /> + <Typography> + <p> + Have you ever found yourself stuck between two options, not being able to choose any? + This is exactly the problem we are going to solve! + </p> + <p>Share your minor everyday uncertainties with the whole world and see what others think!</p> + <Button variant="contained" color="primary" size="large" onClick={handleLetsGo}> + {'let\'s go!'} + </Button> + {!isAuthenticated() && ( + <Button + variant="outlined" + color="primary" + size="large" + className={classes.signup} + onClick={handleSignUp} + > + sign up + </Button> + )} + </Typography> + </Grid> + <Grid item> + <Typography variant="h4"> About the project </Typography> + <Divider /> + <Typography> + <p> + The project is written in {TypescriptLink} and features {ReactLink}, {FeathersLink}, and {MUILink}. + It is currently open-source and you can visit our {GithubLink} (make sure to star our repositories)! + </p> + <p> + We encourage any developer to check it out. Feel free to open issues and create Pull Requests! + </p> + <p> + All the development process is being tracked on the KanBan board (thanks GitHub). + You can always check it to see what is the current state of the project. + </p> <Button variant="outlined" color="primary" - size="large" - className={classes.signup} - onClick={handleSignUp} + startIcon={<TrendingUpIcon />} + href="https://github.com/orgs/which-ecosystem/projects/1" > - sign up + track our progress </Button> - )} - </Typography> - </Grid> - <Grid item> - <Typography variant="h4"> About the project </Typography> - <Divider /> - <Typography> - <p> - The project is written in {TypescriptLink} and features {ReactLink}, {FeathersLink}, and {MUILink}. - It is currently open-source and you can visit our {GithubLink} (make sure to star our repositories)! - </p> - <p> - We encourage any developer to check it out. Feel free to open issues and create Pull Requests! - </p> - <p> - All the development process is being tracked on the KanBan board (thanks GitHub). - You can always check it to see what is the current state of the project. - </p> - <Button - variant="outlined" - color="primary" - startIcon={<TrendingUpIcon />} - href="https://github.com/orgs/which-ecosystem/projects/1" - > - track our progress - </Button> - </Typography> + </Typography> + </Grid> </Grid> </Grid> </Grid> - </Grid> + </div> ); }; -- cgit v1.2.3 From 6d593eebffffdeb09323198d118c8de15786ab2e Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 23:42:23 +0300 Subject: feat: setup correct padding for Page --- src/pages/Page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 91b7214..c0ba3d2 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -13,10 +13,10 @@ import { useNavigate } from '../hooks/useNavigate'; const useStyles = makeStyles(theme => ({ root: { [theme.breakpoints.down('sm')]: { - margin: theme.spacing(2) + margin: theme.spacing(2, 0, 12, 0) }, [theme.breakpoints.up('md')]: { - margin: theme.spacing(15, 5, 5, 8) + margin: theme.spacing(15, 5, 8, 5) } } })); -- cgit v1.2.3 From 86b09f910a44502a7d7b1e14b50b2f02158dfb39 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 23:42:32 +0300 Subject: feat: lower the height of polls --- src/components/Feed/Feed.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx index 5814711..afa914d 100644 --- a/src/components/Feed/Feed.tsx +++ b/src/components/Feed/Feed.tsx @@ -42,7 +42,7 @@ const Feed: React.FC<PropTypes> = ({ polls }) => { isScrolling={isScrolling} onScroll={onChildScroll} rowCount={polls.length} - rowHeight={600} + rowHeight={550} rowRenderer={RenderItem} scrollTop={scrollTop} width={width} -- cgit v1.2.3 From 77b583d42341d00fc1fd458f552afa2cd847d955 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Fri, 3 Jul 2020 23:45:39 +0300 Subject: feat: display notifications on top if mobile --- src/pages/Page.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index c0ba3d2..56d7372 100644 --- a/src/pages/Page.tsx +++ b/src/pages/Page.tsx @@ -1,5 +1,6 @@ import React from 'react'; -import { makeStyles } from '@material-ui/core/styles'; +import { makeStyles, useTheme } from '@material-ui/core/styles'; +import { useMediaQuery } from '@material-ui/core'; import { SnackbarProvider } from 'notistack'; import ProfilePage from './ProfilePage/ProfilePage'; @@ -24,12 +25,14 @@ const useStyles = makeStyles(theme => ({ const Page: React.FC = () => { const { page } = useNavigate(); const classes = useStyles(); + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); return ( <SnackbarProvider maxSnack={3} anchorOrigin={{ - vertical: 'bottom', + vertical: isMobile ? 'top' : 'bottom', horizontal: 'right' }} > -- cgit v1.2.3 From 2a83b58e40d60dc058f385440a3125c60fb90026 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Sat, 4 Jul 2020 00:05:33 +0300 Subject: refactor: improve scrollTopArrow --- src/components/ScrollTopArrow/ScrollTopArrow.tsx | 40 ++++++++++++++---------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/components/ScrollTopArrow/ScrollTopArrow.tsx b/src/components/ScrollTopArrow/ScrollTopArrow.tsx index 6b9d5c9..dfa573f 100644 --- a/src/components/ScrollTopArrow/ScrollTopArrow.tsx +++ b/src/components/ScrollTopArrow/ScrollTopArrow.tsx @@ -1,26 +1,33 @@ import React, { useState } from 'react'; -import { FaArrowCircleUp } from 'react-icons/fa'; -import { makeStyles } from '@material-ui/core'; -import teal from '@material-ui/core/colors/teal'; +import { makeStyles, useTheme } from '@material-ui/core/styles'; +import { useMediaQuery } from '@material-ui/core'; +import ArrowUpwardIcon from '@material-ui/icons/ArrowUpward'; -const useStyles = makeStyles(() => ({ - scrollTop: { +const useStyles = makeStyles(theme => ({ + root: { position: 'fixed', - width: 50, - bottom: 50, - left: 50, + bottom: theme.spacing(10), + left: theme.spacing(10), zIndex: 1000, cursor: 'pointer', - opacity: 0.5, + opacity: 0.4, '&:hover': { - opacity: '1' - } + opacity: 1 + }, + background: theme.palette.primary.main, + borderRadius: '50%' + }, + icon: { + fontSize: 80, + color: 'white' } })); -const ScrollTopArrow:React.FC = () => { +const ScrollTopArrow: React.FC = () => { const [showScroll, setShowScroll] = useState(false); + const theme = useTheme(); const classes = useStyles(); + const isMobile = useMediaQuery(theme.breakpoints.down("sm")); const checkScrollTop = () => { if (!showScroll && window.pageYOffset > 400) { @@ -37,11 +44,10 @@ const ScrollTopArrow:React.FC = () => { window.addEventListener('scroll', checkScrollTop); return ( - <FaArrowCircleUp - className={classes.scrollTop} - onClick={scrollTop} - style={{ height: 50, display: showScroll ? 'block' : 'none', color: teal[700] }} - /> + <div className={classes.root}> + {showScroll && !isMobile && + <ArrowUpwardIcon className={classes.icon} color="primary" onClick={scrollTop} />} + </div> ); }; -- cgit v1.2.3 From b52743cc950e9633a2da41f72d3462286c629967 Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Sat, 4 Jul 2020 00:08:57 +0300 Subject: style: remove eslint errors --- src/components/Header/Header.tsx | 3 ++- src/components/PollCard/PollCard.tsx | 2 +- src/components/ScrollTopArrow/ScrollTopArrow.tsx | 9 ++++++--- src/pages/FeedPage/PollSubmission.tsx | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src') 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 = ( <IconButton onClick={handleProfile}> - { user?.avatarUrl + { + user?.avatarUrl ? <Avatar className={classes.round} src={user?.avatarUrl} /> : <AccountCircle /> } diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index ca85d11..98ae001 100644 --- a/src/components/PollCard/PollCard.tsx +++ b/src/components/PollCard/PollCard.tsx @@ -27,7 +27,7 @@ const DATE_FORMAT = { const useStyles = makeStyles(theme => ({ images: { - height: theme.spacing(50), + height: theme.spacing(50) }, imagesBlock: { display: 'flex' diff --git a/src/components/ScrollTopArrow/ScrollTopArrow.tsx b/src/components/ScrollTopArrow/ScrollTopArrow.tsx index dfa573f..08b8591 100644 --- a/src/components/ScrollTopArrow/ScrollTopArrow.tsx +++ b/src/components/ScrollTopArrow/ScrollTopArrow.tsx @@ -27,7 +27,7 @@ const ScrollTopArrow: React.FC = () => { const [showScroll, setShowScroll] = useState(false); const theme = useTheme(); const classes = useStyles(); - const isMobile = useMediaQuery(theme.breakpoints.down("sm")); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const checkScrollTop = () => { if (!showScroll && window.pageYOffset > 400) { @@ -45,8 +45,11 @@ const ScrollTopArrow: React.FC = () => { return ( <div className={classes.root}> - {showScroll && !isMobile && - <ArrowUpwardIcon className={classes.icon} color="primary" onClick={scrollTop} />} + { + showScroll + && !isMobile + && <ArrowUpwardIcon className={classes.icon} color="primary" onClick={scrollTop} /> + } </div> ); }; diff --git a/src/pages/FeedPage/PollSubmission.tsx b/src/pages/FeedPage/PollSubmission.tsx index 5c8efbb..347eecc 100644 --- a/src/pages/FeedPage/PollSubmission.tsx +++ b/src/pages/FeedPage/PollSubmission.tsx @@ -25,7 +25,7 @@ const useStyles = makeStyles(theme => ({ }, images: { height: theme.spacing(50), - display: 'flex', + display: 'flex' } })); -- cgit v1.2.3 From 7b698a68cb3d332aecfebf7a85b2ac56f9448bea Mon Sep 17 00:00:00 2001 From: eug-vs <eug-vs@keemail.me> Date: Sat, 4 Jul 2020 00:10:12 +0300 Subject: style: improve notifications blankpage --- src/pages/NotificationsPage/NotificationsPage.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pages/NotificationsPage/NotificationsPage.tsx b/src/pages/NotificationsPage/NotificationsPage.tsx index d162eff..3c39ba3 100644 --- a/src/pages/NotificationsPage/NotificationsPage.tsx +++ b/src/pages/NotificationsPage/NotificationsPage.tsx @@ -2,11 +2,12 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import { Typography } from '@material-ui/core'; -const useStyles = makeStyles({ +const useStyles = makeStyles(theme => ({ root: { + marginTop: theme.spacing(40), textAlign: 'center' } -}); +})); const NotificationsPage: React.FC = () => { const classes = useStyles(); -- cgit v1.2.3