blob: 335fcba63a2f45bace45a39aa11823b1f2c9835f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import React from 'react';
import { useHistory } from 'react-router-dom'
import {
Fab as FabBase,
useMediaQuery,
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: 1200,
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;
|