-
Notifications
You must be signed in to change notification settings - Fork 378
New Image component #649
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
New Image component #649
Conversation
This comment has been minimized.
This comment has been minimized.
|
I've moved this over from the old |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of going from Image to Image and ImageLegacy, I think it makes more sense to go from Image to Image and AlphaImage first.
So rollout would happen in 3 stages
- add the new
ImageasAlphaImage(in non-breaking release) - rename the
ImagetoLegacyImageand renameAlphaImagetoImage(in next major release) - remove
LegacyImage(following major release)
@benjaminsehl what do you think?
|
Taking this over from @benjaminsehl, I have some basic tests in and the build is passing, but going to give everything a second look and add a lot more tests as I go. |
lordofthecactus
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new component seems to break the demo-store.

Couple of questions:
- I see the style attribute is used which has quite a strong specificity. The demo store broke so I'm thinking there might be a strong assumption here that these styles can apply broadly. How as it decided that this was to be included by default?
- I see it generates a large srcset. Is this the best practice when using cdn? how was this decided and are there any implications?
WHY are these changes introduced?
Improve developer ergonomics for working with the Image component and ensure greater performance across devices and screen sizes by making responsive images a default and accounting for common lighthouse warnings.
WHAT is this pull request doing?
<Image />now supports all unit types, and a more natural set of APIs (better aligned with standard HTML) for both for responsive and fixed with images.Example markup:
Would result in:
Sometimes you will just want a fixed sized image — we still generate
srcsetfor this, however, as different devices have different pixel densities. We also account for the compound property common on all our other components,dataso you can simply pass the response from the Storefront API and set the width.So this:
Would result in:
Notice that even though we didn't pass in an aspectRatio prop, we were still able to generate a correct style property, by using
data.widthanddata.height.Todo:
Picture Element
In the future, this Image component would be able to be composed within a Picture component, which would look something like:
When inside the component
Imageshould render asourceelement, with the lastImagecomponent rendering aimgelement as the fallback. Ideally we'd somehow do that automatically — looking at the nodes of children, and then setting the as prop for you. Alternatively, our component could re-export the Image component but as a<Source />component — which would be in keeping with HTML semantics.HOW to test your changes?
Post-merge steps
Checklist