MCPcopy Create free account
hub / github.com/api-platform/website / MobileSideBar

Function MobileSideBar

pwa/components/docs/MobileSidebar.tsx:11–136  ·  view source on GitHub ↗
({
  docMenuParts,
}: {
  docMenuParts: NavPartProps[];
})

Source from the content-addressed store, hash-verified

9import DocMenu, { NavPartProps } from "./DocMenu";
10
11export default function MobileSideBar({
12 docMenuParts,
13}: {
14 docMenuParts: NavPartProps[];
15}) {
16 const [isOpen, setOpen] = useState(false);
17 const { breadCrumbs } = useContext(DocContext);
18 const pathname = usePathname();
19
20 const menu = useRef<HTMLDivElement>(null);
21
22 useOnClickOutside(menu, () => setOpen(false));
23
24 useEffect(() => {
25 setOpen(false);
26 }, [pathname]);
27
28 useEffect(() => {
29 if (isOpen) document.body.style.overflow = "hidden";
30 else document.body.style.overflow = "auto";
31 }, [isOpen]);
32
33 return (
34 <div
35 className={classNames(
36 "sticky max-w-8xl px-6 top-16 w-full h-12 bg-white dark:bg-blue-black flex flex-row items-center border-b-px border-gray-300 dark:border-blue-dark text-blue | md:hidden",
37 isOpen ? "z-50" : "z-40"
38 )}
39 >
40 <button onClick={() => setOpen(true)}>
41 <svg
42 xmlns="http://www.w3.org/2000/svg"
43 fill="none"
44 viewBox="0 0 24 24"
45 strokeWidth={1.5}
46 className="w-6 h-6 stroke-current"
47 >
48 <path
49 strokeLinecap="round"
50 strokeLinejoin="round"
51 d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5"
52 />
53 </svg>
54 </button>
55 <div className="pl-4 flex flex-row gap-1 items-center justify-center leading-none text-sm font-light text-text-secondary dark:text-white/70">
56 {breadCrumbs.map((docLink, index) => (
57 <Fragment key={docLink.title}>
58 {docLink.link ? (
59 <Link
60 className="transition-all hover:text-blue text-ellipsis whitespace-nowrap overflow-hidden"
61 href={docLink.link}
62 prefetch={false}
63 >
64 {docLink.title}
65 </Link>
66 ) : (
67 <span
68 className={`${

Callers

nothing calls this directly

Calls 1

useOnClickOutsideFunction · 0.85

Tested by

no test coverage detected