diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-07-04 00:12:42 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-04 00:12:42 +0300 |
commit | ed0117c9c7a60b285eb8e47bbd925e222184df51 (patch) | |
tree | b97f00e24f7ef10db191954588534f59644fdabc /src/pages | |
parent | af51f6c8a6fabdd8e578e13599b33f121f483a52 (diff) | |
parent | 7b698a68cb3d332aecfebf7a85b2ac56f9448bea (diff) | |
download | which-ui-ed0117c9c7a60b285eb8e47bbd925e222184df51.tar.gz |
Merge pull request #61 from which-ecosystem/mobile-adaptation
Adapt application for mobile devices
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/FeedPage/FeedPage.tsx | 15 | ||||
-rw-r--r-- | src/pages/FeedPage/PollSubmission.tsx | 7 | ||||
-rw-r--r-- | src/pages/FeedPage/PollSubmissionImage.tsx | 5 | ||||
-rw-r--r-- | src/pages/HomePage/HomePage.tsx | 128 | ||||
-rw-r--r-- | src/pages/NotificationsPage/NotificationsPage.tsx | 5 | ||||
-rw-r--r-- | src/pages/Page.tsx | 16 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 14 |
7 files changed, 98 insertions, 92 deletions
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..347eecc 100644 --- a/src/pages/FeedPage/PollSubmission.tsx +++ b/src/pages/FeedPage/PollSubmission.tsx @@ -21,6 +21,9 @@ interface PropTypes{ const useStyles = makeStyles(theme => ({ root: { + marginBottom: theme.spacing(4) + }, + images: { height: theme.spacing(50), 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/HomePage/HomePage.tsx b/src/pages/HomePage/HomePage.tsx index 8995630..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={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={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> ); }; 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(); diff --git a/src/pages/Page.tsx b/src/pages/Page.tsx index 24487f3..56d7372 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 { makeStyles, useTheme } from '@material-ui/core/styles'; +import { useMediaQuery } from '@material-ui/core'; import { SnackbarProvider } from 'notistack'; + import ProfilePage from './ProfilePage/ProfilePage'; import FeedPage from './FeedPage/FeedPage'; import AuthPage from './AuthPage/AuthPage'; @@ -8,21 +10,29 @@ 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) + [theme.breakpoints.down('sm')]: { + margin: theme.spacing(2, 0, 12, 0) + }, + [theme.breakpoints.up('md')]: { + margin: theme.spacing(15, 5, 8, 5) + } } })); 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' }} > diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 4710ae8..b7a4a75 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" disableGutters> <ProfileInfo userInfo={userInfo} setUserInfo={setUserInfo} @@ -52,7 +44,7 @@ const ProfilePage: React.FC = () => { totalVotes={totalVotes} /> <Feed polls={[...polls]} /> - </div> + </Container> ); }; |