diff --git a/cigaradvisor/blocks/imagecta/imagecta.css b/cigaradvisor/blocks/imagecta/imagecta.css new file mode 100644 index 00000000..fdd30b48 --- /dev/null +++ b/cigaradvisor/blocks/imagecta/imagecta.css @@ -0,0 +1,11 @@ +@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; + } +} \ No newline at end of file diff --git a/cigaradvisor/blocks/imagecta/imagecta.js b/cigaradvisor/blocks/imagecta/imagecta.js new file mode 100644 index 00000000..1caad0ba --- /dev/null +++ b/cigaradvisor/blocks/imagecta/imagecta.js @@ -0,0 +1,27 @@ +export default function decorate(block) { + const anchor = document.createElement('a'); + [...block.children].forEach((row) => { + var link; + [...row.children].forEach((col) => { + const pic = col.querySelector('picture'); + if (pic) { + anchor.append(pic); + } + if (col.textContent.toLowerCase() !== "image" && col.textContent.toLowerCase() !== "link") { + link = col.textContent; + } + }); + anchor.setAttribute("href", link); + + const children = block.children; + + // Loop through the children and remove those that are not anchor tags + for (let i = children.length - 1; i >= 0; i--) { + if (children[i].tagName !== 'A') { + console.log(children[i].tagName); + block.removeChild(children[i]); + } + } + }); + block.append(anchor); +} \ No newline at end of file