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

STENCIL-3891 Lazy load images, save space for images while loading #1104

Merged
merged 1 commit into from
Nov 8, 2017

Conversation

christensenep
Copy link
Contributor

What?

Lazy load all site images, and save space for images while they are loading.

Tickets / Documentation

@bookernath
Copy link
Contributor

Nice work! Any idea what the browser compatibility looks like for some of the CSS you're using?

@christensenep
Copy link
Contributor Author

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.

@christensenep christensenep force-pushed the STENCIL-3891 branch 5 times, most recently from 1e34b23 to 7605c95 Compare October 18, 2017 18:42
@christensenep christensenep changed the title [WIP] STENCIL-3891 Lazy load images, save space for images while loading STENCIL-3891 Lazy load images, save space for images while loading Oct 18, 2017
@christensenep christensenep force-pushed the STENCIL-3891 branch 7 times, most recently from e87dc94 to 6fdb08f Compare October 19, 2017 18:46
text-align: center;
position: relative;

img {
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 good candidate for a @mixin since it is used in a couple of places.

Copy link
Contributor Author

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'));
}
Copy link
Contributor

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%;
}
Copy link
Contributor

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%;
Copy link
Contributor

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

Copy link
Contributor Author

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:

screen shot 2017-10-20 at 11 10 39 am

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'));
}
}
Copy link
Contributor

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';
}
Copy link
Contributor

Choose a reason for hiding this comment

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

EOL is missing

@@ -0,0 +1,21 @@
// http://sassmeister.com/gist/1b4f2da5527830088e4d
@function get-padding($size) {
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 add some doc blocks for these helpers which we are adding. Also this would be a good candidate for documentation.

@@ -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) {
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 add some doc blocks for these helpers which we are adding. Also this would be a good candidate for documentation.

}

@return $value * map-get($units, $unit);
}
Copy link
Contributor

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";
Copy link
Contributor

Choose a reason for hiding this comment

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

EOL is missing

}

// https://www.sassmeister.com/gist/9fa19d254864f33d4a80
@function to-number($value) {
Copy link
Contributor

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)
Copy link
Contributor

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.

@christensenep christensenep force-pushed the STENCIL-3891 branch 2 times, most recently from 6824c6e to b43a564 Compare October 20, 2017 18:55
@christensenep christensenep force-pushed the STENCIL-3891 branch 2 times, most recently from 8d98981 to 6bd8c50 Compare October 20, 2017 19:14
margin-top: spacing("half");
}
.productView-img-container:after {
content: '';

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;

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'));

Choose a reason for hiding this comment

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

Indentation - 4 soft tabs

@function to-number($value) {
@if type-of($value) == 'number' {
@return $value;
} @else if type-of($value) != 'string' {

Choose a reason for hiding this comment

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

Indentation

@tabayomi
Copy link

tabayomi commented Nov 1, 2017

Looks good to me 👍

@shanth100
Copy link

💚

@christensenep christensenep merged commit 3149e66 into bigcommerce:master Nov 8, 2017
@bigbot
Copy link

bigbot commented Nov 9, 2017

Autotagging @bigcommerce/stencil-team @davidchin

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.

6 participants