el.xwx.moe/components/MobileNavigation.tsx

98 lines
3.4 KiB
TypeScript
Raw Normal View History

2024-04-25 22:56:36 -05:00
import { dropdownTriggerer, isIphone, isPWA } from "@/lib/client/utils";
2024-01-14 10:16:42 -06:00
import React from "react";
2024-01-19 23:34:49 -06:00
import { useState } from "react";
2024-01-14 10:16:42 -06:00
import NewLinkModal from "./ModalContent/NewLinkModal";
import NewCollectionModal from "./ModalContent/NewCollectionModal";
import UploadFileModal from "./ModalContent/UploadFileModal";
import MobileNavigationButton from "./MobileNavigationButton";
2024-06-09 08:27:16 -05:00
import { useTranslation } from "next-i18next";
2024-01-14 10:16:42 -06:00
type Props = {};
export default function MobileNavigation({ }: Props) {
2024-06-09 08:27:16 -05:00
const { t } = useTranslation();
2024-01-14 10:16:42 -06:00
const [newLinkModal, setNewLinkModal] = useState(false);
const [newCollectionModal, setNewCollectionModal] = useState(false);
const [uploadFileModal, setUploadFileModal] = useState(false);
return (
<>
<div
2024-01-19 23:34:49 -06:00
className={`fixed bottom-0 left-0 right-0 z-30 duration-200 sm:hidden`}
2024-01-14 10:16:42 -06:00
>
2024-01-19 23:34:49 -06:00
<div
className={`w-full flex bg-base-100 ${isIphone() && isPWA() ? "pb-5" : ""
} border-solid border-t-neutral-content border-t`}
2024-01-19 23:34:49 -06:00
>
<MobileNavigationButton href={`/dashboard`} icon={"bi-house"} />
<MobileNavigationButton
href={`/links/pinned`}
icon={"bi-pin-angle"}
/>
<div className="dropdown dropdown-top -mt-4">
<div
tabIndex={0}
role="button"
onMouseDown={dropdownTriggerer}
className={`flex items-center btn btn-accent dark:border-violet-400 text-white btn-circle w-20 h-20 px-2 relative`}
>
<span>
<i className="bi-plus text-5xl pointer-events-none"></i>
</span>
</div>
<ul className="dropdown-content z-[1] menu shadow bg-base-200 border border-neutral-content rounded-box w-40 mb-1 -ml-12">
<li>
<div
onClick={() => {
(document?.activeElement as HTMLElement)?.blur();
setNewLinkModal(true);
}}
tabIndex={0}
role="button"
>
2024-06-09 08:27:16 -05:00
{t("new_link")}
</div>
</li>
<li>
<div
onClick={() => {
(document?.activeElement as HTMLElement)?.blur();
setUploadFileModal(true);
}}
tabIndex={0}
role="button"
>
{t("upload_file")}
2024-01-19 23:34:49 -06:00
</div>
</li>
<li>
<div
onClick={() => {
(document?.activeElement as HTMLElement)?.blur();
setNewCollectionModal(true);
}}
tabIndex={0}
role="button"
>
2024-06-09 08:27:16 -05:00
{t("new_collection")}
2024-01-19 23:34:49 -06:00
</div>
</li>
</ul>
</div>
2024-01-14 10:16:42 -06:00
<MobileNavigationButton href={`/links`} icon={"bi-link-45deg"} />
<MobileNavigationButton href={`/collections`} icon={"bi-folder"} />
</div>
</div>
{newLinkModal && (
2024-01-14 10:16:42 -06:00
<NewLinkModal onClose={() => setNewLinkModal(false)} />
)}
{newCollectionModal && (
2024-01-14 10:16:42 -06:00
<NewCollectionModal onClose={() => setNewCollectionModal(false)} />
)}
{uploadFileModal && (
2024-01-14 10:16:42 -06:00
<UploadFileModal onClose={() => setUploadFileModal(false)} />
)}
2024-01-14 10:16:42 -06:00
</>
);
}