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

Enhance sizes documentation for next/image #39301

Merged
merged 9 commits into from Aug 9, 2022

Conversation

atcastle
Copy link
Collaborator

@atcastle atcastle commented Aug 3, 2022

This PR updates the documentation for the sizes proper in next/image to make it more clear what this prop does and why it's (very) important to use it. After feedback, I'll update this PR to also modify the future image component docs.

@ijjk ijjk added area: documentation created-by: Chrome Aurora PRs by the Google Chrome team: https://web.dev/aurora labels Aug 3, 2022

const MyImage = (props) => {
return (
<Image
Copy link
Member

@styfle styfle Aug 3, 2022

Choose a reason for hiding this comment

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

Since you're using layout="fill", should there be a parent div with position: relative? Perhaps we should use layout="responsive" instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took out some of the example code and added a // ... because I think it would take too many lines to make the example illustrate a realistic 3 column layout. The important part is the <Image> element, anyway.

atcastle and others added 4 commits August 3, 2022 14:32
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Steven <steven@ceriously.com>
import Image from 'next/future/image'
// ...

;<Image
Copy link
Member

Choose a reason for hiding this comment

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

Let's wrap this in a component so it's easily copy/pastable? Will also fix the ; issue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a <div className="grid-element"> wrapper, to give some context as to how to interpret this code snippet. To actually use the code you would need an additional grid container, and some flexbox styling, etc, which I'm afraid would make the snippet sort of unwieldy and take focus away from the sizes example value. Let me know if you think this new version works

styfle
styfle previously approved these changes Aug 9, 2022
Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

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

Thanks!

@styfle styfle requested a review from leerob August 9, 2022 19:03
styfle
styfle previously approved these changes Aug 9, 2022
@kodiakhq kodiakhq bot merged commit b2d93e8 into vercel:canary Aug 9, 2022

```js
import Image from 'next/image'
;<div className="grid-element">
Copy link
Member

Choose a reason for hiding this comment

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

Should we revert or fix this forward? The semicolon and broken formatting will go live (we're currently pointing docs at canary, maybe we need to flip that back).

Copy link
Member

Choose a reason for hiding this comment

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

This was updated in e2119c0

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
created-by: Chrome Aurora PRs by the Google Chrome team: https://web.dev/aurora
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants