Skip to content

Commit

Permalink
Create masonry layout
Browse files Browse the repository at this point in the history
  • Loading branch information
agarun committed May 11, 2024
1 parent 1722f22 commit 6c36697
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Binary file added src/app/favicon.ico
Binary file not shown.
39 changes: 39 additions & 0 deletions src/lib/masonry.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client';

import * as React from 'react';
import { Masonry as MasonicMasonry } from 'masonic';
import { useLightbox } from '../hooks/use-lightbox';

const MasonryItem = ({ index, data: { url, width, height } }) => (
<a
href={url}
className="scale-in"
data-pswp-width={width}
data-pswp-height={height}
target="_blank"
rel="noreferrer"
>
<img src={url} />
</a>
);

export const Masonry = ({ items = [], ...props }) => {
useLightbox(items);

if (items.length === 0) {
return null;
}

return (
<section id="gallery" className="max-w-[800px]">
<MasonicMasonry
items={items}
render={MasonryItem}
columnGutter={18}
columnWidth={240}
overscanBy={2}
{...props}
/>
</section>
);
};

0 comments on commit 6c36697

Please sign in to comment.