Skip to content

Commit

Permalink
Minor changes wrt to agent about block
Browse files Browse the repository at this point in the history
  • Loading branch information
piyushjindal committed Jun 8, 2024
1 parent 29524d6 commit 705d6a6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion blocks/agent-about/agent-about.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
display: inline-block;
margin-top: 1rem;
text-decoration: underline;
font-size: var(--body-font-size-xs);
}

.agent-about.block a.view-more::after {
Expand All @@ -33,7 +34,7 @@
.agent-about.block>div.cols-1,
.agent-about.block>div.cols-2,
.agent-about.block>div.cols-3 {
padding-bottom: 1rem;
padding-bottom: 2rem;
}

.agent-about.block>div>div:first-of-type {
Expand Down
21 changes: 19 additions & 2 deletions blocks/agent-about/agent-about.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getMetadata } from '../../scripts/aem.js';
import {
a, div, ul, li,
} from '../../scripts/dom-helpers.js';
Expand All @@ -18,7 +19,23 @@ const viewMoreOnClick = (name, anchor, block) => {
});
};

const getCol = (list, colText) => {
const colsUl = ul();
list.split(',').forEach((x) => {
colsUl.append(li(x.trim()));
});
return div(div(colText), div(colsUl));
};

export default function decorate(block) {
const aboutText = getMetadata('about');
const accreditations = getMetadata('professional-accreditations');
const languages = getMetadata('languages');

block.replaceChildren(div(div('About'), div(aboutText)),
getCol(accreditations, 'Professional Accreditations'),
getCol(languages, 'Languages'));

const children = [...block.children];
if (children?.length) {
children.forEach((child, index) => {
Expand All @@ -43,10 +60,10 @@ export default function decorate(block) {

if (liItems.length > threshold) {
child.children[1].classList.add('hide');
const tempUl = ul({ });
const tempUl = ul();
Array.from(child.children[1].querySelectorAll('li'))
.slice(0, threshold).forEach((liItem) => {
const tempLi = li({}, liItem.textContent);
const tempLi = li(liItem.textContent);
tempUl.append(tempLi);
});

Expand Down
4 changes: 2 additions & 2 deletions blocks/agent-transactions/agent-transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export default async function decorate(block) {
trBody.appendChild(trElement);
});

const tableElement = table({}, thead({}, theadTr), trBody);
const heading1 = h1({}, 'Closed Transactions');
const tableElement = table(thead(theadTr), trBody);
const heading1 = h1('Closed Transactions');
const anchor = a({ class: 'show-more' });
anchor.addEventListener('click', () => {
if (anchor.classList.contains('show-more')) {
Expand Down

0 comments on commit 705d6a6

Please sign in to comment.