From d674d82ddbbb7030136935d765b2b8055033be1a Mon Sep 17 00:00:00 2001 From: Yurii Zusik Date: Fri, 3 Jul 2020 10:33:25 +0300 Subject: [PATCH 1/7] fix(Cornnerstone): BCTHEME-52 stretch & no strech carousel images option works --- assets/js/theme/common/carousel.js | 7 +- .../stencil/heroCarousel/_heroCarousel.scss | 120 +++++++++++++++--- templates/components/carousel.html | 4 +- 3 files changed, 104 insertions(+), 27 deletions(-) diff --git a/assets/js/theme/common/carousel.js b/assets/js/theme/common/carousel.js index 5d297f3fec..6ed8b6da6d 100644 --- a/assets/js/theme/common/carousel.js +++ b/assets/js/theme/common/carousel.js @@ -10,12 +10,7 @@ export default function () { // Alternative image styling for IE, which doesn't support objectfit if (typeof document.documentElement.style.objectFit === 'undefined') { $('.heroCarousel-slide').each((index, element) => { - const $container = $(element); - const imgUrl = $container.find('img').data('lazy'); - - if (imgUrl) { - $container.css('backgroundImage', `url(${imgUrl})`).addClass('compat-object-fit'); - } + $(element).addClass('compat-object-fit'); }); } } diff --git a/assets/scss/components/stencil/heroCarousel/_heroCarousel.scss b/assets/scss/components/stencil/heroCarousel/_heroCarousel.scss index 2113e68f52..e91b4dd1b5 100644 --- a/assets/scss/components/stencil/heroCarousel/_heroCarousel.scss +++ b/assets/scss/components/stencil/heroCarousel/_heroCarousel.scss @@ -28,8 +28,18 @@ } &.slick-initialized { // 2 - max-height: remCalc(1000); + // max-height: remCalc(1000); + // max-height: remCalc(250px); opacity: 1; + + @include breakpoint("small") { + max-height: remCalc(400px); + } + + @include breakpoint("medium") { + max-height: remCalc(600px); + } + } &:not(.slick-initialized) :not(.heroCarousel-slide--first).heroCarousel-slide { @@ -40,9 +50,17 @@ text-decoration: none; } + .slick-track { + // display: flex; + // justify-content: flex-start; + // align-items: center; + } + .slick-next, .slick-prev { top: 50%; + transform: translateY(-50%); + margin: 0; } .slick-next { @@ -77,39 +95,98 @@ .heroCarousel-slide { position: relative; + // max-height: remCalc(400px); a { text-decoration: none; } + + // @include breakpoint("medium") { + // max-height: remCalc(600px); + // } .heroCarousel-image { - @include breakpoint("medium") { - object-fit: cover; // 1 - max-height: remCalc(600px); - width: 100%; + object-fit: contain; + width: 100%; + height: 100%; + object-position: 50% 0%; + // width: 50px; + // max-height: remCalc(250px); + + @include breakpoint("small") { + // object-fit: cover; // 1 + // max-height: remCalc(600px); + // width: 100%; + // max-height: remCalc(400px); + object-position: 50% 50%; } - } - .heroCarousel-image-wrapper { @include breakpoint("medium") { - max-height: remCalc(600px); + // object-fit: cover; // 1 + // max-height: remCalc(600px); + // width: 100%; + // max-height: remCalc(600px); } + } - &.compat-object-fit { // 1 - background-size: cover; - background-position: 50%; - background-repeat: no-repeat; + &.stretch { + + .heroCarousel-image { + // display: block; + // width: 100vw; + // height: 100vh; + object-fit: cover; + object-position: 50% 50%; + } - &.stretch { - @include breakpoint("large") { // 4 - background-size: 100% 100%; + &.compat-object-fit { + .heroCarousel-image { + width: 100%; } } + } + + + + &.compat-object-fit { // 1 .heroCarousel-image { - opacity: 0; + width: auto; + height: auto; + margin: 0 auto; + } + } + + .heroCarousel-image-wrapper { + // max-height: remCalc(400px); + + // @include breakpoint("medium") { + // max-height: remCalc(600px); + // } + // height: 100%; + + height: remCalc(250px); + display: flex; + justify-content: center; + align-items: flex-start; + + @include breakpoint("small") { + // object-fit: cover; // 1 + // max-height: remCalc(600px); + // width: 100%; + height: remCalc(400px); } + + @include breakpoint("medium") { + // object-fit: cover; // 1 + // max-height: remCalc(600px); + // width: 100%; + height: remCalc(600px); + } + + } + } .heroCarousel-content { @@ -117,17 +194,22 @@ padding: spacing("half") spacing("single") (spacing("double")); text-align: center; - @include breakpoint("medium") { + @include breakpoint("small") { @include carouselOpaqueBackgrounds; + width: remCalc(700px); + padding: spacing("single") * 1.5; + + + width: 70%; background-color: rgba($carousel-bgColor, 0.9); left: 0; + padding: spacing("single"); margin: 0 auto; - padding: spacing("single") * 1.5; position: absolute; right: 0; top: 50%; transform: translateY(-50%); - width: remCalc(700px); + &.heroCarousel-content--empty { background-color: transparent; diff --git a/templates/components/carousel.html b/templates/components/carousel.html index 0563d1739e..b9d7c3ccab 100644 --- a/templates/components/carousel.html +++ b/templates/components/carousel.html @@ -6,12 +6,12 @@ "slidesToScroll": 1, "autoplay": true, "autoplaySpeed": {{carousel.swap_frequency}}, - "lazyLoad": "anticipated" + "lazyLoad": "anticipated", }'> {{#each carousel.slides}}