From ec3057873adada9005b5d1d7655975f333259db8 Mon Sep 17 00:00:00 2001 From: kailasnadh790 <53608019+kailasnadh790@users.noreply.github.com> Date: Thu, 30 Nov 2023 20:23:59 -0500 Subject: [PATCH] refactored code --- cigaradvisor/blocks/imagecta/imagecta.css | 18 ++++++++---------- cigaradvisor/blocks/imagecta/imagecta.js | 14 +++++--------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/cigaradvisor/blocks/imagecta/imagecta.css b/cigaradvisor/blocks/imagecta/imagecta.css index fdd30b48..8a053fdd 100644 --- a/cigaradvisor/blocks/imagecta/imagecta.css +++ b/cigaradvisor/blocks/imagecta/imagecta.css @@ -1,11 +1,9 @@ -@media (min-width: 60em) { - .home-tall-banner > a { - display: block!important; - width: 100%!important; - height: 100%!important; - border: 1px solid #000!important; - background-size: cover; - background-position: 50% 50%; - background-repeat: no-repeat; - } +.home-tall-banner > a img{ + display: block; + position: relative; + max-width: 100%; + max-height: 100%; + width: auto; + height: auto; + border: 1px solid #000; } \ No newline at end of file diff --git a/cigaradvisor/blocks/imagecta/imagecta.js b/cigaradvisor/blocks/imagecta/imagecta.js index b8f10e85..c9d30b33 100644 --- a/cigaradvisor/blocks/imagecta/imagecta.js +++ b/cigaradvisor/blocks/imagecta/imagecta.js @@ -1,12 +1,8 @@ -import { - createOptimizedPicture, readBlockConfig, -} from '../../scripts/aem.js'; - export default async function decorate(block) { - const configs = readBlockConfig(block); - block.textContent = ''; + const children = []; const anchor = document.createElement('a'); - anchor.append(createOptimizedPicture(configs.image)); - anchor.setAttribute('href', configs.link); - block.append(anchor); + anchor.append(block.querySelector('picture')); + anchor.setAttribute('href', block.querySelector('a').getAttribute('href')); + children.push(anchor); + block.replaceChildren(...children); }