From 6a216b903899d1481f93ebff40e246f60c4c3e89 Mon Sep 17 00:00:00 2001 From: eug-vs 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(-) 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 = ({ initialPoll }) => { const dominant: Which = left.votes >= right.votes ? 'left' : 'right'; return ( - +
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([]); const { isAuthenticated } = useAuth(); - const classes = useStyles(); useEffect(() => { get('/feed').then(response => { @@ -33,10 +24,10 @@ const FeedPage: React.FC = () => { }; return ( -
+ {isAuthenticated() && } -
+ ); }; 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 = ({ addPoll }) => { return ( - + {user && } -
+
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 = ({ url, setUrl }) => { const Upload = ( <> - Upload an image + Upload an image ); 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(); const [polls, setPolls] = useState([]); const [totalVotes, setTotalVotes] = useState(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 ( -
+ { totalVotes={totalVotes} /> -
+ ); }; -- cgit v1.2.3