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

[MWPW-158015] [Mini Compare Merch Card] Redesign mini compare card for testing #3147

Open
wants to merge 35 commits into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6c6d3c9
Redesign mini-compare chart. Added checkmarks for icons. Backward com…
Nov 5, 2024
4c51f63
implemented cheveron up and down functionality for checkmark copy list
Nov 5, 2024
8a6c32e
added isMobile check
Nov 6, 2024
d725219
Fix backward compatibility issues
Nov 6, 2024
f0a65a6
minor
Nov 6, 2024
62e2ec2
minor css fixes as per figma
Nov 6, 2024
37b70b4
refactored large "decorateFooterRows" method
Nov 6, 2024
8dfa0e9
remove duplicate css
Nov 7, 2024
daadcbb
review comments
Nov 8, 2024
eb4ba26
UT added
Nov 11, 2024
5105249
Merge branch 'stage' into MWPW-158015
Nov 11, 2024
8e8ce9c
fix post merge conflict
Nov 11, 2024
7587c16
npm run build
Nov 11, 2024
28fbaea
linter
Nov 11, 2024
19f887a
UT coverage
Nov 13, 2024
5254abf
mini compare covergae
Nov 13, 2024
4407f37
review comment
Nov 13, 2024
08f60ba
fix post merge. margin was affected due to ul change
Nov 13, 2024
02e75a4
fixed ul after merge conflict with the other fix PR
Nov 14, 2024
b465d1c
Merge branch 'stage' into MWPW-158015
Nov 14, 2024
83b3004
linter
Nov 14, 2024
9bc6065
Merge branch 'stage' into MWPW-158015
Nov 27, 2024
dc5ee8e
Merge branch 'stage' into MWPW-158015
mirafedas Dec 11, 2024
11ee7bd
resolved conflicts
mirafedas Dec 11, 2024
ef3f6cd
fixed mini-compare-chart footer cta alignment
mirafedas Dec 11, 2024
4472303
decreased footer rows height to match the design
mirafedas Dec 11, 2024
5a56237
fixed mini-compare footer alignment
mirafedas Dec 13, 2024
16dee1a
fixed footer horizontal padding and mobile breakpoint
mirafedas Dec 16, 2024
f02ae16
updated unit tests
mirafedas Dec 16, 2024
882af05
corrected paddings, font sizes and other
mirafedas Dec 18, 2024
6c7342b
corrected slots
mirafedas Dec 18, 2024
4deca34
corrected padding
mirafedas Dec 18, 2024
e679d79
footer padding corrected
mirafedas Dec 18, 2024
385903e
Merge branch 'stage' into MWPW-158015
mirafedas Dec 20, 2024
4883637
corrected heading-m-price padding
mirafedas Dec 20, 2024
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
12 changes: 12 additions & 0 deletions libs/blocks/merch-card/img/chevron.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 72 additions & 15 deletions libs/blocks/merch-card/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { decorateButtons, decorateBlockHrs } from '../../utils/decorate.js';
import { getConfig, createTag, loadStyle } from '../../utils/utils.js';
import { getMetadata } from '../section-metadata/section-metadata.js';
import { processTrackingLabels } from '../../martech/attributes.js';
import { chevronDownSVG, chevronUpSVG } from './img/chevron.js';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be on-demand for performance reasons

import '../../deps/mas/merch-card.js';
import '../../deps/lit-all.min.js';

Expand Down Expand Up @@ -387,23 +388,79 @@ const getMiniCompareChartFooterRows = (el) => {
return footerRows;
};

