Skip to content

Commit

Permalink
lightbox and zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
FlapShatner committed May 3, 2023
1 parent 2b80a9d commit 07a3d90
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
4 changes: 0 additions & 4 deletions lib/socials.ts

This file was deleted.

15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"react-photo-album": "^2.1.0",
"sharp": "^0.32.1",
"tailwindcss": "3.3.2",
"typescript": "5.0.4"
"typescript": "5.0.4",
"yet-another-react-lightbox": "^3.5.3"
}
}
23 changes: 15 additions & 8 deletions pages/photography.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
import PhotoAlbum from "react-photo-album";
import NextJsImage from "@/components/nextJsImage";
import { photos } from "@/lib/photos";
import PhotoAlbum from 'react-photo-album'
import NextJsImage from '@/components/nextJsImage'
import Lightbox from 'yet-another-react-lightbox'
import Zoom from 'yet-another-react-lightbox/plugins/zoom'
import 'yet-another-react-lightbox/styles.css'
import { photos } from '@/lib/photos'
import { useState } from 'react'

const Photography = () => {
const [index, setIndex] = useState(-1)

// Breakpoints in px for the number of photos per row
const fourColumns = 1400
const threeColumns = 900
const twoColumns = 600

const rowConstraints = (w: number) => ({ maxPhotos: w > fourColumns ? 4 : w > threeColumns ? 3 : w > twoColumns ? 2 : 1 });
const rowConstraints = (w: number) => ({ maxPhotos: w > fourColumns ? 4 : w > threeColumns ? 3 : w > twoColumns ? 2 : 1 })

return (
<div className="w-full px-4">
<h1 className="text-center py-6 text-2xl">Photography</h1>
<div className='w-full px-4'>
<h1 className='text-center py-6 text-2xl'>Photography</h1>
<PhotoAlbum
photos={photos}
layout="rows"
layout='rows'
rowConstraints={rowConstraints}
renderPhoto={NextJsImage}
defaultContainerWidth={1200}
spacing={(containerWidth) => (containerWidth < 600 ? 5 : 10)}
onClick={({ index }) => setIndex(index)}
/>
<Lightbox slides={photos} open={index >= 0} close={() => setIndex(-1)} index={index} plugins={[Zoom]} />
</div>
)
}

export default Photography
export default Photography

1 comment on commit 07a3d90

@vercel
Copy link

@vercel vercel bot commented on 07a3d90 May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.