Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add with-cloudinary example #43250

Merged
merged 15 commits into from Dec 2, 2022
Merged

Add with-cloudinary example #43250

merged 15 commits into from Dec 2, 2022

Conversation

Nutlope
Copy link
Contributor

@Nutlope Nutlope commented Nov 22, 2022

Added an image gallery example using Next.js and Cloudinary.

Edit: This is now ready to ship!

@ijjk ijjk added the examples Issue/PR related to examples label Nov 22, 2022
steven-tey
steven-tey previously approved these changes Dec 1, 2022
// This effect keeps track of the last viewed photo in tshe modal to keep the index page in sync when the user navigates back
if (lastViewedPhoto && !photoId) {
document
.querySelector(`#photo-${lastViewedPhoto}`)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is a querySelector the way we want to do this? Or could / should it be done using a ref?

Copy link
Contributor Author

@Nutlope Nutlope Dec 1, 2022

Choose a reason for hiding this comment

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

I paired with Sam/Ryan on this featured and I actually suggested using a ref but they recommended I do it with querySelector instead. Can't remember the reason why – perhaps speed? Cause otherwise, I'd have to attach a ref to each of the 300+ images on a page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You think I should explore using ref instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, could be a lot of refs floating around. 🤔 Just don't see query selecting often. Made me do a double take and ask. Perhaps @ijjk and @styfle have better ideas.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree – I'll add this to my list of improvements for early next week. Sound good?

So far I have:

  • Add infinite scrolling
  • Fix bottom photo navbar animations on very wide screens
  • Convert querySelector to ref

For now, I'd love to ship this since we're planning to send the email tomorrow morning.

Copy link
Member

Choose a reason for hiding this comment

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

querySelector seems really odd with react

Lets compare the perf with `ref

Co-authored-by: Michael Novotny <manovotny@gmail.com>
const results = await cloudinary.v2.search
.expression(`folder:${process.env.CLOUDINARY_FOLDER}/*`)
.sort_by('public_id', 'desc')
.max_results(400)
Copy link
Member

Choose a reason for hiding this comment

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

Weren't we gonna add the infinite scrolling handling to reduce the initial document size?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Planning on adding infinite scrolling + smoothing out some animations next week, but for now, I'd love to ship it since we're sending out an email tomorrow morning to all Next.js Conf attendees with the photo gallery. Lemme know if that sounds alright to you.

For context, we've kept folks waiting for too long since I was originally planning to send this out early last week and I've already told a couple folks that we were sending it tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to do in a follow-up 👍

@Nutlope Nutlope requested a review from ijjk December 1, 2022 23:28
@ijjk
Copy link
Member

ijjk commented Dec 2, 2022

Looks good to land, we can address mentioned tweaks in follow-ups!

@kodiakhq kodiakhq bot merged commit 57dc720 into canary Dec 2, 2022
@kodiakhq kodiakhq bot deleted the add-with-cloudinary branch December 2, 2022 04:05
<Image
src={`https://res.cloudinary.com/${
process.env.NEXT_PUBLIC_CLOUDINARY_CLOUD_NAME
}/image/upload/c_scale,${navigation ? 'w_1280' : 'w_1920'}/${
Copy link
Member

@styfle styfle Dec 2, 2022

Choose a reason for hiding this comment

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

This feels off because the 1280/1920 distinction is made twice. Once here in src and once for width.

I'm still thinking that with-cloudinary example should use the loaderFile to configure cloudinary and then you just pass src=${currentImage.public_id}.${currentImage.format} to each <Image>

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants