Skip to content

Commit

Permalink
feat(MWPW-142267): Merch What's Included and Merch Mnemonic List (TwP)
Browse files Browse the repository at this point in the history
Introduces Merch What's Included and Merch Mnemonic List web components for TwP What's included screen.

Resolves: MWPW-142267

Test link: https://mwpw-142267--milo--adobecom.hlx.page/drafts/axel/block-samples/twp/illustrator#twpmodal
  • Loading branch information
Axelcureno committed Jun 20, 2024
1 parent ecf0570 commit 7c78c1a
Show file tree
Hide file tree
Showing 9 changed files with 455 additions and 4 deletions.
27 changes: 25 additions & 2 deletions web-components/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { execSync } from 'node:child_process';
const commitHash = execSync('git rev-parse HEAD').toString().trim();
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();

console.log(`you're building from branch ${branch} with commit ${commitHash}`);
console.log(
`Building from tacocat repository is DEPRECATED, please switch to the new 'mas' repository.`
);

const banner = {
js: `// branch: ${branch} commit: ${commitHash} ${new Date().toUTCString()}`,
js: `Building from tacocat repository is DEPRECATED, please switch to the new 'mas' repository.`,
};

async function buildLitComponent(name) {
Expand Down Expand Up @@ -78,11 +80,32 @@ Promise.all([
plugins: [rewriteImports()],
external: ['lit'],
}),
build({
entryPoints: ['./src/merch-whats-included.js'],
bundle: true,
banner,
outfile: './lib/merch-whats-included.js',
format: 'esm',
plugins: [rewriteImports()],
external: ['lit'],
}),
build({
entryPoints: ['./src/merch-mnemonic-list.js'],
bundle: true,
banner,
outfile: './lib/merch-mnemonic-list.js',
format: 'esm',
plugins: [rewriteImports()],
external: ['lit'],
}),
buildLitComponent('merch-icon'),
buildLitComponent('merch-quantity-select'),
buildLitComponent('merch-secure-transaction'),
buildLitComponent('merch-stock'),
buildLitComponent('merch-subscription-panel'),
buildLitComponent('merch-twp-d2p'),
buildLitComponent('merch-whats-included'),
buildLitComponent('merch-mnemonic-list'),
]).catch(() => process.exit(1));

