Skip to content

Commit

Permalink
slots, styles and basic layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Axelcureno committed Sep 18, 2024
1 parent 29a16b0 commit cd361b9
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 26 deletions.
1 change: 1 addition & 0 deletions libs/features/mas/web-components/src/global.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ styles.innerHTML = `
--consonant-merch-card-border-color: #eaeaea;
--color-accent: #1473E6;
--merch-color-focus-ring: #1473E6;
--merch-color-grey-60: #6D6D6D;
--merch-color-grey-80: #2c2c2c;
--merch-color-green-promo: #2D9D78;
Expand Down
34 changes: 15 additions & 19 deletions libs/features/mas/web-components/src/variants/ccd-suggested.css.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,28 @@ export const CSS = `
grid-template-columns: var(--consonant-merch-card-ccd-suggested-width);
}
merch-card[variant="ccd-suggested"] [slot='heading-xxs'] {
merch-card[variant="ccd-suggested"] [slot='detail-m'] {
color: var(--merch-color-grey-60);
}
merch-card[variant="ccd-suggested"] [slot='icons'] {
flex-flow: wrap;
place-self: flex-start;
}
merch-card[variant="ccd-suggested"] [slot='heading-xs'] {
font-size: var(--consonant-merch-card-heading-xxs-font-size);
line-height: var(--consonant-merch-card-heading-xxs-line-height);
}
merch-card[variant="ccd-suggested"] [slot='body-s'] a:not(.con-button) {
font-size: var(--consonant-merch-card-body-xxs-font-size);
font-style: normal;
font-weight: 400;
line-height: var(--consonant-merch-card-body-xxs-line-height);
text-decoration-line: underline;
color: var(--merch-color-grey-80);
}
merch-card[variant="ccd-suggested"] [slot='image'] {
display: flex;
justify-content: center;
flex-shrink: 0;
width: var(--consonant-merch-card-ccd-suggested-background-img-size);
height: var(--consonant-merch-card-ccd-suggested-background-img-size);
overflow: hidden;
border-radius: 50%;
padding: var(--consonant-merch-spacing-xs);
align-self: center;
merch-card[variant="ccd-suggested"] [slot='cta'] a {
text-decoration: none;
color: var(--merch-color-grey-60);
font-weight: 500;
}
@media screen and ${TABLET_UP} {
.two-merch-cards.ccd-suggested,
.three-merch-cards.ccd-suggested,
Expand Down
48 changes: 41 additions & 7 deletions libs/features/mas/web-components/src/variants/ccd-suggested.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class CCDSuggested extends VariantLayout {
get stripStyle() {
if (this.strip && this.stripBackground) {
return `
background: ${this.stripBackground};
background: ${this.stripBackground};
background-size: ${this.strip} 100%;
background-repeat: no-repeat;
background-position: left;
Expand All @@ -28,24 +28,58 @@ export class CCDSuggested extends VariantLayout {
}

renderLayout () {
return html`${this.cardImage}
return html`
<div style="${this.stripStyle}" class="body">
<slot name="icons"></slot>
<slot name="detail-m"></slot>
<slot name="heading-xs"></slot>
<div class="top-secton">
<slot name="icons"></slot>
<div class="header">
<slot name="detail-m"></slot>
<slot name="heading-xs"></slot>
</div>
</div>
<slot name="body-xs"></slot>
<slot name="footer"></slot>
<div class="footer">
<slot name="price"></slot>
<slot name="cta"></slot>
</div>
</div>
<slot></slot>`;
}

static variantStyle = css`
:host([variant='ccd-suggested']) {
width: var(--consonant-merch-card-ccd-suggested-width);
height: var(--consonant-merch-card-ccd-suggested-height);
min-height: var(--consonant-merch-card-ccd-suggested-height);
border-radius: 4px;
display: flex;
flex-flow: wrap;
}
:host([variant='ccd-suggested']) .body {
height: auto;
}
:host([variant='ccd-suggested']) .top-secton {
display: flex;
flex-flow: wrap;
place-self: flex-start;
}
:host([variant='ccd-suggested']) .header {
padding-inline-start: var(--consonant-merch-spacing-xxs);
}
:host([variant='ccd-suggested']) slot[name='detail-m'] {
flex-flow: wrap;
place-self: flex-start;
}
:host([variant='ccd-suggested']) .footer {
display: flex;
justify-content: space-between;
flex-grow: 1;
margin-top: auto;
align-items: flex-end;
}
`;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Merch Card CCD Suggested Web Component demo page</title>
<script>
window.process = {
env: {},
};
</script>
<style>
main {
display: flex;
align-items: center;
gap: 20px;
flex-direction: column;
padding-top: 80px;
}

main>div {
display: initial;
}

.action-area {
display: contents;
}

#sidenav {
display: none;
}

@media screen and (min-width: 1440px) {
#sidenav {
flex: 1;x
justify-content: stretch;
padding-top: 8px;
display: flex;
position: fixed;
bottom: 0px;
left: 0px;
gap: 20px;
flex-direction: column;
width: 220px;
}
}
</style>
</head>

<body>
<script type="module" src="./merch-card.ccd-suggested.test.html.js"></script>
<main>
<div id="sidenav">
<button onclick="toggleRTL()">Toggle RTL</button>
<button onclick="skipTests()">Skip tests</button>
<button onclick="runTests()">Run tests</button>
</div>
<div class="one-merch-card ccd-suggested">
<merch-card class="" tabindex="0" variant="ccd-suggested" filters="" types="">
<sp-status-light size="l" variant="info" dir="ltr"></sp-status-light>
<merch-icon
slot="icons"
src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/photoshop.svg"
alt=""
href=""
size="l"
>undefined</merch-icon
>
<merch-icon
slot="icons"
src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/lightroom.svg"
alt=""
href=""
size="l"
>undefined</merch-icon
>
<p slot="detail-m">YOUR EXPIRED PLAN</p>
<p slot="heading-xs"><strong>Photography plan (20GB)</strong></p>
<p slot="body-xs">
Creative Cloud Photography plan.<br>
Starting at US$19.99/mo
</p>
<div slot="price">
<span
is="inline-price"
data-display-old-price="true"
data-display-per-unit="false"
data-promotion-code=""
data-quantity="1"
data-template="price"
data-wcs-osi="r_JXAnlFI7xD6FxWKl2ODvZriLYBoSL701Kd1hRyhe8"
class="placeholder-resolved"
><span class="price" aria-label="US$35.99 per month"
><span class="price-currency-symbol">US$</span
><span class="price-currency-space disabled"></span
><span class="price-integer">35</span
><span class="price-decimals-delimiter">.</span
><span class="price-decimals">99</span
><span class="price-recurrence">/mo</span
><span class="price-unit-type disabled"></span
><span class="price-tax-inclusivity disabled"></span>
</span
></span>
</div>
<div slot="cta">
<a
is="checkout-link"
data-checkout-workflow="UCv3"
data-checkout-workflow-step="segmentation"
data-promotion-code="CCI2AAUSQ22440CH"
data-quantity="1"
data-wcs-osi="r_JXAnlFI7xD6FxWKl2ODvZriLYBoSL701Kd1hRyhe8"
data-extra-options="{}"
><span>Buy now</span></a
>
</div>
</merch-card>
</div>
<div class="one-merch-card ccd-suggested-strip">
<merch-card strip-size="wide" strip-background="./img/strip-wide.png" tabindex="0" variant="ccd-suggested" filters="" types="">
<sp-status-light size="l" variant="info" dir="ltr"></sp-status-light>
<merch-icon
slot="icons"
src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/photoshop.svg"
alt=""
href=""
size="l"
>undefined</merch-icon
>
<merch-icon
slot="icons"
src="https://www.adobe.com/content/dam/shared/images/product-icons/svg/lightroom.svg"
alt=""
href=""
size="l"
>undefined</merch-icon
>
<p slot="detail-m">YOUR EXPIRED PLAN</p>
<p slot="heading-xs"><strong>Photography plan (20GB)</strong></p>
<p slot="body-xs">
Creative Cloud Photography plan.<br>
Starting at US$19.99/mo
</p>
<div slot="price">
<span
is="inline-price"
data-display-old-price="true"
data-display-per-unit="false"
data-promotion-code=""
data-quantity="1"
data-template="price"
data-wcs-osi="r_JXAnlFI7xD6FxWKl2ODvZriLYBoSL701Kd1hRyhe8"
class="placeholder-resolved"
><span class="price" aria-label="US$35.99 per month"
><span class="price-currency-symbol">US$</span
><span class="price-currency-space disabled"></span
><span class="price-integer">35</span
><span class="price-decimals-delimiter">.</span
><span class="price-decimals">99</span
><span class="price-recurrence">/mo</span
><span class="price-unit-type disabled"></span
><span class="price-tax-inclusivity disabled"></span></span
></span
>
</div>
<div slot="cta">
<a
is="checkout-link"
data-checkout-workflow="UCv3"
data-checkout-workflow-step="segmentation"
data-promotion-code="CCI2AAUSQ22440CH"
data-quantity="1"
data-wcs-osi="r_JXAnlFI7xD6FxWKl2ODvZriLYBoSL701Kd1hRyhe8"
data-extra-options="{}"
><span>Buy now</span></a
>
</div>
</merch-card>
</div>
</main>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// @ts-nocheck
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';

import { mockLana } from './mocks/lana.js';
import { mockFetch } from './mocks/fetch.js';
import { mockConfig } from './mocks/config.js';

import { appendMiloStyles, delay } from './utils.js';
import { mockIms } from './mocks/ims.js';
import { withWcs } from './mocks/wcs.js';
import mas from './mas.js';

const skipTests = sessionStorage.getItem('skipTests');

runTests(async () => {
mockIms();
mockLana();
await mockFetch(withWcs);
await mas();

describe('merch-card web component', () => {
it('should exist in the HTML document', async () => {
expect(document.querySelector('merch-card[variant="ccd-slice"]')).to.exist;
});

it('should display a CTA', async () => {
const ccdSliceCard = document.querySelector(
'merch-card[variant="ccd-slice"]',
);
const shadowRoot = ccdSliceCard.shadowRoot;
const cta = ccdSliceCard.querySelector('.con-button');
expect(cta).to.exist;
});

it('should have correct attributes for the ccd-slice wide card', async () => {
const ccdSliceWideCard = document.querySelector('merch-card[variant="ccd-slice"][size="wide"]');
expect(ccdSliceWideCard.getAttribute('variant')).to.equal('ccd-slice');
expect(ccdSliceWideCard.getAttribute('size')).to.equal('wide');
});

it('should display a CTA in the ccd-slice wide card', async () => {
const ccdSliceWideCard = document.querySelector('merch-card[variant="ccd-slice"][size="wide"]');
const cta = ccdSliceWideCard.querySelector('.con-button');
expect(cta).to.exist;
});
});

});

0 comments on commit cd361b9

Please sign in to comment.