-
Notifications
You must be signed in to change notification settings - Fork 615
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
STENCIL-3891 Lazy load images, save space for images while loading #1104
Conversation
Nice work! Any idea what the browser compatibility looks like for some of the CSS you're using? |
9b7d57b
to
aca239a
Compare
I don't believe I'm using anything that will affect compatibility, but one of the reasons I have it marked as WIP is indeed that I want to take it through the browserstack ringer first. |
1e34b23
to
7605c95
Compare
e87dc94
to
6fdb08f
Compare
text-align: center; | ||
position: relative; | ||
|
||
img { |
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.
Is this a good candidate for a @mixin
since it is used in a couple of places.
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.
Will do
content: ''; | ||
display: block; | ||
padding-bottom: get-padding(stencilString('product_size')); | ||
} |
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.
EOL is missing
|
||
.lazyload, .lazyloading { | ||
height:100%; | ||
} |
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.
EOL is missing
@@ -72,7 +90,7 @@ | |||
position: absolute; | |||
right: 0; | |||
top: 0; | |||
width: auto; | |||
width: 100%; |
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.
won't this stretch the image to the width of the outside container. This could cause image to stretch when they are loaded with a small dimension like 10x10
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.
Oh, I remembered why I did this. There's currently an issue when the browser width is extremely small, the thumbnails will extend outside their borders, like so:
I would have liked to use max-width, but unfortunately we're already setting max-width at 50px here. I don't know of a CSS trick to essentially say "max of 50px or 100%, whichever is less", but perhaps there is one.
In any event, this doesn't really have to be a part of this ticket, so I changed it back.
.card-img-container:after { | ||
padding-bottom: get-padding(stencilString('brand_size')); | ||
} | ||
} |
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.
EOL is missing
$list: str-split($size, 'x'); | ||
|
||
@return nth($list, 2) + 'px'; | ||
} |
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.
EOL is missing
assets/scss/tools/_image.scss
Outdated
@@ -0,0 +1,21 @@ | |||
// http://sassmeister.com/gist/1b4f2da5527830088e4d | |||
@function get-padding($size) { |
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.
Can we add some doc blocks for these helpers which we are adding. Also this would be a good candidate for documentation.
assets/scss/tools/_string.scss
Outdated
@@ -8,3 +8,66 @@ | |||
|
|||
@return $string; | |||
} | |||
|
|||
// https://stackoverflow.com/questions/32376461/how-to-split-a-string-into-two-lists-of-numbers-in-sass | |||
@function str-split($string, $separator) { |
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.
Can we add some doc blocks for these helpers which we are adding. Also this would be a good candidate for documentation.
assets/scss/tools/_string.scss
Outdated
} | ||
|
||
@return $value * map-get($units, $unit); | ||
} |
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.
EOL is missing
@@ -1,2 +1,3 @@ | |||
@import "list"; | |||
@import "string"; | |||
@import "image"; |
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.
EOL is missing
assets/scss/tools/_string.scss
Outdated
} | ||
|
||
// https://www.sassmeister.com/gist/9fa19d254864f33d4a80 | ||
@function to-number($value) { |
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.
Since we are adding all these helpers should we think about adding some unit tests to go with it as well. This is just for the team to think over. Not a priority for this PR @bigcommerce/stencil-team
CHANGELOG.md
Outdated
@@ -2,6 +2,8 @@ | |||
|
|||
## Draft | |||
- Use appropriately-sized (50x50) images for product thumbnails on product details page [#1097](https://github.com/bigcommerce/cornerstone/pull/1097) | |||
- Load visible images before images below the fold [#1104](https://github.com/bigcommerce/cornerstone/pull/1104) | |||
- Save space for lazy loading images while they are loading [#1104](https://github.com/bigcommerce/cornerstone/pull/1104) |
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.
I am not sure we should be adding multiple lines pointing to the same PR. Can we update the desc in the first one to include the second one as well.
6824c6e
to
b43a564
Compare
8d98981
to
6bd8c50
Compare
margin-top: spacing("half"); | ||
} | ||
.productView-img-container:after { | ||
content: ''; |
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.
just a helpful pointer - a few other places lend themselves well to using mixins
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; |
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.
Indentation - 4 soft tabs - see style guide
.brand-image-container:after { | ||
content: ''; | ||
display: block; | ||
padding-bottom: get-padding(stencilString('thumb_size')); |
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.
Indentation - 4 soft tabs
assets/scss/tools/_string.scss
Outdated
@function to-number($value) { | ||
@if type-of($value) == 'number' { | ||
@return $value; | ||
} @else if type-of($value) != 'string' { |
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.
Indentation
6bd8c50
to
cd247d3
Compare
cd247d3
to
7715219
Compare
Looks good to me 👍 |
💚 |
Autotagging @bigcommerce/stencil-team @davidchin |
What?
Lazy load all site images, and save space for images while they are loading.
Tickets / Documentation