aboutsummaryrefslogtreecommitdiff
path: root/src/components/Header/MobileHeader.tsx
blob: a20d54a7d500111cec38d51d95af8a41f752c80f (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
import React from 'react';
import {
  AppBar,
  Toolbar,
  useScrollTrigger,
  Slide
} from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';

interface PropTypes {
  menu: JSX.Element;
  logo: JSX.Element;
  search: JSX.Element;
}

const useStyles = makeStyles({
  root: {
    display: 'flex',
    justifyContent: 'space-between'
  }
});


const MobileHeader: React.FC<PropTypes> = React.memo(props => {
  const classes = useStyles();
  const trigger = useScrollTrigger();
  const { menu, search, logo } = props;

  return (
    <Slide appear={false} direction="down" in={!trigger}>
      <AppBar position="fixed">
        <Toolbar className={classes.root}>
          {menu}
          {logo}
          {search}
        </Toolbar>
      </AppBar>
    </Slide>
  );
});

export default MobileHeader;