function rewriteImports() {
Expand Down
47 changes: 47 additions & 0 deletions web-components/src/merch-mnemonic-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { html, css, LitElement } from 'lit';

export class MerchMnemonicList 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);
15 changes: 15 additions & 0 deletions web-components/src/merch-twp-d2p.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@ export const styles = css`
margin: 0;
}
::slotted([slot='merch-whats-included']) {
align-self: auto;
width: 100%;
position: absolute;
background: #fff;
height: 100%;
padding: 30px;
border-radius: 10px;
box-sizing: border-box;
}
::slotted([slot$='-footer']) {
flex-basis: 100%;
}
::slotted([slot='merch-whats-included'].hidden) {
display: none;
}
/* Mobile */
.mobile {
Expand Down
20 changes: 20 additions & 0 deletions web-components/src/merch-twp-d2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class MerchTwpD2P extends LitElement {
super();
this.step = 1;
this.#handleOfferSelected = this.handleOfferSelected.bind(this);
this.handleWhatsIncludedClick = this.handleWhatsIncludedClick.bind(this);
}

/** @type {Commerce.Log.Instance} */
Expand Down Expand Up @@ -311,6 +312,7 @@ export class MerchTwpD2P extends LitElement {
? this.mobileLayout
: this.desktopLayout
}
<slot name="merch-whats-included"></slot>
</div>
`;
}
Expand All @@ -327,6 +329,10 @@ export class MerchTwpD2P extends LitElement {
EVENT_MERCH_QUANTITY_SELECTOR_CHANGE,
this.handleQuantityChange
);
this.whatsIncludedLink?.addEventListener(
'click',
this.handleWhatsIncludedClick
);
this.addEventListener(
EVENT_MERCH_STORAGE_CHANGE,
this.handleStorageChange
Expand All @@ -340,6 +346,7 @@ export class MerchTwpD2P extends LitElement {
EVENT_OFFER_SELECTED,
this.#handleOfferSelected
);
this.whatsIncludedLink?.removeEventListener('click', this.handleWhatsIncludedClick);
this.removeEventListener(
EVENT_MERCH_STORAGE_CHANGE,
this.handleStorageChange
Expand All @@ -357,6 +364,14 @@ export class MerchTwpD2P extends LitElement {
this.requestUpdate();
}

get whatsIncludedLink() {
return this.querySelector('merch-card .merch-whats-included');
}

get whatsIncluded() {
return this.querySelector('[slot="merch-whats-included"]');
}

setOfferSelectOnPanel(offerSelect) {
offerSelect.setAttribute('variant', 'subscription-options');
this.subscriptionPanel.offerSelect?.remove();
Expand Down Expand Up @@ -424,6 +439,11 @@ export class MerchTwpD2P extends LitElement {
this.setOfferSelectOnPanel(offerSelect);
}

handleWhatsIncludedClick(event) {
event.preventDefault();
this.whatsIncluded?.classList.toggle('hidden');
}

async processCards() {
const allCards = [...this.querySelectorAll('merch-card')];
allCards.forEach((card, i) => {
Expand Down
100 changes: 100 additions & 0 deletions web-components/src/merch-whats-included.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { html, css, LitElement } from 'lit';

export class MerchWhatsIncluded extends LitElement {
static styles = css`
:host {
display: inline-grid;
place-items: end start;
grid-auto-flow: row;
width: auto;
overflow: hidden;
place-content: stretch start;
box-sizing: border-box;
align-self: baseline;
margin-top: 16px;
margin-bottom: 16px;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
grid-auto-rows: unset;
height: inherit;
}
::slotted([slot='heading']) {
grid-column: 1 / -1;
font-size: 18px;
margin: 0;
margin-bottom: 16px;
}
::slotted([slot='content']) {
display: contents;
}
.hidden {
display: none;
}
.see-more {
font-size: 14px;
text-decoration: underline;
color: var(--link-color-dark);
margin-top: 16px;
}
`;

static properties = {
heading: { type: String, attribute: true },
mobileRows: { type: Number, attribute: true },
};

updated() {
this.hideSeeMoreEls();
}

hideSeeMoreEls() {
if (this.isMobile) {
this.rows.forEach((node, index) => {
if (index >= 5) {
node.style.display = this.showAll ? 'flex' : 'none';
}
});
}
}

constructor() {
super();
this.showAll = false;
this.mobileRows = this.mobileRows === undefined ? 5 : this.mobileRows;
}

toggle() {
this.showAll = !this.showAll;

this.dispatchEvent(
new CustomEvent('hide-see-more-elements', {
bubbles: true,
composed: true,
})
);
this.requestUpdate();
}

render() {
return html`<slot name="heading"></slot>
<slot name="content"></slot>
${this.isMobile && this.rows.length > this.mobileRows
? html`<div @click=${this.toggle} class="see-more">
${this.showAll ? '- See less' : '+ See more'}
</div>`
: html``}`;
}

get isMobile() {
return window.matchMedia('(max-width: 767px)').matches;
}

get rows() {
return this.querySelectorAll('merch-mnemonic-list');
}
}

customElements.define('merch-whats-included', MerchWhatsIncluded);
94 changes: 92 additions & 2 deletions web-components/test/merch-twp-d2p.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,96 @@
<sp-icon-close-circle size="l"></sp-icon-close-circle>
<merch-twp-d2p>
<h4 slot="detail-xl">Try the full version of Adobe apps with a 7-day free trial.</h4>
<a slot="cci-footer" href="#cci" tabindex="0">See all plans and pricing</a>
<a slot="cct-footer" href="#cct" tabindex="0">See all plans and pricing</a>
<a slot="cce-footer" href="#cce" tabindex="0">See all plans and pricing</a>
<div id="merch-whats-included" slot="merch-whats-included" class="merch-whats-included hidden">
<sp-icon-close-circle name="close-whats-included"size="l"></sp-icon-close-circle>
<h3>What’s included with Creative Cloud All Apps</h3>
<p>Get the apps and services you need for all kinds of creative work, from photography and graphic design to video, UI/UX, and social media.</p>
<merch-whats-included>
<h3 slot="heading">Apps</h3>
<div slot="content">
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/photoshop.svg" alt="Photoshop"></merch-icon>
</div>
<p slot="description"><strong>Photoshop</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/illustrator.svg" alt="Illustrator"></merch-icon>
</div>
<p slot="description"><strong>Illustrator</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/premiere.svg" alt="Premiere Pro"></merch-icon>
</div>
<p slot="description"><strong>Premiere Pro</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/acrobat.svg" alt="Acrobat Pro"></merch-icon>
</div>
<p slot="description"><strong>Acrobat Pro</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/cc-express.svg" alt="Adobe Express"></merch-icon>
</div>
<p slot="description"><strong>Adobe Express</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/firefly.svg" alt="Adobe Firefly"></merch-icon>
</div>
<p slot="description"><strong>Firefly</strong></p>
</merch-mnemonic-list>
</div>
</merch-whats-included>
<merch-whats-included>
<h3 slot="heading">Membership perks</h3>
<div slot="content">
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/photoshop.svg" alt="Photoshop"></merch-icon>
</div>
<p slot="description"><strong>Adobe Fonts</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/illustrator.svg" alt="Illustrator"></merch-icon>
</div>
<p slot="description"><strong>Adobe Color</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/premiere.svg" alt="Premiere Pro"></merch-icon>
</div>
<p slot="description"><strong>Adobe Portfolio</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/acrobat.svg" alt="Acrobat Pro"></merch-icon>
</div>
<p slot="description"><strong>Behance</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/firefly.svg" alt="Adobe Firefly"></merch-icon>
</div>
<p slot="description"><strong>Creative Cloud libraries</strong></p>
</merch-mnemonic-list>
<merch-mnemonic-list>
<div slot="icon">
<merch-icon size="s" src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/cc-express.svg" alt="Adobe Express"></merch-icon>
</div>
<p slot="description">x,xxx monthly <u><a href="https://adobe.com">generative credits</a></u></p>
</merch-mnemonic-list>
</div>
</merch-whats-included>
</div>
</merch-twp-d2p>
</sp-dialog-base>
</sp-theme>
Expand Down Expand Up @@ -165,7 +255,7 @@ <h5 slot="header">
credits</a></li>
</ul>
<p>
<a href="https://adobe.com/">See all included apps.</a>
<a class="whats-included-link" href="#merch-whats-included">See all included apps.</a>
</p>
</div>
<div slot="footer">
Expand Down Expand Up @@ -242,7 +332,7 @@ <h5 slot="header">
credits</a></li>
</ul>
<p>
<a href="https://adobe.com/">See all included apps.</a>
<a href="#merch-whats-included">See all included apps.</a>
</p>
</div>
<div slot="footer">
Expand Down
Loading

0 comments on commit 7c78c1a

Please sign in to comment.