Skip to content

Commit

Permalink
#270 Add v2-iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
tdziezykDS committed Dec 8, 2023
1 parent 2cbaaee commit 7a416db
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
14 changes: 14 additions & 0 deletions blocks/v2-iframe/v2-iframe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.v2-iframe iframe {
width: 100%;
}

.v2-iframe.v2-iframe--full-viewport {
width: 100vw;
height: 100vh;
display: flex;
}

.v2-iframe--full-viewport iframe {
width: 100%;
height: 100%;
}
17 changes: 17 additions & 0 deletions blocks/v2-iframe/v2-iframe.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { variantsClassesToBEM } from '../../scripts/common.js';

export default async function decorate(block) {
const iframe = document.createElement('iframe');
const link = block.querySelector('a')?.getAttribute('href') || block.textContent.trim();
const fixedHeightClass = [...block.classList].find((el) => /[0-9]+px/.test(el));

variantsClassesToBEM(block.classList, ['full-viewport'], 'v2-iframe');

if (fixedHeightClass) {
iframe.height = fixedHeightClass;
}

iframe.src = link;
iframe.setAttribute('frameborder', 0);
block.replaceChildren(iframe);
}
15 changes: 11 additions & 4 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,15 @@ export function getImageForBreakpoint(imagesList, onChange = () => { }) {
onDesktopChange(desktopMQ);
}

const moveClassToHtmlEl = (className, elementSelector = 'main') => {
if (document.querySelector(elementSelector).classList.contains(className)) {
document.querySelector('html').classList.add(className);
document.querySelector(elementSelector).classList.remove(className);
}
};

/* REDESING CLASS CHECK */
if (document.querySelector('main').classList.contains('redesign-v2')) {
document.querySelector('html').classList.add('redesign-v2');
document.querySelector('main').classList.remove('redesign-v2');
}
moveClassToHtmlEl('redesign-v2');

/* ETERNAL APP CLASS CHECK */
moveClassToHtmlEl('external-app');
18 changes: 18 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1730,3 +1730,21 @@ main.blue-contract .section.section-with-title p {
}

/* generic tooltip styles ends here */

/* externa app styles start */

.external-app header,
.external-app footer {
display: none;
}

.external-app .v2-iframe-wrapper {
padding: 0 !important;
margin: 0 !important;
}

.external-app .section.v2-iframe-container {
padding: 0;
}

/* externa app styles end */

0 comments on commit 7a416db

Please sign in to comment.