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-142267: Merch What's Included and Merch Mnemonic List (TwP) #2554

Merged
merged 20 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions libs/blocks/merch-card/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ const parseTwpContent = async (el, merchCard) => {
const content = group.filter((e) => e.tagName.toLowerCase() === 'p' || e.tagName.toLowerCase() === 'ul');
const bodySlot = createTag('div', { slot: 'body-xs' }, content);
merchCard.append(bodySlot);

const whatsIncludedLink = bodySlot.querySelector('a[href*="merch-whats-included"]');
if (whatsIncludedLink) {
whatsIncludedLink.classList.add('merch-whats-included');
}
} else if (index === 2) { // Footer section
const footerContent = group.filter((e) => ['h5', 'p'].includes(e.tagName.toLowerCase()));
const footer = createTag('div', { slot: 'footer' }, footerContent);
Expand Down
3 changes: 3 additions & 0 deletions libs/blocks/merch-mnemonic-list/merch-mnemonic-list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.merch-mnemonic-list {
display: contents;
}
21 changes: 21 additions & 0 deletions libs/blocks/merch-mnemonic-list/merch-mnemonic-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import '../../deps/merch-mnemonic-list.js';
import '../../deps/merch-card.js';
import { createTag } from '../../utils/utils.js';

const init = async (el) => {
const rows = el.querySelectorAll(':scope p:not([class])');
if (rows.length < 1) return;
[...rows].forEach((paragraph) => {
const merchMnemonicList = createTag('merch-mnemonic-list');
paragraph.setAttribute('slot', 'description');
const picture = paragraph.querySelector('picture');
const img = picture.querySelector('img');
const icon = createTag('merch-icon', { slot: 'icon', size: 's', src: img.src });
picture.remove();
if (icon) merchMnemonicList.appendChild(icon);
if (paragraph) merchMnemonicList.appendChild(paragraph);
el.appendChild(merchMnemonicList);
});
};

export default init;
20 changes: 20 additions & 0 deletions libs/blocks/merch-twp/merch-twp.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@
content.querySelector('h4').setAttribute('slot', 'detail-xl');
twp.append(...[...content.querySelectorAll(':scope > h4, merch-card')]);

const whatsIncludedFragment = el.querySelector('.fragment[data-path*="merch-whats-included"]');
if (whatsIncludedFragment) {
const whatsIncludedSlot = createTag(
'div',
{
slot: 'merch-whats-included',
class: 'hidden merch-whats-included-container',
},
whatsIncludedFragment,
);
twp.append(whatsIncludedSlot);
Comment on lines +83 to +85
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
whatsIncludedFragment,
);
twp.append(whatsIncludedSlot);
whatsIncludedFragment,
{ parent : twp },
);

Copy link
Contributor

Choose a reason for hiding this comment

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

addressed

window.addEventListener('milo:modal:closed', (event) => {
// Check if whatsIncludedSlot has the 'hidden' class
if (!whatsIncludedSlot.classList.contains('hidden')) {
event.preventDefault(); // Prevent the default behavior of the event
whatsIncludedSlot.classList.toggle('hidden'); // Toggle the 'hidden' class on whatsIncludedSlot
}
});
}

Check warning on line 93 in libs/blocks/merch-twp/merch-twp.js

View check run for this annotation

Codecov / codecov/patch

libs/blocks/merch-twp/merch-twp.js#L77-L93

Added lines #L77 - L93 were not covered by tests

const cciFooter = createTag('div', { slot: 'cci-footer' });
cciFooter.append(...[...content.querySelectorAll('p:not(hr ~ p)')]);
const cctFooter = createTag('div', { slot: 'cct-footer' });
Expand Down
21 changes: 21 additions & 0 deletions libs/blocks/merch-whats-included/merch-whats-included.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.merch-whats-included-container > .fragment {
width: inherit;
height: inherit;
}

.merch-whats-included-container .fragment .container {
display: grid;
grid-auto-flow: column;
width: auto;
}

@media screen and (max-width: 767px) {
.merch-whats-included-container {
position: fixed;
overflow: hidden scroll;
}

.merch-whats-included-container .fragment .container {
grid-auto-flow: row;
}
}
30 changes: 30 additions & 0 deletions libs/blocks/merch-whats-included/merch-whats-included.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import '../../deps/merch-whats-included.js';
import { createTag } from '../../utils/utils.js';

const init = async (el) => {
const styles = Array.from(el.classList);
const mobileRows = styles.find((style) => /\d/.test(style));
const heading = el.querySelector('h3, h4');
const content = el.querySelector('.section');

const contentSlot = createTag(
'div',
{ slot: 'content' },
content.innerHTML,
);
const whatsIncluded = createTag(
'merch-whats-included',
{ mobileRows: mobileRows || 1 },
);
if (heading) {
heading.setAttribute('slot', 'heading');
whatsIncluded.appendChild(heading);
}

whatsIncluded.appendChild(contentSlot);
const divsWithoutClass = contentSlot.querySelectorAll('div:not([class])');
divsWithoutClass.forEach((div) => div.remove());
el.replaceWith(whatsIncluded);
};

export default init;
48 changes: 48 additions & 0 deletions libs/deps/merch-mnemonic-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// branch: MWPW-142267 commit: db56fa6d1f49aa580f3da94842ffb9e73516ee18 Mon, 08 Jul 2024 21:06:50 GMT

Check warning on line 1 in libs/deps/merch-mnemonic-list.js

View workflow job for this annotation

GitHub Actions / Running eslint

[eslint] reported by reviewdog 🐶 File ignored because of a matching ignore pattern. Use "--no-ignore" to override. Raw Output: {"fatal":false,"severity":1,"message":"File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."}
Copy link
Contributor

Choose a reason for hiding this comment

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

since this PR was already merged in mas repository these files should now be regenerated from /main branch

Copy link
Member Author

@Axelcureno Axelcureno Jul 11, 2024

Choose a reason for hiding this comment

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

Fixed


// src/merch-mnemonic-list.js
import { html, css, LitElement } from "/libs/deps/lit-all.min.js";
var MerchMnemonicList = class extends LitElement {
static styles = css`
:host {
display: flex;
flex-direction: row;
gap: 10px;
margin-bottom: 10px;
align-items: flex-end;
}

::slotted([slot='icon']) {
display: flex;
justify-content: center;
align-items: center;
height: max-content;
}

::slotted([slot='description']) {
font-size: 14px;
line-height: 21px;
margin: 0;
}

:host .hidden {
display: none;
}
`;
static properties = {
description: { type: String, attribute: true }
};
constructor() {
super();
}
render() {
return html`
<slot name="icon"></slot>
<slot name="description">${this.description}</slot>
`;
}
};
customElements.define("merch-mnemonic-list", MerchMnemonicList);
export {
MerchMnemonicList
};
Loading
Loading