File size: 1,091 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import React, { useRef, useState } from "react";
import Footer from "./Footer/Footer";
import SideBar from "./SideBar";
import Body from "./Body";
import NavBar from "./NavBar";
import { Container } from "./style";

function Dashboad() {
  const [headerBackground, setHeaderBackground] = useState(false);
  const [navBackground, setNavBackground] = useState(false);
  const bodyRef = useRef();
  const bodyScrolled = () => {
    bodyRef.current.scrollTop >= 30
      ? setNavBackground(true)
      : setNavBackground(false);
    bodyRef.current.scrollTop >= 268
      ? setHeaderBackground(true)
      : setHeaderBackground(false);
  };

  return (
    <Container>
      <div className="dash_body">
        <SideBar />
        <div className="body" ref={bodyRef} onScroll={bodyScrolled}>
          <NavBar navBackground={navBackground} />
          <div className="contents">
            <Body headerBackground={headerBackground} />
          </div>
        </div>
      </div>
      <div className="footer">
        <Footer />
      </div>
    </Container>
  );
}

export default Dashboad;