Skip to content

Commit

Permalink
KAW-7684 Refactor full widht to support all of the blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
TomaszDziezykNetcentric committed Jul 24, 2024
1 parent 910dc61 commit 5c4000e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
11 changes: 0 additions & 11 deletions blocks/image/image.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
.section .image-wrapper-full-width {
margin: 0;
width: 100%;
max-width: 100vw;
}

.block.image picture {
display: flex;
}
Expand All @@ -12,8 +6,3 @@
width: 100%;
object-fit: cover;
}

.block.image.full-width {
margin-left: calc(-1 * var(--section-x-padding));
margin-right: calc(-1 * var(--section-x-padding));
}
6 changes: 2 additions & 4 deletions blocks/image/image.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export default async function decorate(block) {
if (block.classList.contains('full-width')) {
block.parentElement.classList.add('image-wrapper-full-width');
}
export default async function decorate() {
// JS code
}
9 changes: 9 additions & 0 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ function buildAutoBlocks(main) {
}
}

function customDecorateBlocks(main) {
main.querySelectorAll('div.section > div > div').forEach((block) => {
if (block.classList.contains('full-width')) {
block.parentElement.classList.add('wrapper-full-width');
}
});
}

/**
* Decorates the main element.
* @param {Element} main The main element
Expand All @@ -67,6 +75,7 @@ export function decorateMain(main) {
buildAutoBlocks(main);
decorateSections(main);
decorateBlocks(main);
customDecorateBlocks(main);
}

/**
Expand Down
12 changes: 12 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ main .section:last-child {
}
}

/* full width styles */
.section .wrapper-full-width {
margin: 0;
width: 100%;
max-width: 100vw;
}

.block.full-width {
margin-left: calc(-1 * var(--section-x-padding));
margin-right: calc(-1 * var(--section-x-padding));
}

/* section metadata */
main .section.light,
main .section.highlight {
Expand Down

0 comments on commit 5c4000e

Please sign in to comment.