-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* photo-gallery error: - error Error: Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead. * Fix calvin's bug * photo gallery using cloudinary no feature to switch between qtrs yet * implemented photo gallery! --------- Co-authored-by: Calvin Nguyen <can005@ucsd.edu>
- Loading branch information
1 parent
065fa3f
commit fb2c234
Showing
55 changed files
with
320 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = {} | ||
const nextConfig = { | ||
experimental: { | ||
serverActions: true, | ||
}, | ||
images: { | ||
domains: ['res.cloudinary.com'], | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,4 +49,11 @@ | |
margin-bottom: 1rem; | ||
font-weight: 500; | ||
} | ||
} | ||
|
||
.picContainer { | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Image from "next/image"; | ||
import type { RenderPhotoProps } from "react-photo-album"; | ||
import { CldImage } from 'next-cloudinary'; | ||
import s from "./style.module.scss" | ||
|
||
export default function NextJsImage({ | ||
photo, | ||
imageProps: { alt, title, sizes, className, onClick }, | ||
wrapperStyle, | ||
}: RenderPhotoProps) { | ||
return ( | ||
<div style={{ ...wrapperStyle, position: "relative" }}> | ||
<CldImage | ||
fill | ||
src={photo.src} | ||
className={s.image} | ||
placeholder={"blurDataURL" in photo ? "blur" : undefined} | ||
{...{ alt, title, sizes, onClick }} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
"use client"; | ||
|
||
import React, { useState, useEffect } from "react"; | ||
import s from "./style.module.scss"; | ||
import PhotoAlbum from "react-photo-album"; | ||
import NextJsImage from "./NextJsImage"; | ||
|
||
const qtr_yr = [ | ||
{value:"wtr_23", text: "Winter 2023", length: 16}, | ||
{value: "spr_23", text: "Spring 2023", length: 24, vertical:[7, 24, 22]}, | ||
// {value: "sum_23", text: "Summer 2023", length: 1} | ||
] | ||
|
||
const breakpoints = [1080, 640, 384, 256, 128, 96, 64, 48]; | ||
|
||
type Photo = { | ||
src: string; | ||
width: number; | ||
height: number; | ||
srcSet: { | ||
src: string; | ||
width: number; | ||
height: number; | ||
}[]; | ||
}; | ||
|
||
const options = qtr_yr.map((option, index) => { | ||
return <option value={option.value} key={index}>{option.text}</option> | ||
}) | ||
|
||
const PhotoGallery: React.FC = () => { | ||
const [selectedOption, setSelectedOption] = useState(qtr_yr[0].value); | ||
|
||
const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => { | ||
setSelectedOption(e.target.value); | ||
} | ||
const [photos, setPhotos] = useState<Photo[]>([]); | ||
|
||
useEffect(() => { | ||
const rawPhotos = []; | ||
//here i am trying to read the dimensions of the image from cloudinary, but doesn't work | ||
// const cloudinary = require('cloudinary').v2; | ||
// cloudinary.config({ | ||
// cloud_name: 'dgnecfapo', | ||
// api_key: '', | ||
// api_secret: '' | ||
// }); | ||
const selectedQtrYr = qtr_yr.find(q => q.value === selectedOption); | ||
const numPhotos = selectedQtrYr?.length ?? 0; | ||
const indexVertical = selectedQtrYr?.vertical ?? []; | ||
for (let i = 1; i <= numPhotos; i++) { | ||
const newPhoto = {src: `${selectedOption}_showcase_${i}.jpg`, width:4032, height:3024}; | ||
if (indexVertical.includes(i)) { | ||
newPhoto.width = 4000; | ||
newPhoto.height = 6000; | ||
} | ||
// trying to dynamically read the images from cloudinary | ||
// cloudinary.uploader.explicit(newPhoto.src, {type: 'fetch'}, function(error: string, result: any) { | ||
// newPhoto.width = result.width; | ||
// newPhoto.height = result.height; | ||
// }); | ||
rawPhotos.push(newPhoto); | ||
} | ||
|
||
const updatedPhotos = rawPhotos.map((photo) => ({ | ||
src: photo.src, | ||
width: photo.width, | ||
height: photo.height, | ||
srcSet: breakpoints.map((breakpoint) => { | ||
const height = Math.round((photo.height / photo.width) * breakpoint); | ||
return { | ||
src: photo.src, | ||
width: breakpoint, | ||
height, | ||
}; | ||
}), | ||
})); | ||
|
||
setPhotos(updatedPhotos); | ||
}, [selectedOption]); | ||
|
||
return ( | ||
<> | ||
<div className={s.container}> | ||
<h1>Photo Gallery</h1> | ||
<select name="project_select" onChange={handleChange}> | ||
{options} | ||
</select> | ||
</div> | ||
<PhotoAlbum | ||
photos={photos} | ||
layout="rows" | ||
renderPhoto={NextJsImage} | ||
sizes={{ | ||
size: "calc(90vw - 100px)", | ||
sizes: [ | ||
{ viewport: "(max-width: 299px)", size: "calc(90vw - 10px)" }, | ||
{ viewport: "(max-width: 599px)", size: "calc(90vw - 20px)" }, | ||
{ viewport: "(max-width: 1199px)", size: "calc(90vw - 30px)" }, | ||
], | ||
}} | ||
/> | ||
</> | ||
); | ||
} | ||
|
||
export default PhotoGallery; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
@use "/src/styles/vars.scss" as vars; // allows you to use pre-defined color | ||
@use "/src/styles/vars.scss" as vars; // allows you to use pre-defined color | ||
|
||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
select { | ||
border-radius: 0.25rem; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
h1 { | ||
color: vars.$blue-dark; | ||
} | ||
} | ||
|
||
.image { | ||
border-radius: 0.5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.