I'm trying to make a Sticky Header that can change its background-color based on his position on the page. To do that, I'm trying to add a className "active" to my Styled Component "StyledHeader" that will appears when the scrollPositionY is above 400px and disappear when below.
In other words, what I want to do is something like this but using React.JS, JSX syntax and Styled Components.
Here's what I have for now:
import { Link } from '@reach/router';
import DuskLogo from '../images/dusk_logo.svg';
import {
StyledHeader,
StyledDuskLogo
} from '../styles/StyledHeader';
const Header = () => (
<StyledHeader>
<div className="header-content">
<Link to="/">
<StyledDuskLogo src={DuskLogo} alt="dusk-logo" />
</Link>
</div>
</StyledHeader>
)
export default Header;
Do you know a simple way to do it ?