Skip to content

Commit

Permalink
Revert "MWPW-142130: update the source of merch card name" (#1927)
Browse files Browse the repository at this point in the history
Revert "MWPW-142130: update the source of merch card name (#1883)"

This reverts commit f5e68ff.
  • Loading branch information
yesil committed Feb 26, 2024
1 parent f5e68ff commit 3f1b6c9
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 32 deletions.
110 changes: 102 additions & 8 deletions libs/blocks/merch-card/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,102 @@ import { processTrackingLabels } from '../../martech/attributes.js';
import { replaceKey } from '../../features/placeholders.js';
import '../../deps/merch-card.js';

const PRODUCT_NAMES = [
'acrobat-pdf-pack',
'acrobat-pro-2020',
'acrobat-reader-dc-mobile',
'acrobat-reader-dc',
'acrobat-sign-solutions-mobile',
'acrobat-sign-solutions',
'acrobat-standard-2020',
'acrobat-standard-dc',
'acrobat',
'adobe-connect',
'adobe-export-pdf',
'adobe-firefly',
'adobe-scan',
'advertising-cloud',
'aero',
'aftereffects',
'analytics',
'animate',
'audience-manager',
'audition',
'behance',
'bridge',
'campaign',
'captivate-prime',
'captivate',
'capture',
'all-apps',
'express',
'character-animator',
'cloud-service',
'coldfusion-aws',
'coldfusion-builder',
'coldfusion-enterprise',
'coldfusion',
'color',
'commerce-cloud',
'content-server',
'customer-journey-analytics',
'design-to-print',
'digital-editions',
'dreamweaver',
'embedded-print-engine',
'experience-manager-assets',
'experience-manager-forms',
'experience-manager-sites',
'experience-manager',
'experience-platform',
'fill-sign',
'fonts',
'frame',
'framemaker-publishing-server',
'framemaker',
'fresco',
'http-dynamic-streaming',
'illustrator',
'incopy',
'indesign-server',
'indesign',
'intelligent-services',
'journey-orchestration',
'lightroom-classic',
'lightroom',
'magento',
'marketo',
'media-encoder',
'media-server-aws',
'media-server-extended',
'media-server-professional',
'media-server-standard',
'mixamo',
'pdf-print-engine',
'pepe',
'photoshop-elements',
'photoshop-express',
'photoshop',
'portfolio',
'postscript',
'premiere-elements',
'premierepro',
'presenter-video-express',
'real-time-customer-data-platform',
'robohelp-server',
'robohelp',
'stock',
'substance-3d-designer',
'substance-3d-modeler',
'substance-3d-painter',
'substance-3d-sampler',
'substance-3d-stager',
'target',
'technical-communication-suite',
'type',
'xml-documentation',
];

const TAG_PATTERN = /^[a-zA-Z0-9_-]+:[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-].*$/;

const CARD_TYPES = ['segment', 'special-offers', 'plans', 'catalog', 'product', 'inline-heading', 'image', 'mini-compare-chart'];
Expand Down Expand Up @@ -247,6 +343,8 @@ const setMiniCompareOfferSlot = (merchCard, offers) => {

const init = async (el) => {
const styles = [...el.classList];
const lastClass = styles[styles.length - 1];
const name = PRODUCT_NAMES.includes(lastClass) ? lastClass : undefined;
const cardType = getPodType(styles) || 'product';
if (!styles.includes(cardType)) {
styles.push(cardType);
Expand All @@ -273,15 +371,11 @@ const init = async (el) => {
if (el.dataset.removedManifestId) {
merchCard.dataset.removedManifestId = el.dataset.removedManifestId;
}
if (name) {
merchCard.setAttribute('name', name);
}
let tags = {};
if (el.lastElementChild?.previousElementSibling?.querySelector('h3,h3,h4,h5,h6')) {
// tag section is available
const nameSelector = 'h3,h4,h5,h6';
const nameEl = el.lastElementChild.querySelector(nameSelector);
if (nameEl) {
merchCard.setAttribute('name', nameEl.textContent?.trim());
nameEl.remove();
}
if (el.lastElementChild) {
tags = extractTags(el.lastElementChild);
if (tags.categories?.length > 1 || tags.types?.length > 0) {
// this div contains tags, remove it from further processing.
Expand Down
26 changes: 13 additions & 13 deletions libs/blocks/merch-cards/merch-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const fail = (el, err = '') => {
};

/**
* Removes merch cards from the DOM if they are not meant to be displayed for the given filter.
* Removes merch cards from the DOM if they are not meant to be displayed in this merch cards block.
* @param {*} merchCards merch-cards element
*/
export function filterMerchCards(merchCards, filtered) {
Expand Down Expand Up @@ -113,9 +113,9 @@ async function initMerchCards(config, type, filtered, el, preferences) {
const preference = preferences[key];
if (!preference) return;
preference
.forEach(([sortKey, cardSize], index) => {
if (merchCard.name === sortKey || merchCard.title === sortKey) {
filters[key] = { order: index + 1, size: cardSize };
.forEach(([cardTitle, cardSize], index) => {
if (merchCard.title === cardTitle) {
filters[key] = { order: index, size: cardSize };
}
});
});
Expand All @@ -134,12 +134,12 @@ export default async function init(el) {
return fail(el, 'Missing queryIndexCardPath config');
}

const { base } = getConfig();
const { miloLibs } = getConfig();
const merchStyles = new Promise((resolve) => {
loadStyle(`${base}/blocks/merch/merch.css`, resolve);
loadStyle(`${miloLibs}/blocks/merch/merch.css`, resolve);
});
const merchCardStyles = new Promise((resolve) => {
loadStyle(`${base}/blocks/merch-card/merch-card.css`, resolve);
loadStyle(`${miloLibs}/blocks/merch-card/merch-card.css`, resolve);
});
const allStyles = Promise.all([merchStyles, merchCardStyles]);

Expand All @@ -150,12 +150,12 @@ export default async function init(el) {

if (!filtered) {
await Promise.all([
import(`${base}/features/spectrum-web-components/dist/theme.js`),
import(`${base}/features/spectrum-web-components/dist/button.js`),
import(`${base}/features/spectrum-web-components/dist/search.js`),
import(`${base}/features/spectrum-web-components/dist/overlay.js`),
import(`${base}/features/spectrum-web-components/dist/menu.js`),
import(`${base}/features/spectrum-web-components/dist/popover.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/theme.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/button.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/search.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/overlay.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/menu.js`),
import(`${miloLibs}/features/spectrum-web-components/dist/popover.js`),
]);
}

Expand Down
4 changes: 2 additions & 2 deletions libs/deps/merch-card.js

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

1 change: 0 additions & 1 deletion test/blocks/merch-card/merch-card.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ describe('Catalog Card', () => {
it('Parses the filters and types', async () => {
document.body.innerHTML = await readFile({ path: './mocks/catalog.html' });
const merchCard = await init(document.querySelector('.merch-card.catalog.tags'));
expect(merchCard.name).equal('photoshop');
expect(merchCard.filters).to.be.deep.equal({
all: { order: undefined, size: undefined },
'creativity-design': { order: undefined, size: undefined },
Expand Down
1 change: 0 additions & 1 deletion test/blocks/merch-card/mocks/catalog.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ <h5>Desktop + Mobile</h5>
</div>
<div>
<div data-valign="middle">
<h3>photoshop</h3>
<p>catalog:categories/creativity-design</p>
<p>catalog:categories/creativity-design/graphic-design</p>
<p>catalog:categories/creativity-design/photo</p>
Expand Down
11 changes: 4 additions & 7 deletions test/blocks/merch-cards/mocks/merch-cards.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div>
<div>
<p><strong>Photoshop</strong></p>
<p>all-apps</p>
<p>Creative Cloud All Apps</p>
<p>Express</p>
</div>
</div>
Expand Down Expand Up @@ -132,30 +132,27 @@
</div>

<div id="cards">
<div class="merch-card catalog">
<div class="merch-card catalog express">
<div>
<h3>Adobe Express</h3>
</div>
<div>
<h3>express</h3>
<p>catalog:categories/creativity-design/photo</p>
</div>
</div>
<div class="merch-card catalog">
<div class="merch-card catalog photoshop">
<div>
<h3>Photoshop</h3>
</div>
<div>
<h3>photoshop</h3>
<p>catalog:categories/creativity-design/photo</p>
</div>
</div>
<div class="merch-card catalog">
<div class="merch-card catalog all-apps">
<div>
<h3>Creative Cloud All Apps</h3>
</div>
<div>
<h3>all-apps</h3>
<p>catalog:categories/creativity-design/photo</p>
<p>catalog:categories/creativity-design/video</p>
</div>
Expand Down

0 comments on commit 3f1b6c9

Please sign in to comment.