GithubHelp home page GithubHelp logo

Comments (1)

eleventhaus avatar eleventhaus commented on June 29, 2024

Figured it out

Landing.jsx

function Landing() {
  const [transparent, setTransparent] = useState(true);

  useEffect(() => {
    window.addEventListener("scroll", navbarColorChange);
    return function cleanup() {
      window.removeEventListener("scroll", navbarColorChange);
    };
  });

  const navbarColorChange = () => {
    const windowsScrollTop = window.pageYOffset;
    if (windowsScrollTop > 100) {
      setTransparent(false);
    } else {
      setTransparent(true);
    }
  };

  return (
    <>
      <MKBox sx={{ position: "sticky", top: 0, zIndex: 10 }}>
        <Navbar
          routes={routes}
          action={{
            type: "external",
            route: "/signup",
            label: "sign up",
            color: "warning",
          }}
          sticky
          transparent={transparent}
        />
      </MKBox>

Navbar.jsx

function Navbar({ brand, routes, transparent, light, action, sticky, relative, center }) {
  return (
      <>
        <MKBox
          py={{ xs: 1, sm: 2 }}
          px={{ xs: 4, sm: transparent ? 3 : 3, lg: transparent ? 6 : 6 }}
          my={relative ? 0 : 2}
          mx={relative ? 0 : 3}
          width={relative ? "100%" : "calc(100% - 48px)"}
          borderRadius="xl"
          shadow={transparent ? "none" : "md"}
          color={light ? "white" : "dark"}
          position={relative ? "relative" : "absolute"}
          left={0}
          zIndex={3}
          sx={({ palette: { transparent: transparentColor, white }, functions: { rgba } }) => ({
            backgroundColor: transparent ? transparentColor.main : rgba(white.main, 0.8),
            backdropFilter: transparent ? "none" : `saturate(200%) blur(6px)`,
          })}
        >
        </MKBox>
    </>
  );
}

from ct-material-kit-pro-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.