import "./tailwind.css";
import "@fontsource/pixelify-sans";
import "@fontsource/outfit/400.css";
import "@fontsource/outfit/500.css";
import "@fontsource/russo-one";
import "overlayscrollbars/overlayscrollbars.css";
import { useState, useEffect } from "react";
import { usePageContext } from "vike-react/usePageContext";
import { IconBrandGithub, IconDownload, IconDeviceGamepad3, IconTrophy } from "@tabler/icons-react";
import { OverlayScrollbarsComponent } from "overlayscrollbars-react";
import { usePendingNavigation } from "@/lib/navigation";
function ClientOnlyScrollbars({ children, className }: { children: React.ReactNode; className?: string }) {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) {
return
{children}
;
}
return (
{children}
);
}
const links = [
{
label: "Play",
href: "/",
icon: ,
},
{
label: "Leaderboard",
href: "/leaderboard",
icon: ,
},
{
label: "Download",
href: "/download",
icon: ,
},
{
label: "GitHub",
href: "https://github.com/Xevion/Pac-Man",
icon: ,
},
];
export function Link({ href, label, icon }: { href: string; label: string; icon?: React.ReactNode }) {
const pageContext = usePageContext();
const { urlPathname } = pageContext;
const pendingUrl = usePendingNavigation();
const effectiveUrl = pendingUrl ?? urlPathname;
const isActive = href === "/" ? effectiveUrl === href : effectiveUrl.startsWith(href);
return (
{icon}
{label}
);
}
export default function LayoutDefault({ children }: { children: React.ReactNode }) {
const [opened, setOpened] = useState(false);
const toggle = () => setOpened((v) => !v);
const close = () => setOpened(false);
const pageContext = usePageContext();
const { urlPathname } = pageContext;
const pendingUrl = usePendingNavigation();
const effectiveUrl = pendingUrl ?? urlPathname;
const isIndexPage = effectiveUrl === "/";
const sourceLinks = links
.filter((link) => !link.href.startsWith("/"))
.map((link) => (
{link.icon}
));
return (
{sourceLinks}
{children}
{opened && (
Navigation
{links.map((link) => (
))}
)}
);
}