2024-01-19 23:34:49 -06:00
|
|
|
import { isPWA } from "@/lib/client/utils";
|
2024-01-14 10:16:42 -06:00
|
|
|
import Link from "next/link";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
|
|
|
export default function MobileNavigationButton({
|
|
|
|
href,
|
|
|
|
icon,
|
|
|
|
}: {
|
|
|
|
href: string;
|
|
|
|
icon: string;
|
|
|
|
}) {
|
|
|
|
const router = useRouter();
|
|
|
|
const [active, setActive] = useState(false);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
setActive(href === router.asPath);
|
|
|
|
}, [router]);
|
|
|
|
|
|
|
|
return (
|
2024-01-19 23:34:49 -06:00
|
|
|
<Link
|
|
|
|
href={href}
|
|
|
|
className="w-full active:scale-[80%] duration-200 select-none"
|
|
|
|
draggable="false"
|
|
|
|
style={{ WebkitTouchCallout: "none" }}
|
|
|
|
onContextMenu={(e) => {
|
|
|
|
if (isPWA()) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
return false;
|
|
|
|
} else return null;
|
|
|
|
}}
|
|
|
|
>
|
2024-01-14 10:16:42 -06:00
|
|
|
<div
|
|
|
|
className={`py-2 cursor-pointer gap-2 w-full rounded-full capitalize flex items-center justify-center`}
|
|
|
|
>
|
|
|
|
<i
|
|
|
|
className={`${icon} text-primary text-3xl drop-shadow duration-200 rounded-full w-14 h-14 text-center pt-[0.65rem] ${
|
|
|
|
active || false ? "bg-primary/20" : ""
|
|
|
|
}`}
|
|
|
|
></i>
|
|
|
|
</div>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
}
|