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

Minor changes wrt to agent about block #246

Merged
merged 5 commits into from
Jun 10, 2024
Merged
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
8 changes: 3 additions & 5 deletions blocks/agent-about/agent-about.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
letter-spacing: normal;
}

.agent-about.block a {
cursor: pointer;
}

.agent-about.block .hide {
display: none;
}
Expand All @@ -20,6 +16,8 @@
display: inline-block;
margin-top: 1rem;
text-decoration: underline;
font-size: var(--body-font-size-xs);
color: var(--black);
}

.agent-about.block a.view-more::after {
Expand All @@ -33,7 +31,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
25 changes: 21 additions & 4 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 @@ -31,7 +48,7 @@ export default function decorate(block) {
child.children[1].classList.add('hide');
child.append(div({ class: `${name}-truncate` },
`${child.children[1].textContent.substring(0, threshold)}...`));
const anchor = a({ class: 'view-more' });
const anchor = a({ class: 'view-more', href: '#' });
child.append(anchor);
viewMoreOnClick(name, anchor, block);
}
Expand All @@ -43,15 +60,15 @@ 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);
});

child.append(div({ class: `${name}-truncate` }, tempUl));
const anchor = a({ class: 'view-more' });
const anchor = a({ class: 'view-more', href: '#' });
child.append(anchor);
viewMoreOnClick(name, anchor, block);
}
Expand Down
14 changes: 7 additions & 7 deletions blocks/agent-profile/agent-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ const getPhoneDiv = () => {
let phoneUl;

if (getMetadata('direct-phone')) {
phoneUl = ul({});
phoneUl.append(li({}, 'Direct: ', getMetadata('direct-phone')));
phoneUl = ul();
phoneUl.append(li('Direct: ', getMetadata('direct-phone')));
}

if (getMetadata('office-phone')) {
phoneUl = phoneUl || ul({});
phoneUl.append(li({}, 'Office: ', getMetadata('office-phone')));
phoneUl = phoneUl || ul();
phoneUl.append(li('Office: ', getMetadata('office-phone')));
}

if (phoneUl) {
Expand Down Expand Up @@ -62,9 +62,9 @@ const getSocialDiv = () => {

['facebook', 'instagram', 'linkedin'].forEach((x) => {
const url = getMetadata(x);
socialUl = socialUl || ul({});
socialUl = socialUl || ul();
if (url) {
const socialLi = li({}, a({
const socialLi = li(a({
href: url, class: x, title: x, 'aria-label': x,
}, span({ class: `icon icon-${x}` })));
socialUl.append(socialLi);
Expand All @@ -82,7 +82,7 @@ const getSocialDiv = () => {
export default async function decorate(block) {
const profileImage = getImageDiv();
const profileContent = div({ class: 'profile-content' },
div({ class: 'name' }, h1({}, getMetadata('name'))),
div({ class: 'name' }, h1(getMetadata('name'))),
div({ class: 'designation' }, getMetadata('designation')),
);

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
Loading