el.xwx.moe/components/LinkViews/Layouts/MasonryView.tsx

44 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-04-23 20:48:15 -05:00
import LinkCard from "@/components/LinkViews/LinkCard";
import { LinkIncludingShortenedCollectionAndTags } from "@/types/global";
import { GridLoader } from "react-spinners";
2024-04-23 20:53:33 -05:00
import Masonry from "react-masonry-css";
2024-04-23 20:48:15 -05:00
export default function MasonryView({
2024-04-23 20:53:33 -05:00
links,
editMode,
isLoading,
2024-04-23 20:48:15 -05:00
}: {
2024-04-23 20:53:33 -05:00
links: LinkIncludingShortenedCollectionAndTags[];
editMode?: boolean;
isLoading?: boolean;
2024-04-23 20:48:15 -05:00
}) {
2024-04-23 20:53:33 -05:00
return (
<Masonry
breakpointCols={4}
columnClassName="!w-full flex flex-col gap-5"
className="grid min-[1900px]:grid-cols-4 xl:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-5"
>
{links.map((e, i) => {
return (
<LinkCard
key={i}
link={e}
count={i}
flipDropdown={i === links.length - 1}
editMode={editMode}
/>
);
})}
2024-04-23 20:48:15 -05:00
2024-04-23 20:53:33 -05:00
{isLoading && links.length > 0 && (
<GridLoader
color="oklch(var(--p))"
loading={true}
size={20}
className="fixed top-5 right-5 opacity-50 z-30"
/>
)}
</Masonry>
);
2024-04-23 20:48:15 -05:00
}