el.xwx.moe/components/Sidebar/index.tsx

76 lines
2.7 KiB
TypeScript
Raw Normal View History

2023-04-23 08:26:39 -05:00
// Copyright (C) 2022-present Daniel31x13 <daniel31x13@gmail.com>
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2023-03-22 18:11:54 -05:00
import useCollectionStore from "@/store/collections";
2023-02-18 21:32:02 -06:00
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faFolder,
2023-03-05 15:03:20 -06:00
faBox,
2023-03-10 13:25:33 -06:00
faHashtag,
2023-02-24 22:22:33 -06:00
faBookmark,
2023-02-18 21:32:02 -06:00
} from "@fortawesome/free-solid-svg-icons";
import SidebarItem from "./SidebarItem";
2023-03-22 18:11:54 -05:00
import useTagStore from "@/store/tags";
2023-03-05 15:03:20 -06:00
import Link from "next/link";
2023-02-08 17:58:55 -06:00
export default function () {
2023-04-24 16:30:40 -05:00
const { collections } = useCollectionStore();
2023-03-22 18:11:54 -05:00
const { tags } = useTagStore();
2023-02-08 17:58:55 -06:00
return (
2023-03-28 10:11:34 -05:00
<div className="fixed bg-gray-100 top-0 bottom-0 left-0 w-80 p-2 overflow-y-auto border-solid border-r-sky-100 border z-20">
2023-03-28 02:31:50 -05:00
<p className="p-2 text-sky-500 font-bold text-xl mb-5 leading-4">
Linkwarden
</p>
2023-02-18 21:32:02 -06:00
2023-03-28 02:31:50 -05:00
<Link href="/links">
2023-03-25 09:17:34 -05:00
<div className="hover:bg-gray-50 hover:outline outline-sky-100 outline-1 duration-100 text-sky-900 rounded-md my-1 p-2 cursor-pointer flex items-center gap-2">
2023-03-05 15:03:20 -06:00
<FontAwesomeIcon icon={faBookmark} className="w-4 text-sky-300" />
<p>All Links</p>
</div>
</Link>
2023-02-24 22:22:33 -06:00
2023-03-05 15:03:20 -06:00
<Link href="/collections">
2023-03-25 09:17:34 -05:00
<div className="hover:bg-gray-50 hover:outline outline-sky-100 outline-1 duration-100 text-sky-900 rounded-md my-1 p-2 cursor-pointer flex items-center gap-2">
2023-03-05 15:03:20 -06:00
<FontAwesomeIcon icon={faBox} className="w-4 text-sky-300" />
<p>All Collections</p>
</div>
</Link>
2023-04-24 16:30:40 -05:00
<div className="text-gray-500 mt-5">
2023-03-25 09:17:34 -05:00
<p className="text-sm p-2">Collections</p>
</div>
2023-02-18 21:32:02 -06:00
<div>
{collections.map((e, i) => {
2023-03-05 15:03:20 -06:00
return (
<SidebarItem
key={i}
text={e.name}
2023-03-22 22:06:15 -05:00
icon={<FontAwesomeIcon icon={faFolder} />}
2023-03-05 15:03:20 -06:00
path={`/collections/${e.id}`}
/>
);
})}
</div>
2023-04-24 16:30:40 -05:00
<div className="text-gray-500 mt-5">
2023-03-25 09:17:34 -05:00
<p className="text-sm p-2">Tags</p>
</div>
<div>
{tags.map((e, i) => {
2023-03-05 15:03:20 -06:00
return (
<SidebarItem
key={i}
text={e.name}
2023-03-22 22:06:15 -05:00
icon={<FontAwesomeIcon icon={faHashtag} />}
2023-03-05 15:03:20 -06:00
path={`/tags/${e.id}`}
/>
);
2023-02-18 21:32:02 -06:00
})}
</div>
2023-02-08 17:58:55 -06:00
</div>
);
}