diff --git a/scripts/aem.js b/scripts/aem.js
index f04b8e8..650b49c 100644
--- a/scripts/aem.js
+++ b/scripts/aem.js
@@ -633,8 +633,57 @@ function decorateBlocks(main) {
main.querySelectorAll('div.section > div > div').forEach(decorateBlock);
}
+function decorateGroups() {
+ const parentElement = document.querySelector('body.ship-focus .default-content-wrapper');
+ const groupContainer = document.createElement('div');
+ const subcontainer = document.createElement('div');
+ let groupElement = document.createElement('div');
+ let isCard = false;
+ let child = parentElement.firstChild;
+ subcontainer.classList.add('blocks');
+ groupElement.classList.add('main-group');
+
+ while (child) {
+ if (groupElement.children.length > 0) {
+ switch (child.nodeName) {
+ case 'H1':
+ groupContainer.appendChild(groupElement);
+ groupElement = document.createElement('div');
+ break;
+ case 'H2':
+ groupContainer.appendChild(groupElement);
+ groupElement = document.createElement('div');
+ groupElement.classList.add('sub-group');
+ break;
+ case 'H3':
+ if (!isCard) {
+ groupContainer.appendChild(groupElement);
+ } else {
+ subcontainer.appendChild(groupElement);
+ }
+ groupElement = document.createElement('div');
+ groupElement.classList.add('block');
+ isCard = true;
+ break;
+ default:
+ break;
+ }
+ groupElement.appendChild(child);
+ } else {
+ groupElement.appendChild(child);
+ }
+ child = parentElement.firstChild;
+
+ if (!child) {
+ subcontainer.appendChild(groupElement);
+ groupContainer.appendChild(subcontainer);
+ }
+ }
+ parentElement.appendChild(groupContainer);
+}
+
function decorateSpaceshipFocusPageH1() {
- const spaceshipFocusPageH1Element = document.querySelector('body.ship-focus .default-content-wrapper > h1:first-child');
+ const spaceshipFocusPageH1Element = document.querySelector('body.ship-focus .default-content-wrapper .main-group h1');
if (spaceshipFocusPageH1Element) {
const innerText = spaceshipFocusPageH1Element.textContent.trim();
@@ -704,6 +753,7 @@ export {
decorateSections,
decorateTemplateAndTheme,
decorateSpaceshipFocusPageH1,
+ decorateGroups,
fetchPlaceholders,
getMetadata,
loadBlock,
diff --git a/scripts/scripts.js b/scripts/scripts.js
index 867659d..d5ba0a8 100644
--- a/scripts/scripts.js
+++ b/scripts/scripts.js
@@ -1,6 +1,5 @@
import {
sampleRUM,
- buildBlock,
// loadHeader,
// loadFooter,
decorateButtons,
@@ -9,25 +8,83 @@ import {
decorateBlocks,
decorateTemplateAndTheme,
decorateSpaceshipFocusPageH1,
+ decorateGroups,
waitForLCP,
loadBlocks,
loadCSS,
+ getMetadata,
} from './aem.js';
const LCP_BLOCKS = []; // add your LCP blocks to the list
-/**
- * Builds hero block and prepends to main in a new section.
- * @param {Element} main The container element
- */
-function buildHeroBlock(main) {
- const h1 = main.querySelector('h1');
- const picture = main.querySelector('picture');
- // eslint-disable-next-line no-bitwise
- if (h1 && picture && (h1.compareDocumentPosition(picture) & Node.DOCUMENT_POSITION_PRECEDING)) {
- const section = document.createElement('div');
- section.append(buildBlock('hero', { elems: [picture, h1] }));
- main.prepend(section);
+function addSpeedInformation(info, containerElement) {
+ const infoElement = document.createElement('div');
+
+ infoElement.classList.add('info');
+
+ const texts = info.split(' ');
+ const result = `${texts[0]}${texts.slice(1).join(' ')}`;
+
+ infoElement.innerHTML = result;
+ containerElement.appendChild(infoElement);
+}
+
+function addSpecifications(specs) {
+ const specContainer = document.createElement('div');
+
+ specContainer.classList.add('spec-container');
+
+ const content = `
SPECIFICATIONS
Learn more about the ${document.querySelector('h1').textContent} and its technical specifications.
+ length | width | height | weight |
+ ${specs.Length} | ${specs.Width} | ${specs.Height} | ${specs.Weight} |
`;
+ specContainer.innerHTML = content;
+
+ const parentElement = document.querySelector('body.ship-focus .default-content-wrapper');
+ parentElement.appendChild(specContainer);
+}
+
+async function prepareSpecification() {
+ try {
+ if (!document.body.classList.contains('ship-focus')) {
+ return;
+ }
+ const specificationPath = getMetadata('specifications');
+ if (!specificationPath) {
+ return;
+ }
+ const specificationUrl = new URL(specificationPath);
+ const specificationsResponse = await fetch('/specifications/query-index.json');
+ if (!specificationsResponse.ok) {
+ return;
+ }
+ const specifications = await specificationsResponse.json();
+ const specification = specifications.data.find((s) => s.path === specificationUrl.pathname);
+ if (!specification) {
+ return;
+ }
+
+ const specificationsObj = JSON.parse(specification.specifications);
+ const infoContainer = document.createElement('div');
+ const titleElement = document.querySelector('h2');
+
+ if (specificationsObj.Range) {
+ addSpeedInformation(specificationsObj.Range, infoContainer);
+ // Temp content as it is not received from document
+ addSpeedInformation(specificationsObj['Number of Passengers'], infoContainer);
+ addSpeedInformation(specificationsObj.Length, infoContainer);
+ }
+
+ addSpecifications(specificationsObj);
+
+ infoContainer.classList.add('info-container');
+ titleElement.parentNode.insertBefore(infoContainer, titleElement);
+
+ // these dataset are reference and will be removed later
+ document.body.dataset.features = specification.features;
+ document.body.dataset.specification = specification.specifications;
+ } catch (e) {
+ // eslint-disable-next-line no-console
+ console.error('could not load specifications', e);
}
}
@@ -49,7 +106,7 @@ async function loadFonts() {
*/
function buildAutoBlocks(main) {
try {
- buildHeroBlock(main);
+ prepareSpecification(main);
} catch (error) {
// eslint-disable-next-line no-console
console.error('Auto Blocking failed', error);
@@ -68,6 +125,7 @@ export function decorateMain(main) {
buildAutoBlocks(main);
decorateSections(main);
decorateBlocks(main);
+ decorateGroups();
decorateSpaceshipFocusPageH1();
}
diff --git a/styles/baseModel.css b/styles/baseModel.css
index 5967b6b..080059b 100644
--- a/styles/baseModel.css
+++ b/styles/baseModel.css
@@ -6,15 +6,26 @@ body.ship-focus .default-content-wrapper {
max-width: 100%;
}
-body.ship-focus .default-content-wrapper p:not(p ~ p) {
+/* body.ship-focus .default-content-wrapper p:not(p ~ p) {
+ margin: 0 -130px;
+} */
+
+/* stylelint-disable-next-line no-descending-specificity */
+body.ship-focus .default-content-wrapper h1 + p {
+ max-height: 100vh;
+ display: block;
+ overflow-y: hidden;
margin: 0 -130px;
}
body.ship-focus .default-content-wrapper p:not(p ~ p) img {
- width: 100%;
+ width: 100vw;
+ height: 100vh;
+ object-fit: cover;
}
-body.ship-focus .default-content-wrapper > h1:first-child {
+
+body.ship-focus .default-content-wrapper .main-group > h1:first-child {
position: absolute;
left: 0;
right: 0;
@@ -26,11 +37,11 @@ body.ship-focus .default-content-wrapper > h1:first-child {
color: var(--dark-blue);
text-transform: uppercase;
transform: skew(40deg);
- padding-left: 400px;
line-height: 150px;
+ width: 60%;
}
-body.ship-focus .default-content-wrapper > h1:first-child .rotate {
+body.ship-focus .default-content-wrapper .main-group > h1:first-child .rotate {
position: relative;
white-space: pre-wrap;
transform: skew(-40deg);
diff --git a/styles/styles.css b/styles/styles.css
index 2f14ba0..7565f39 100644
--- a/styles/styles.css
+++ b/styles/styles.css
@@ -217,9 +217,142 @@ main .section.highlight {
color: var(--midnight-blue-color);
}
+.default-content-wrapper h2 {
+ margin-top: 60px;
+}
+
+.default-content-wrapper .sub-group p {
+ line-height: 27px;
+}
+
+/*
+.default-content-wrapper .blocks {
+ display: flex;
+ flex-wrap: wrap;
+ margin-top: 80px;
+ gap: 107px;
+}
+
+.default-content-wrapper .block:first-child {
+ flex-basis: 55%;
+}
+
+.default-content-wrapper .block:nth-child(2),
+.default-content-wrapper .block:nth-child(3) {
+ flex-basis: 30%;
+} */
+
+.default-content-wrapper .blocks {
+ display: flex;
+ flex-direction: column;
+ margin-top: 80px;
+ gap: 42px;
+}
+
+.default-content-wrapper .block {
+ display: flex;
+ flex-direction: column;
+ /* stylelint-disable-next-line declaration-block-no-redundant-longhand-properties */
+ flex-wrap: wrap;
+ font-size: var(--paragraph-font-size);
+ line-height: 27px;
+ width: 100%;
+ height: 500px;
+ overflow: hidden;
+}
+
+.default-content-wrapper .block:nth-child(odd) h3 {
+ order: 1;
+ margin-bottom: 0;
+ margin-top: 24px;
+ font-size: var(--paragraph-font-size);
+}
+
+.default-content-wrapper .block:nth-child(odd) h3 + p {
+ order: 3;
+ margin-top: 0;
+ margin-left: 106px;
+}
+
+.default-content-wrapper .block:nth-child(odd) p:last-child {
+ order: 2;
+ margin-top: 10px;
+ width: 40%;
+}
+
+.default-content-wrapper .block:nth-child(even) h3 {
+ order: 2;
+ margin-bottom: 0;
+ margin-top: 24px;
+ font-size: var(--paragraph-font-size);
+}
+
+/* stylelint-disable-next-line no-descending-specificity */
+.default-content-wrapper .block:nth-child(even) h3 + p {
+ order: 1;
+ margin-top: 0;
+ width: 30%;
+ margin-right: 106px;
+}
+
+.default-content-wrapper .block:nth-child(even) p:last-child {
+ order: 3;
+ margin-top: 10px;
+ width: 60%;
+}
+
+.default-content-wrapper .info-container {
+ position: absolute;
+ top: 550px;
+ right: 130px;
+}
+
+.default-content-wrapper .info-container .info-number {
+ font-size: 50px;
+ line-height: 70px;
+ font-weight: 300;
+}
+
+.default-content-wrapper .info-container .info-text {
+ font-size: 15px;
+ line-height: 24px;
+ padding-left: 5px;
+ vertical-align: super;
+}
+
+.default-content-wrapper .info {
+ background-color: var(--background-color);
+ opacity: 0.9;
+ padding: 10px 20px;
+ margin-bottom: 20px;
+}
+.default-content-wrapper .spec-container {
+ margin-top: 86px;
+}
+
+.default-content-wrapper .spec-container h2{
+ clear: both;
+}
+
+.default-content-wrapper .spec-container table {
+ width: 100%;
+ margin-top: 37px;
+}
+
+.default-content-wrapper .spec-container th {
+ font-size: 15px;
+ line-height: 24px;
+ font-weight: 400;
+ text-align: left;
+}
+
+.default-content-wrapper .spec-container td {
+ font-size: 20px;
+ line-height: 26px;
+ font-weight: 600;
+}
/* stylelint-disable-next-line no-descending-specificity */
p {
font-size: var(--paragraph-font-size);
}
-