Skip to content

Integrate srcSet #693

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

Merged
merged 46 commits into from
May 15, 2020
Merged

Integrate srcSet #693

merged 46 commits into from
May 15, 2020

Conversation

aChanEP
Copy link
Contributor

@aChanEP aChanEP commented May 7, 2020

Description:

https://elasticpath.atlassian.net/secure/RapidBoard.jspa?rapidView=467&projectKey=RS&modal=detail&selectedIssue=RS-805&assignee=557058%3A2cdf4e37-eb83-44ee-9d76-d5409db1e998

The purpose of this PR is to implement dynamic images that will fetch the appropriate asset based on window width and browser compatibility. This PR will stop lighthouse from complaining about using next-gen formats and improper sizing for our images. lighthouse performance sees modest improvements and we are hitting the mid to high 50's.

ImageContainer component has been updated to utilize dynamic images enabled through the picture element. Take a look at the component README for more information.

Image assets for the Breville catalog have been sized appropriately for 3 sizing breakpoints: 0-768, 768 - 1092, 1092 - Infinity. Each sizing containing jpg, jp2, and webp formats which will cover a full range of browsers. The assets can be seen at this s3 bucket: https://s3.console.aws.amazon.com/s3/buckets/refstoreimgs/?region=us-west-2&tab=overview.

The demo-team will need to be notified of these assets changes as they are currently using pngs for their demo's.

A seperate project here for image processing:
https://github.com/aChanEP/nextGenImageCreation. We may want to use this as a starting point for a future asset pipeline if we deem it necessary.

// Processed images for bellevie dataset
"skuImagesUrl": "https://ep-demo-assets.s3-us-west-2.amazonaws.com/BELLEVIE/skuImages/%fileName%",
"siteImagesUrl": "https://ep-demo-assets.s3-us-west-2.amazonaws.com/BELLEVIE/siteImages/%fileName%",

TODO's:

  1. Still needing to debug multi-sku images. DONE
  2. Need to write up documentation on how to reskin. WIP

Linting:

  • No linting errors

Tests:

  • E2E tests (npm test run with e2e)
  • Manual tests

Documentation:

  • Requires documentation updates

aChanEP added 17 commits May 6, 2020 21:51
Integrate srcSet
Able to get srcSet working
change to use x instead of w
adjust sizings
clean up
Able to get the homepage to use srcSet
Able to get pdp to work with new image container
able to get appheader working
able to get image container working in productlistitem
uncomment all usages of image container
add styling
update ep.config.json
update mandatory alt tag for img element
More updates to alt element.  Include better descriptions for imaeg parameters
fix readme and make more descriptive parameter names
update config file
update README example
@aChanEP aChanEP changed the title [WIP] Integrate srcSet Integrate srcSet May 12, 2020
@shaunmaharaj
Copy link
Contributor

Please address conflicts & rebase

@@ -27,12 +25,12 @@
}
],
"defaultCurrencyValue": "CAD",
"skuImagesUrl": "https://elasticpath-demo-images.s3-us-west-2.amazonaws.com/VESTRI_VIRTUAL_V1/%sku%.png",
"siteImagesUrl": "https://elasticpath-demo-images.s3-us-west-2.amazonaws.com/VESTRI_VIRTUAL_V1/%fileName%",
"skuImagesUrl": "https://refstoreimgs.s3-us-west-2.amazonaws.com/productImages/%fileName%",
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a copy of the existing bucket's images?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes its a copy of existing buckets. resized and re-typed versions of the breville catalog within the reference store aws

"skuImagesUrl": "https://elasticpath-demo-images.s3-us-west-2.amazonaws.com/VESTRI_VIRTUAL_V1/%sku%.png",
"siteImagesUrl": "https://elasticpath-demo-images.s3-us-west-2.amazonaws.com/VESTRI_VIRTUAL_V1/%fileName%",
"skuImagesUrl": "https://refstoreimgs.s3-us-west-2.amazonaws.com/productImages/%fileName%",
"siteImagesUrl": "https://refstoreimgs.s3-us-west-2.amazonaws.com/siteImages/%fileName%",
Copy link
Contributor

