Skip to content

Commit

Permalink
chore: image grid
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasGleiter committed May 7, 2024
1 parent e5a1594 commit 28fb8e4
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 30 deletions.
7 changes: 0 additions & 7 deletions src/app/(landing)/(content)/layout.tsx

This file was deleted.

23 changes: 0 additions & 23 deletions src/app/(landing)/(content)/page.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions src/app/(lang)/(image)/p/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function ImageDetailsPage() {
return <div>ImageDetailsPage</div>;
}
File renamed without changes.
46 changes: 46 additions & 0 deletions src/app/(lang)/(landing)/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import test from '@/public/test.png';
import Image from 'next/image';
import Link from 'next/link';

export default async function Home() {
const images = [
{ id: 1, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
{ id: 2, public_id: test, format: 'png', blurDataUrl: 'https://test.com/' },
];

return (
<main className="mx-auto max-w-[1960px] p-4">
<div className="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4 gap-4">
{images.map(({ id, public_id, blurDataUrl }) => (
<Link
key={id}
href={`/?photoId=${id}`}
as={`/p/${id}`}
shallow
className="after:content group relative block w-full cursor-zoom-in after:pointer-events-none after:absolute after:inset-0 after:rounded-lg after:shadow-highlight"
>
<Image
src={public_id}
alt="Next.js Conf photo"
className="transform rounded-md brightness-90 transition will-change-auto group-hover:brightness-110"
style={{ transform: 'translate3d(0, 0, 0)' }}
placeholder="blur"
blurDataURL={blurDataUrl}
width={720}
height={480}
sizes="(max-width: 640px) 100vw,
(max-width: 1280px) 50vw,
(max-width: 1536px) 33vw,
25vw"
/>
</Link>
))}
</div>
</main>
);
}
8 changes: 8 additions & 0 deletions src/utils/useLastViewedPhoto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createGlobalState } from 'react-hooks-global-state';

const initialState = { photoToScrollTo: null };
const { useGlobalState } = createGlobalState(initialState);

export const useLastViewedPhoto = () => {
return useGlobalState('photoToScrollTo');
};

0 comments on commit 28fb8e4

Please sign in to comment.