From c73a0d7643ac335dbcdc64b90467ba7d3a45c4f4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Oct 2020 15:10:15 +0300 Subject: feat: add dashed borders to ImageInput --- src/containers/PollCreation/ImageInput.tsx | 46 +++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'src/containers/PollCreation') diff --git a/src/containers/PollCreation/ImageInput.tsx b/src/containers/PollCreation/ImageInput.tsx index e807865..181294e 100644 --- a/src/containers/PollCreation/ImageInput.tsx +++ b/src/containers/PollCreation/ImageInput.tsx @@ -17,13 +17,33 @@ interface PropTypes { progress?: number; } -const useStyles = makeStyles({ +const useStyles = makeStyles(theme => ({ root: { + width: '50%', + display: 'flex' + }, + mediaRoot: { + display: 'flex' + }, + uploadRoot: { + flex: 1, + display: 'flex', + [theme.breakpoints.up('md')]: { + padding: theme.spacing(4) + }, + [theme.breakpoints.down('sm')]: { + padding: theme.spacing(8, 1) + } + }, + outline: { + padding: theme.spacing(2), + flex: 1, + border: '2px dashed gray', + borderRadius: theme.spacing(1), display: 'flex', justifyContent: 'center', flexDirection: 'column', - alignItems: 'center', - width: '50%' + alignItems: 'center' }, clearIcon: { opacity: '.5', @@ -48,7 +68,7 @@ const useStyles = makeStyles({ icon: { color: 'white' } -}); +})); const ImageInput: React.FC = ({ callback, progress }) => { @@ -69,15 +89,17 @@ const ImageInput: React.FC = ({ callback, progress }) => { }; const Upload = ( -
- - or - +
+
+ + or + +
); const Media = ( - +
{ @@ -91,7 +113,11 @@ const ImageInput: React.FC = ({ callback, progress }) => { ); - return url ? Media : Upload; + return ( +
+ {url ? Media : Upload} +
+ ); }; export default ImageInput; -- cgit v1.2.3 From 3cbf292b6d4976589428d0841cd1201057d104d4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Oct 2020 15:51:19 +0300 Subject: feat: use icon in header instead of submit button --- src/containers/PollCreation/PollCreation.tsx | 29 +++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'src/containers/PollCreation') diff --git a/src/containers/PollCreation/PollCreation.tsx b/src/containers/PollCreation/PollCreation.tsx index b7ee00a..18c3c6b 100644 --- a/src/containers/PollCreation/PollCreation.tsx +++ b/src/containers/PollCreation/PollCreation.tsx @@ -3,11 +3,12 @@ import Bluebird from 'bluebird'; import { useHistory } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; import { - Button, + IconButton, Card, Container, LinearProgress } from '@material-ui/core'; +import SendIcon from '@material-ui/icons/Send'; import { useSnackbar } from 'notistack'; import useS3Preupload from './useS3Preupload'; @@ -46,7 +47,7 @@ const PollCreation: React.FC = () => { progress: rightProgress } = useS3Preupload(); - const handleClick = async () => { + const handleSubmit = async () => { try { const [leftUrl, rightUrl] = await Bluebird.all([resolveLeft(), resolveRight()]); @@ -67,8 +68,14 @@ const PollCreation: React.FC = () => { } }; + const submitIcon = ( + + + + ); + return ( - + {user && } @@ -76,21 +83,7 @@ const PollCreation: React.FC = () => {
- { - leftProgress || rightProgress - ? - : ( - - ) - } + {(leftProgress > 0 || rightProgress > 0) && } -- cgit v1.2.3 From fd7e4817cd0e0160e85ad98ad81f406c66a94800 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Oct 2020 20:21:35 +0300 Subject: feat: correctly wire modal logic --- src/containers/PollCreation/PollCreation.tsx | 41 ++++++++++++++-------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/containers/PollCreation') diff --git a/src/containers/PollCreation/PollCreation.tsx b/src/containers/PollCreation/PollCreation.tsx index 18c3c6b..68f41d2 100644 --- a/src/containers/PollCreation/PollCreation.tsx +++ b/src/containers/PollCreation/PollCreation.tsx @@ -1,22 +1,17 @@ import React from 'react'; import Bluebird from 'bluebird'; -import { useHistory } from 'react-router-dom'; import { makeStyles } from '@material-ui/core/styles'; -import { - IconButton, - Card, - Container, - LinearProgress -} from '@material-ui/core'; +import { Card, Container, LinearProgress } from '@material-ui/core'; import SendIcon from '@material-ui/icons/Send'; import { useSnackbar } from 'notistack'; import useS3Preupload from './useS3Preupload'; import ImageInput from './ImageInput'; import ModalScreen from '../../components/ModalScreen/ModalScreen'; +import Message from '../../components/Message/Message'; import UserStrip from '../../components/UserStrip/UserStrip'; import { post } from '../../requests'; -import { useFeed } from '../../hooks/APIClient'; +import { useFeed, useProfile } from '../../hooks/APIClient'; import { useAuth } from '../../hooks/useAuth'; @@ -30,10 +25,10 @@ const useStyles = makeStyles(theme => ({ const PollCreation: React.FC = () => { const classes = useStyles(); - const history = useHistory(); const { user } = useAuth(); const { enqueueSnackbar } = useSnackbar(); const { mutate: updateFeed } = useFeed(); + const { mutate: updateProfile } = useProfile(user?.username || ''); const { file: left, setFile: setLeft, @@ -56,26 +51,23 @@ const PollCreation: React.FC = () => { right: { url: rightUrl } }; - history.push('/feed'); - post('/polls/', { contents }).then(() => { updateFeed(); + updateProfile(); enqueueSnackbar('Your poll has been successfully created!', { variant: 'success' }); }); } catch (error) { enqueueSnackbar('Failed to create a poll. Please, try again.', { variant: 'error' }); - history.push('/feed'); } }; - const submitIcon = ( - - - - ); - return ( - + } + handleAction={handleSubmit} + isActionDisabled={!(left && right) || leftProgress > 0 || rightProgress > 0} + > {user && } @@ -83,8 +75,17 @@ const PollCreation: React.FC = () => {
- {(leftProgress > 0 || rightProgress > 0) && } + {(leftProgress > 0 || rightProgress > 0) && ( + <> + + + + )} ); -- cgit v1.2.3