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-147034: Custom border color + badge/border color decoupling [Mer… #15

Merged
merged 8 commits into from
Jul 23, 2024
Merged
17 changes: 12 additions & 5 deletions web-components/src/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class MerchCard extends LitElement {
variant: { type: String, reflect: true },
size: { type: String, attribute: 'size', reflect: true },
badgeColor: { type: String, attribute: 'badge-color' },
borderColor: { type: String, attribute: 'border-color' },
badgeBackgroundColor: {
type: String,
attribute: 'badge-background-color',
Expand Down Expand Up @@ -109,11 +110,8 @@ export class MerchCard extends LitElement {
#container;

updated(changedProperties) {
if (
changedProperties.has('badgeBackgroundColor') &&
this.variant !== 'twp'
) {
this.style.border = `1px solid ${this.badgeBackgroundColor}`;
if (changedProperties.has('badgeBackgroundColor') || changedProperties.has('borderColor')) {
this.style.border = this.computedBorderStyle;
}
this.updateComplete.then(async () => {
const prices = Array.from(
Expand All @@ -126,6 +124,15 @@ export class MerchCard extends LitElement {
});
}

get computedBorderStyle() {
if (this.variant !== 'twp') {
return `1px solid ${
this.borderColor ? this.borderColor : this.badgeBackgroundColor
}`;
}
return '';
}

get evergreen() {
return this.classList.contains('intro-pricing');
}
Expand Down
6 changes: 3 additions & 3 deletions web-components/test/merch-card.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,9 @@ <h4 slot="heading-xs">Acrobat Pro</h4>
</merch-card>
</div>
<div class="three-merch-cards segment">
<merch-card class="merch-card background-opacity-70 segment badge-card" variant="segment" size=""
badge-background-color="#2D9D78" badge-color="#fff" badge-text="Save a lot" filters="all" types="" tabindex="0"
style="border: 1px solid rgb(45, 157, 120);">
<merch-card class="merch-card background-opacity-70 segment badge-card custom-border-color" variant="segment" size=""
badge-background-color="#2D9D78" badge-color="#fff" badge-text="Save a lot" filters="all" types="" tabindex="0" border-color="#1473E6"
style="border: 1px solid rgb(20, 115, 230);">
<h3 id="merch-card-background-opacity-70-segment" class="card-heading" slot="heading-xs">merch-card aaa bbbccc dddeee bbbccc dddeee</h3>
<div slot="body-xs">
<h5 id="this-is-the-green-promo-text-with-link">This is the green promo text with <a href="https://www.adobe.com">link</a>!</h5>
Expand Down
7 changes: 7 additions & 0 deletions web-components/test/merch-card.test.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,11 @@ runTests(async () => {
).title;
expect(title).to.equal('Individuals');
});

it('should have custom border color for segment card', async () => {
const segmentCard = document.querySelector('merch-card[variant="segment"].custom-border-color');
const borderColor = segmentCard.getAttribute('border-color');
expect(borderColor).to.exist;
expect(borderColor).to.not.equal('');
});
});