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-158053: CCD Slice Card [Merch card] #2878

Merged
merged 26 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
03778dd
MWPW-156612 fragment merch-card variant layouts
npeltier Aug 29, 2024
7ead9eb
MWPW-156612 changing title selector
npeltier Aug 31, 2024
a8ab869
MWPW-156612 forking style insertion
npeltier Sep 1, 2024
b9580d5
MWPW-156612 styles fixes
npeltier Sep 1, 2024
6df1623
MWPW-156612 review comments
npeltier Sep 3, 2024
6c3cb8f
Merge branch 'stage' of github.com:adobecom/milo into MWPW-156612
npeltier Sep 7, 2024
5ad2935
MWPW-156612 fixing unit tests
npeltier Sep 9, 2024
9aa3eee
initial commit
Axelcureno Sep 12, 2024
bc3ae26
Merge branch 'stage' into MWPW-158053
Axelcureno Sep 12, 2024
49b3acd
MWPW-158053: CCD Slide Card
Axelcureno Sep 13, 2024
950c3ae
RTL alignment
Axelcureno Sep 16, 2024
ed4137a
ccd slice card added to merch-datasource libs
Axelcureno Sep 16, 2024
afaf7ff
review comments addressed
Axelcureno Sep 18, 2024
95698c4
so long, milo styles
Axelcureno Sep 18, 2024
ae57a05
decluttered html test page
Axelcureno Sep 18, 2024
3a656a7
spectrum ctas in test file
Axelcureno Sep 19, 2024
8273f59
removed images and added pixel png
Axelcureno Sep 19, 2024
cdb6c8c
removed dead code
Axelcureno Sep 19, 2024
f30355d
Update merch-card.ccd-slice.test.html.js
Axelcureno Sep 19, 2024
f84c67c
Update merch-twp-d2p.test.html
Axelcureno Sep 19, 2024
b174f0d
Update ccd-slice.js
Axelcureno Sep 24, 2024
3e9ed08
Merge branch 'stage' into MWPW-158053
Axelcureno Sep 24, 2024
2b04688
Update merch-datasource.js
Axelcureno Sep 24, 2024
17a18a1
Merge branch 'stage' into MWPW-158053
Axelcureno Sep 24, 2024
1139b0f
inherited width of images
Axelcureno Sep 24, 2024
c3289a7
updated deps
Axelcureno Sep 24, 2024
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
214 changes: 149 additions & 65 deletions libs/deps/mas/merch-card.js
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/deps/mas/merch-datasource.js
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions libs/features/mas/web-components/src/merch-datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const VARIANTS = {
AH: 'ah',
CCD_ACTION: 'ccd-action',
SPECIAL_OFFERS: 'special-offers',
CCD_SLICE: 'ccd-slice',
};

const cardContent = {
Expand Down Expand Up @@ -35,6 +36,11 @@ const cardContent = {
description: { tag: 'div', slot: 'body-xs' },
ctas: { size: 'l' },
},
[VARIANTS.CCD_SLICE]: {
backgroundImage: { tag: 'div', slot: 'image' },
description: { tag: 'div', slot: 'body-s' },
ctas: { size: 'l' },
},
};

