generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(MWPW-142267): Merch What's Included and Merch Mnemonic List (TwP)
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
1 parent
ecf0570
commit 7c78c1a
Showing
9 changed files
with
455 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.