const decorateFooterRows = (merchCard, footerRows) => {
if (footerRows) {
const footerRowsSlot = createTag('div', { slot: 'footer-rows' });
footerRows.forEach((row) => {
const rowIcon = row.firstElementChild.querySelector('picture');
const rowText = row.querySelector('div > div:nth-child(2)').innerHTML;
const rowTextParagraph = createTag('div', { class: 'footer-row-cell-description' }, rowText);
const footerRowCell = createTag('div', { class: 'footer-row-cell' });
if (rowIcon) {
rowIcon.classList.add('footer-row-icon');
footerRowCell.appendChild(rowIcon);
}
footerRowCell.appendChild(rowTextParagraph);
footerRowsSlot.appendChild(footerRowCell);
const createFirstRow = (firstRow, isMobile, checkmarkCopyContainer) => {
const firstRowText = firstRow.querySelector('div > div:last-child').innerHTML;
let firstRowTextParagraph;

if (isMobile) {
const chevronIcon = createTag('span', { class: 'chevron-icon' }, chevronDownSVG);
firstRowTextParagraph = createTag('div', { class: 'footer-rows-title' }, firstRowText);
firstRowTextParagraph.appendChild(chevronIcon);

firstRowTextParagraph.addEventListener('click', () => {
rohitsahu marked this conversation as resolved.
Show resolved Hide resolved
const isOpen = checkmarkCopyContainer.classList.toggle('open');
chevronIcon.innerHTML = isOpen ? chevronUpSVG : chevronDownSVG;
});
merchCard.appendChild(footerRowsSlot);
} else {
firstRowTextParagraph = createTag('div', { class: 'footer-rows-title' }, firstRowText);
checkmarkCopyContainer.classList.add('open');
}

return firstRowTextParagraph;
};

const createFooterRowCell = (row, isCheckmark) => {
const rowIcon = row.firstElementChild.querySelector('picture');
const rowText = row.querySelector('div > div:nth-child(2)').innerHTML;
const rowTextParagraph = createTag('div', { class: 'footer-row-cell-description' }, rowText);
const footerRowCellClass = isCheckmark ? 'footer-row-cell-checkmark' : 'footer-row-cell';
const footerRowIconClass = isCheckmark ? 'footer-row-icon-checkmark' : 'footer-row-icon';
const footerRowCell = createTag('div', { class: footerRowCellClass });

if (rowIcon) {
rowIcon.classList.add(footerRowIconClass);
footerRowCell.appendChild(rowIcon);
}
footerRowCell.appendChild(rowTextParagraph);

return footerRowCell;
};

const decorateFooterRows = (merchCard, footerRows) => {
if (!footerRows) return;

const footerRowsSlot = createTag('div', { slot: 'footer-rows' });
const isCheckmark = merchCard.classList.contains('checkmark');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace checkmark with a more business/functional term

const isMobile = window.matchMedia('(max-width: 1199px)').matches;

if (isCheckmark) {
const firstRow = footerRows[0];
const bgStyle = firstRow.querySelector('div > div:first-child').innerHTML;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use "#E8E8E8" as default

const hrElem = createTag('hr', { style: `background: ${bgStyle};` });
footerRowsSlot.appendChild(hrElem);
merchCard.classList.add('has-divider');

const checkmarkCopyContainer = createTag('div', { class: 'checkmark-copy-container' });
const firstRowTextParagraph = createFirstRow(firstRow, isMobile, checkmarkCopyContainer);

footerRowsSlot.appendChild(firstRowTextParagraph);
footerRowsSlot.appendChild(checkmarkCopyContainer);

footerRows.splice(0, 1);
footerRowsSlot.style.padding = '0px var(--consonant-merch-spacing-s)';
footerRowsSlot.style.marginBlockEnd = 'var(--consonant-merch-spacing-xs)';
}

footerRows.forEach((row) => {
const footerRowCell = createFooterRowCell(row, isCheckmark);
if (isCheckmark) {
footerRowsSlot.querySelector('.checkmark-copy-container').appendChild(footerRowCell);
} else {
footerRowsSlot.appendChild(footerRowCell);
}
});

merchCard.appendChild(footerRowsSlot);
};

const setMiniCompareOfferSlot = (merchCard, offers) => {
Expand Down
143 changes: 97 additions & 46 deletions libs/deps/mas/mas.js

Large diffs are not rendered by default.

Loading