Choose a reason for hiding this comment

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

Getting CORS errors on these images. Need to add a CORS config for the new bucket:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the url

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI I get cors issues even when switching back to elasticpath-demo-images

imgClassName="category-item-thumbnail img-responsive"
isSkuImage
fileName={productData._code[0].code}
imageFileTypes={['webp', 'jp2', 'jpg']}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we take the "imageFileTypes" from ep.config.json? We're duplicating this across components but it's a shared config and could be changed by an implementor.

Copy link
Contributor

@plundaahl-ep plundaahl-ep May 12, 2020

Choose a reason for hiding this comment

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

I would +1 this!

Would it be possible to make the imageFileTypes property optional, and have it override whatever is in ep.config.json?

Most Demo Team assets are PNGs. As this stands right now, we're going to need to not only convert our existing assets to one of the above formats, but also create duplicates (in each of the three formats) for every demo we put out (or go through and manually update the types on each of these components). It would definitely reduce friction if we could configure this in one place, and override manually where necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ Overriding it per usage sounds like a good idea to me! I'll make those changes :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

aChanEP added 2 commits May 12, 2020 17:36
Remove image type input
imgClassName="thumbnail"
isSkuImage
fileName={code}
imageFileTypes={['webp', 'jp2', 'jpg']}
Copy link
Contributor

@plundaahl-ep plundaahl-ep May 12, 2020

Choose a reason for hiding this comment

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

Would it be worth pulling this out before merging this in, and letting the details in ep.config.json determine the types used here?

Also, same question about the following files:

  • src/components/src/QuickOrderForm/quickorderform.tsx
  • src/components/src/ProductListItem/productlistitem.main.tsx
  • src/components/src/ProductDisplayItem/productdisplayitem.main.tsx

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep removing these types. Will be an optional parameter that will override the types in the config.

isSkuImage: false,
ImageContainerSrcs: [],
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see this defined in the props interface. Where is it used? If you want to keep it it should be camel case like all the prop names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. Removing

aChanEP added 8 commits May 13, 2020 17:12
remove alt
change to use React Component
remove styling
remove useless onerror
add newline
get rid of alt
update readme
new line
Copy link
Contributor Author

@aChanEP aChanEP left a comment

Choose a reason for hiding this comment

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

Please address conflicts & rebase

rebased

@@ -0,0 +1,3 @@
picture {
width: 100%;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch!

);
const generateSrcSet = type => imageSizes.reduce((acc, imageSize) => {
if (acc === '') {
return `${acc}${imgPrefix.replace('%fileName%', `${type}/${fileName}-${imageSize}w.${type} ${imageSize}w`)}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

WIP looking into it

isSkuImage: false,
ImageContainerSrcs: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. Removing

aChanEP added 7 commits May 14, 2020 13:42
support mutli-sku images
update config
Update storybook README and stories
use cleaner approach
update image container styling
add aria-label back
add new line
@aChanEP
Copy link
Contributor Author

aChanEP commented May 14, 2020

All problems have been addressed here! This should be ready to be merged! Working on re-skinning docs now :)

@elasticpath elasticpath deleted a comment from allcontributors bot May 14, 2020
aChanEP added 3 commits May 14, 2020 18:38
update README and make slight changes to error handling
change naming
stop never ending refresh loop
make some quick fixes
@aChanEP aChanEP merged commit 40bfd67 into master May 15, 2020
@aChanEP aChanEP deleted the srcSet branch May 15, 2020 15:37
@@ -147,8 +147,14 @@ class ProductListItemMain extends Component<ProductListItemMainProps, ProductLis
return (
<div className="category-item-inner">
<div className={`category-item-thumbnail-container ${imageStatus === 'loaded' ? 'loaded' : ''}`}>
<Link to={`${itemDetailLink}/${encodeURIComponent(productData._code[0].code)}`} title={productData._definition[0]['display-name']}>
Copy link
Contributor

Choose a reason for hiding this comment

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

axe reports an error due to the missing title. I'll fix this in my PR with the version update before release cut-off:
#712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants