diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-08-13 17:27:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-13 17:27:32 +0300 |
commit | d1e0dcd8538a61184eca50fbf7769c6d2943ff6b (patch) | |
tree | 9c2ba42d34e469d292fc1fe807e3f814a872a69e /src/components/Fab | |
parent | 2dc5fc00347256982136deea98d483c444002595 (diff) | |
parent | 52799ec4e4cd5801423ee0d2aa56039c061afdb4 (diff) | |
download | which-ui-d1e0dcd8538a61184eca50fbf7769c6d2943ff6b.tar.gz |
Merge pull request #78 from which-ecosystem/redesign
Move PollSubmission to separate page and add FAB
Diffstat (limited to 'src/components/Fab')
-rw-r--r-- | src/components/Fab/Fab.tsx | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/components/Fab/Fab.tsx b/src/components/Fab/Fab.tsx new file mode 100644 index 0000000..7ca2893 --- /dev/null +++ b/src/components/Fab/Fab.tsx @@ -0,0 +1,50 @@ +import React from 'react'; +import { useHistory } from 'react-router-dom'; +import { Fab as FabBase, Slide, useScrollTrigger } from '@material-ui/core/'; +import { makeStyles } from '@material-ui/core/styles'; +import PlusIcon from '@material-ui/icons/Add'; + +interface PropTypes { + hideOnScroll?: boolean; +} + +const useStyles = makeStyles(theme => ({ + root: { + zIndex: 1000, + position: 'fixed', + + [theme.breakpoints.down('sm')]: { + right: theme.spacing(2), + bottom: theme.spacing(8) + }, + [theme.breakpoints.up('md')]: { + right: theme.spacing(5), + bottom: theme.spacing(5) + } + } +})); + +const Fab: React.FC<PropTypes> = ({ hideOnScroll = false }) => { + const classes = useStyles(); + const history = useHistory(); + const trigger = useScrollTrigger(); + + const handleClick = () => { + history.push('/new'); + }; + + return ( + <Slide appear={false} direction="up" in={(!hideOnScroll) || !trigger}> + <FabBase + onClick={handleClick} + className={classes.root} + color="secondary" + > + <PlusIcon /> + </FabBase> + </Slide> + ); +}; + +export default Fab; + |