-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1104 from BC-EChristensen/STENCIL-3891
STENCIL-3891 Lazy load images, save space for images while loading
- Loading branch information
Showing
40 changed files
with
332 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// ============================================================================= | ||
// LAZY LOAD | ||
// ============================================================================= | ||
|
||
|
||
// Component | ||
@import "lazyLoad"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.lazyload, .lazyloading { | ||
height:100%; | ||
} | ||
|
||
@mixin lazy-loaded-img() { | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
margin: auto; | ||
} | ||
|
||
@mixin lazy-loaded-padding($size-param) { | ||
&:after { | ||
content: ''; | ||
display: block; | ||
height: 0; | ||
width: 100%; | ||
padding-bottom: get-padding(stencilString($size-param)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.brand-image-container { | ||
position: relative; | ||
max-width: get-width(stencilString('thumb_size')); | ||
|
||
img { | ||
@include lazy-loaded-img; | ||
} | ||
|
||
@include lazy-loaded-padding('thumb_size'); | ||
} | ||
|
||
.brand { | ||
.card-img-container { | ||
max-width: get-width(stencilString('brand_size')); | ||
|
||
@include lazy-loaded-padding('brand_size'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// | ||
/// Calculate the required `padding-bottom` value to reserve page space for an image of a given size, represented by `$size`. | ||
/// | ||
/// @param {String} $size - A string of the form 'XxY', where 'X' and 'Y' are integers. | ||
/// | ||
/// @return {Number} - A percentage indicating the appropriate value of `padding-bottom`. | ||
/// | ||
@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); | ||
} | ||
|
||
/// | ||
/// Returns a string representing the width (in pixels) of an image with size `$size`. | ||
/// | ||
/// @param {String} $size - A string of the form 'XxY', where 'X' and 'Y' are integers. | ||
/// | ||
/// @return {String} - A string of the form 'Xpx' | ||
/// | ||
@function get-width($size) { | ||
$list: str-split($size, 'x'); | ||
|
||
@return nth($list, 1) + 'px'; | ||
} | ||
|
||
/// | ||
/// Returns a string representing the width (in pixels) of an image with size `$size`. | ||
/// | ||
/// @param {String} $size - A string of the form 'XxY', where 'X' and 'Y' are integers. | ||
/// | ||
/// @return {String} - A string of the form 'Ypx' | ||
/// | ||
@function get-height($size) { | ||
$list: str-split($size, 'x'); | ||
|
||
@return nth($list, 2) + 'px'; | ||
} |
Oops, something went wrong.