Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truck configurator #200 #192

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions blocks/v2-iframe/v2-iframe.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.iframe iframe {
width: 100%;
}

.v2-iframe iframe {
width: 100%;
}

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

@supports (height: 1svh) {
.v2-iframe.v2-iframe--full-viewport {
height: 100svh;
}
}

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

export default async function decorate(block) {
const link = block.querySelector('a')?.getAttribute('href') || block.textContent.trim();
const title = block.querySelector('h1, h2, h3, h4, h5, h6').textContent;
const iframe = createElement('iframe', { props: { src: link, frameborder: 0, title } });
const fixedHeightClass = [...block.classList].find((el) => /[0-9]+px/.test(el));
const maxWidthClass = [...block.classList].find((el) => /width-[0-9]+px/.test(el));

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

if (fixedHeightClass) {
iframe.height = fixedHeightClass;
}
if (maxWidthClass) {
const maxWidht = maxWidthClass.split('width-')[1];
iframe.style.maxWidth = maxWidht;
}

block.replaceChildren(iframe);
}
17 changes: 13 additions & 4 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,16 @@ function buildTruckLineupBlock(main, classname) {
}
}

/* REDESING CLASS CHECK */
if (getMetadata('style') === 'redesign-v2') {
document.querySelector('html').classList.add('redesign-v2');
}
const globalClasses = getMetadata('style').split(',').map((el) => el.trim());

const moveClassToHtmlEl = (className) => {
if (globalClasses.includes(className)) {
document.querySelector('html').classList.add(className);
}
};

/* REDESIGN CLASS CHECK */
moveClassToHtmlEl('redesign-v2');

/* EXTERNAL 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 @@ -1285,3 +1285,21 @@ main .section.responsive-title h1 {
width: 1px;
white-space: nowrap;
}

/* external 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;
}

/* external app styles end */