Last active
November 11, 2019 11:31
-
-
Save BiosBoy/2fc964f45bbf9f1f1fae45b6c70b8f80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // CONSTANTS | |
| $pixels-density-list: 1 2; | |
| $webp-support: '.webp-support'; | |
| $webp-format: 'webp'; | |
| // LAYOUTS LIST BELOW | |
| $resoultions-tablet_mobile: tablet 'max-width: 1000px', mobile 'max-width: 600px'; | |
| $resoultions-only_tablet: tablet 'max-width: 1000px',; // "," - is a hack for a single object props; | |
| $resoultions-only_mobile: mobile 'max-width: 600px',; // "," - is a hack for a single object props; | |
| @mixin image-factory($folder, $layout, $name, $current-pixels, $type, $webp) { | |
| @if $webp { | |
| background-image: url($folder + $layout + '/'+ $name + '@' + $current-pixels + 'x.' + $webp-format); | |
| } @else { | |
| background-image: url($folder + $layout + '/'+ $name + '@' + $current-pixels + 'x.' + $type); | |
| } | |
| } | |
| @mixin generate-set($folder, $name, $type, $current-pixels, $layout) { | |
| @media (-webkit-min-device-pixel-ratio: $current-pixels) { | |
| @include image-factory($folder, $layout, $name, $current-pixels, $type, $webp: false); | |
| #{$webp-support} & { | |
| @include image-factory($folder, $layout, $name, $current-pixels, $type, $webp: true); | |
| } | |
| } | |
| } | |
| @mixin desktop-images($folder, $name, $type) { | |
| @each $current-pixels in $pixels-density-list { | |
| @include generate-set($folder, $name, $type, $current-pixels, $layout: 'desktop'); | |
| } | |
| } | |
| @mixin touchscreen-images($folder, $name, $type, $layouts-list) { | |
| @each $current-resolution in $layouts-list { | |
| $layout: nth($current-resolution, 1); | |
| $resolution: nth($current-resolution, 2); | |
| @media ($resolution) { | |
| @each $current-pixels in $pixels-density-list { | |
| @include generate-set($folder, $name, $type, $current-pixels, $layout); | |
| } | |
| } | |
| } | |
| } | |
| @mixin progressive-images-set($folder, $name, $type, $layouts-list) { | |
| @include desktop-images($folder, $name, $type); | |
| @include touchscreen-images($folder, $name, $type, $layouts-list); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment