Skip to content

Commit

Permalink
STENCIL-3891 Lazy load images, save space for images while loading
Browse files Browse the repository at this point in the history
  • Loading branch information
christensenep committed Oct 19, 2017
1 parent 68b06ae commit e87dc94
Show file tree
Hide file tree
Showing 39 changed files with 348 additions and 54 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

## 1.9.4 (2017-10-17)
- Style optimized checkout new checklist radio buttons [#1088](https://github.com/bigcommerce/cornerstone/pull/1088)
Expand Down
19 changes: 17 additions & 2 deletions assets/scss/components/citadel/cards/_cards.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

.card-figure {
margin-top: $card-figure-marginTop;

position: relative;
&:hover {

// scss-lint:disable NestingDepth
Expand All @@ -24,6 +24,16 @@
}
}

.card-img-container {
max-width: get-width(stencilString('productgallery_size'));
}

.card-img-container:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('productgallery_size'));
}

.card-figcaption {
display: none;
margin: $card-figcaption-margin;
Expand All @@ -42,9 +52,14 @@

.card-image {
border: 0;
display: flex;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: auto;
max-height: 100%;
}

.card-title {
Expand Down
4 changes: 4 additions & 0 deletions assets/scss/components/citadel/loading/_loading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
display: none;
z-index: zIndex("low");
}

.lazyload, .lazyloading {
height:100%;
}
11 changes: 10 additions & 1 deletion assets/scss/components/stencil/account/_account.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
}

.account-product-image {
width: auto;
position: absolute;
top: 0;
bottom: 0;
margin: auto;
}
}

Expand Down Expand Up @@ -74,6 +77,12 @@
width: 70px;
}

.account-product-figure:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('productthumb_size'));
}

.account-product-download {
border-radius: 50%;
height: remCalc(33px);
Expand Down
40 changes: 36 additions & 4 deletions assets/scss/components/stencil/cart/_cart.scss
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ $cart-item-label-offset: $cart-thumbnail-maxWidth + $cart-item-sp
float: left;
height: $cart-thumbnail-height;
margin-bottom: $cart-item-spacing;
text-align: right;
width: grid-calc(4, $total-columns);
position: relative;

@include breakpoint("small") {
// height: auto;
Expand All @@ -113,17 +113,33 @@ $cart-item-label-offset: $cart-thumbnail-maxWidth + $cart-item-sp

@include breakpoint("medium") {
float: none;
text-align: left;
width: grid-calc(1, $total-columns);
}
}

.cart-item-figure:after {
content: '';
display: block;
height: 0;
width: 100%;
padding-bottom: get-padding(stencilString('productthumb_size'));
}

.cart-item-fixed-image {
width: 100%;
}

.cart-item-image {
width: auto;
position:absolute;
margin-left:auto;
top:0;
bottom:0;
left:0;
right:0;

@include breakpoint("medium") {
margin-left:0;
}
}

.cart-item-title {
Expand Down Expand Up @@ -556,8 +572,24 @@ $cart-item-label-offset: $cart-thumbnail-maxWidth + $cart-item-sp

.previewCartItem-image {
@include grid-column(4, $float: false);
padding: spacing("single");
padding: 0;
text-align: center;
position: relative;

img {
position: absolute;
margin: auto;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
}

.previewCartItem-image:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('productthumb_size'));
}

.previewCartItem-content {
Expand Down
32 changes: 25 additions & 7 deletions assets/scss/components/stencil/productView/_productView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,43 @@
align-items: center;
display: flex;
justify-content: center;
margin: 0;
margin: auto;
position: relative;

@include breakpoint("medium") {
min-height: 366px;
min-width: inherit;
}

img {
width: 100%;
+ .productView-thumbnails {
margin-top: spacing("half");
}
}

.productView-image--default {
.productView-img-container {
position: relative;
margin: auto;
max-width: get-width(stencilString('product_size'));
width: 100%;

img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin:auto;
max-height: 100%;
width: auto;
}
}

+ .productView-thumbnails {
margin-top: spacing("half");
}
.productView-img-container:after {
content: '';
display: block;
height: 0;
width: 100%;
padding-bottom: get-padding(stencilString('product_size'));
}

.productView-thumbnails {
Expand Down
20 changes: 20 additions & 0 deletions assets/scss/components/stencil/writeReview/_writeReview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,29 @@
}
}


.writeReview-form {

@include breakpoint("medium") {
@include grid-column(6);
}
}

.writeReview-productImage-container {
position: relative;

img {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
}

.writeReview-productImage-container:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('product_size'));
}
3 changes: 3 additions & 0 deletions assets/scss/layouts/_layouts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
// Brand grid
@import "brands/brandGrid";

// Brand product list
@import "brands/brand";

// Product grid
@import "products/productGrid";

Expand Down
19 changes: 18 additions & 1 deletion assets/scss/layouts/blog/_blog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,24 @@
}

.blog-thumbnail {
margin: 0 0 (spacing("base") * 2);
margin: 0 auto (spacing("base") * 2);
position: relative;
max-width: get_width(stencilString('blog_size'));

img {
position: absolute;
top: 0;
bottom: 0;
right: 0;
left: 0;
margin: auto;
}
}

.blog-thumbnail:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('blog_size'));
}

.blog-post-figure {
Expand Down
29 changes: 29 additions & 0 deletions assets/scss/layouts/brands/_brand.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.brand-image-container {
position: relative;
max-width: get-width(stencilString('thumb_size'));

img {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
}

.brand-image-container:after {
content: '';
display: block;
padding-bottom: get-padding(stencilString('thumb_size'));
}

.brand {
.card-img-container {
max-width: get-width(stencilString('brand_size'));
}

.card-img-container:after {
padding-bottom: get-padding(stencilString('brand_size'));
}
}
4 changes: 4 additions & 0 deletions assets/scss/layouts/brands/_brandGrid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
text-align: center;
}
}

.card-figure:after {
padding-bottom: get-padding(stencilString('brand_size'));
}
}
30 changes: 30 additions & 0 deletions assets/scss/layouts/header/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
@include breakpoint("medium") {
margin-left: remCalc(40px);
}

.header-logo-image {
right: unset;
}
}

.header-logo--right {
Expand All @@ -101,6 +105,10 @@
@include breakpoint("medium") {
margin-right: remCalc(40px);
}

.header-logo-image {
left: unset;
}
}

.header-logo-text {
Expand Down Expand Up @@ -139,14 +147,36 @@
}
}

.header-logo-image-container {
position: relative;
}

.header-logo-image-container:after {
content: '';
display: block;
padding-bottom: remCalc($header-height) - $header-logo-marginVertical * 2;

@include breakpoint("medium") {
padding-bottom: get-height(stencilString('logo_size'));
}
}

.header-logo-image {
position: absolute;
margin: auto;
top: 0;
right: 0;
left: 0;
bottom: 0;
max-height: remCalc($header-height) - $header-logo-marginVertical * 2;

@include breakpoint("medium") {
max-height: none;
}
}



//
// Mobile Menu Toggle
//
Expand Down
21 changes: 21 additions & 0 deletions assets/scss/tools/_image.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// http://sassmeister.com/gist/1b4f2da5527830088e4d
@function get-padding($size) {
$list: str-split($size, 'x');

$width: to-number(nth($list, 1));
$height: to-number(nth($list, 2));

@return percentage($height/$width);
}

@function get-width($size) {
$list: str-split($size, 'x');

@return nth($list, 1) + 'px';
}

@function get-height($size) {
$list: str-split($size, 'x');

@return nth($list, 2) + 'px';
}
Loading

0 comments on commit e87dc94

Please sign in to comment.