rsnext/examples/cms-buttercms/components/header-section.js
Steven 4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00

51 lines
1.4 KiB
JavaScript

import { useEffect, useState, useRef } from "react";
import Image from "next/image";
import MainMenu from "./main-menu/main-menu";
export default function HeaderSection({ mainMenu }) {
const [isNavbarSticky, setIsNavbarSticky] = useState(false);
const navbarAreaEl = useRef(null);
function fixNavBar() {
if (navbarAreaEl.current) {
setIsNavbarSticky(window.pageYOffset > navbarAreaEl.current.offsetTop);
}
}
useEffect(() => {
window.addEventListener("scroll", fixNavBar);
return () => {
window.removeEventListener("scroll", fixNavBar);
};
}, []);
return (
<header className="header">
<div
ref={navbarAreaEl}
className={`navbar-area ${isNavbarSticky ? "sticky" : ""}`}
>
<div className="container">
<div className="row align-items-center">
<div className="col-lg-12">
<nav className="navbar navbar-expand-lg">
<a className="navbar-brand" href="https://buttercms.com">
<Image
src="https://cdn.buttercms.com/PBral0NQGmmFzV0uG7Q6"
alt="Logo"
width={180}
height={45}
/>
</a>
<MainMenu mainMenuLinks={mainMenu} />
</nav>
</div>
</div>
</div>
</div>
</header>
);
}