-
Notifications
You must be signed in to change notification settings - Fork 174
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
base: stage
Are you sure you want to change the base?
Changes from 7 commits
6c6d3c9
4c51f63
8a6c32e
d725219
f0a65a6
62e2ec2
37b70b4
8dfa0e9
daadcbb
eb4ba26
5105249
8e8ce9c
7587c16
28fbaea
19f887a
5254abf
4407f37
08f60ba
02e75a4
b465d1c
83b3004
9bc6065
dc5ee8e
11ee7bd
ef3f6cd
4472303
5a56237
16dee1a
f02ae16
882af05
6c7342b
4deca34
e679d79
385903e
4883637
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'; | ||
import '../../deps/mas/merch-card.js'; | ||
import '../../deps/lit-all.min.js'; | ||
|
||
|
@@ -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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) => { | ||
|
Large diffs are not rendered by default.
There was a problem hiding this comment.
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