diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Feed/Feed.tsx | 2 | ||||
-rw-r--r-- | src/components/Header/Header.tsx | 88 | ||||
-rw-r--r-- | src/components/PollCard/PollCard.tsx | 10 | ||||
-rw-r--r-- | src/components/ScrollTopArrow/ScrollTopArrow.tsx | 43 |
4 files changed, 92 insertions, 51 deletions
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} diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index 294c250..41aeec7 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -3,9 +3,11 @@ 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'; @@ -14,27 +16,36 @@ import { useNavigate } from '../../hooks/useNavigate'; 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 + round: { + width: theme.spacing(3), + height: theme.spacing(3) } -}); +})); 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'); @@ -53,31 +64,58 @@ 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.round} 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} ${classes.round}`}>W</Typography> + </IconButton> + {FeedButton} + {NotificationsButton} + {ProfileButton} + </Toolbar> + </AppBar> + ); + + return isMobile ? MobileVersion : BrowserVersion; }; export default Header; diff --git a/src/components/PollCard/PollCard.tsx b/src/components/PollCard/PollCard.tsx index f5a5762..98ae001 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 + height: theme.spacing(50) }, 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/components/ScrollTopArrow/ScrollTopArrow.tsx b/src/components/ScrollTopArrow/ScrollTopArrow.tsx index 6b9d5c9..08b8591 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,13 @@ 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> ); }; |