async function parseMerchCard(fragmentData, appendFn, merchCard, consonant) {
Expand Down
23 changes: 23 additions & 0 deletions libs/features/mas/web-components/src/variants/ccd-slice.css.js
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export const CSS = `
:root {
--consonant-merch-card-ccd-slice-single-width: 322px;
--consonant-merch-card-ccd-slice-icon-size: 30px;
--consonant-merch-card-ccd-slice-wide-width: 600px;
--consonant-merch-card-ccd-slice-single-height: 154px;
--consonant-merch-card-ccd-slice-background-img-size: 119px;
}

merch-card[variant="ccd-slice"] [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-slice"] [slot='image'] img {
overflow: hidden;
border-radius: 50%;
}
`;
78 changes: 78 additions & 0 deletions libs/features/mas/web-components/src/variants/ccd-slice.js
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { VariantLayout } from './variant-layout.js';
import { html, css } from 'lit';
import { CSS } from './ccd-slice.css.js';

export class CCDSlice extends VariantLayout {

getGlobalCSS() {
return CSS;
}

renderLayout() {
return html` <div class="content">
<slot name="icons"></slot> ${this.badge}
<slot name="body-s"></slot>
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: this should be body-xs

Copy link
Contributor

Choose a reason for hiding this comment

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

or merch-datasource that should be body-s too :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I have fixed in merch-datasource, thank you.

<slot name="footer"></slot>
</div>
<slot name="image"></slot>
<slot></slot>`;
}

static variantStyle = css`
:host([variant='ccd-slice']) {
width: var(--consonant-merch-card-ccd-slice-single-width);
border-radius: 4px;
display: flex;
flex-flow: wrap;
}

:host([variant='ccd-slice']) ::slotted([slot='body-s']) {
font-size: var(--consonant-merch-card-body-xs-font-size);
line-height: var(--consonant-merch-card-body-xxs-line-height);
}

:host([variant='ccd-slice'][size='wide']) {
width: var(--consonant-merch-card-ccd-slice-wide-width);
}

:host([variant='ccd-slice']) .content {
display: flex;
gap: var(--consonant-merch-spacing-xxs);
padding: var(--consonant-merch-spacing-xs);
padding-inline-end: 0;
width: 154px;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
flex: 1 0 0;
}

:host([variant='ccd-slice']) ::slotted([slot='body-s']) ::slotted(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);
}

:host([variant='ccd-slice']) ::slotted([slot='image']) {
display: flex;
justify-content: center;
flex-shrink: 0;
width: var(--consonant-merch-card-ccd-slice-background-img-size);
height: var(--consonant-merch-card-ccd-slice-background-img-size);
overflow: hidden;
border-radius: 50%;
padding: var(--consonant-merch-spacing-xs);
align-self: center;
}

:host([variant='ccd-slice']) ::slotted([slot='image']) img {
overflow: hidden;
border-radius: 50%;
width: inherit;
height: inherit;
}
`;
}
4 changes: 4 additions & 0 deletions libs/features/mas/web-components/src/variants/variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Product } from './product.js';
import { Segment } from './segment.js';
import { SpecialOffer } from './special-offer.js';
import { TWP } from './twp.js';
import { CCDSlice } from './ccd-slice.js';

const getVariantLayout = (card, mustMatch = false) => {
switch (card.variant) {
Expand All @@ -31,6 +32,8 @@ const getVariantLayout = (card, mustMatch = false) => {
return new SpecialOffer(card);
case 'twp':
return new TWP(card);
case 'ccd-slice':
return new CCDSlice(card);
default:
return mustMatch ? undefined : new Product(card);
}
Expand All @@ -45,6 +48,7 @@ const getVariantStyles = () => {
styles.push(Segment.variantStyle);
styles.push(SpecialOffer.variantStyle);
styles.push(TWP.variantStyle);
styles.push(CCDSlice.variantStyle);
return styles;
};

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!DOCTYPE html>
<html lang="en">

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

</style>
</head>

<body>
<script type="module" src="./merch-card.ccd-slice.test.html.js"></script>
<main>
<sp-theme theme="spectrum" color="light" scale="medium">
<merch-card class="" tabindex="0" variant="ccd-slice" 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="body-s">
<strong>Creative Cloud Photography plan.<br>
Starting at US$19.99/mo
</strong>
</p>
<div slot="footer">
<sp-button size="s" focusable>Buy now</sp-button>
</div>
<div slot="image">
<img src="./img/pixel.png" alt="">
</div>
</merch-card
>
<merch-card size="wide" class="" tabindex="0" variant="ccd-slice" 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/creative-cloud.svg"
alt=""
href=""
size="l"
>undefined</merch-icon
>
<p slot="body-s">
<strong>Save over 30% on Creative Cloud All Apps. Register for MAX by August 31 and save US$200 on a full conference pass.</strong>
<br><a href="https://www.adobe.com/creativecloud/all-apps.html" target="_blank">See terms</a>
</p>
<div slot="footer">
<sp-button size="s" focusable>Register now</sp-button>
</div>
<div slot="image">
<img src="./img/pixel.png" alt="">
</div>
</merch-card>
</sp-theme>
</main>
</body>
</html>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// @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 './spectrum.js';
import '../src/merch-offer.js';
import '../src/merch-offer-select.js';
import '../src/merch-quantity-select.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 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');
});
});

});
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

</div>
<template id="merch-twp-d2p">
<sp-theme theme="spectrum" color="light" scale="large">
<sp-theme theme="spectrum" color="light" scale="large">
<sp-dialog-base slot="click-content" dismissable underlay no-divider>
<sp-icon-close-circle size="l"></sp-icon-close-circle>
<merch-twp-d2p>
Expand Down
Loading