STRF-8622 Add helper for generating a 1x/2x srcset for store logo #149
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What? Why?
Add a helper to make it easy to generate 1x/2x srcsets for images that have stored dimensions.
The specific reason for creating this is to allow the store logo to look good even when it has been given an explicit pixel size; we can separate CSS pixel size from inherent pixel sizing easily with this helper.
Given an input like:
{{getImageSrcset1x2x image_with_dimensions "123x456"}}
and a StencilImage with dimensions like this:
It will produce a
srcset
value string like this:https://cdn.example.com/path/to/123x456/image.png?c=2 1x, https://cdn.example.com/path/to/246x912/image.png?c=2 2x
It can also create the best-possible version if the image is not big enough to support 2x, such as:
{{getImageSrcset1x2x image_with_dimensions "123x556"}}
https://cdn.example.com/path/to/123x556/image.png?c=2 1x, https://cdn.example.com/path/to/210x950/image.png?c=2 1.7086x
which is still a validsrcset
.How was it tested?
Unit tests.
cc @bigcommerce/storefront-team