Skip to content

Commit

Permalink
block done
Browse files Browse the repository at this point in the history
  • Loading branch information
santi-homps committed Feb 5, 2024
1 parent 061e666 commit d3fcea2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
36 changes: 36 additions & 0 deletions blocks/v2-resources/v2-resources.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.section.v2-resources-container {
padding: 0 0 90px;
}

.section.v2-resources-container .v2-resources-wrapper {
padding: 40px 16px;
}

.v2-resources__heading {
font-family: var(--ff-headline-medium);
margin: 0;
}

.v2-resources__subtitle {
margin: 40px 0 0;
}

.v2-resources__text {
margin: 5px 0;
}

a.v2-resources__link {
display: block;
color: var(--text-color);
font-size: var(--body-font-size-xs);
line-height: var(--body-2-line-height);
width: fit-content;
margin-top: 15px;
border-bottom: 1px solid transparent;
}

a.v2-resources__link:hover {
text-decoration: none;
color: var(--c-tertiary-cool-gray);
border-color: var(--c-tertiary-cool-gray);
}
35 changes: 35 additions & 0 deletions blocks/v2-resources/v2-resources.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export default async function decorate(block) {
const blockName = 'v2-resources';

const contentWrapper = block.querySelector(':scope > div');
contentWrapper.classList.add(`${blockName}__content-wrapper`);

const columns = [...block.querySelectorAll(':scope > div > div')];

const [headerCol, contentCol] = columns;

headerCol.classList.add(`${blockName}__header`);
contentCol.classList.add(`${blockName}__content`);

const header = [...headerCol.querySelectorAll('h1, h2, h3, h4, h5, h6')];
header[0].classList.add(`${blockName}__heading`);

const subtitles = [...contentCol.querySelectorAll('h1, h2, h3, h4, h5, h6')];
subtitles.forEach((subt) => subt.classList.add(`${blockName}__subtitle`));

const contentElmts = [...contentCol.children];

contentElmts.forEach((el, idx) => {
const tagName = el.tagName.toLowerCase();
const isButton = [...el.classList].includes('button-container');
if (tagName === 'p' && !isButton) {
el.classList.add(`${blockName}__text`);
} else if (tagName === 'p' && isButton) {
const link = el.querySelector('a');
link.classList.add(`${blockName}__link`);
link.classList.remove('button--primary', 'button');
contentElmts[idx - 1].insertAdjacentElement('afterend', link);
el.remove();
}
});
}

0 comments on commit d3fcea2

Please sign in to comment.