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

Add subscriptions-message-number to SwG smartbox button #28213

Merged
merged 2 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,16 @@
<div class="brand-logo">
PublisherLogo - Subscriptions Demo
</div>
<p>You need to append "#swg.experiments=smartbox" at the end of the URL and then refresh.</p>
</header>





<h3>"Smart Button (Light)"</h3>

<button id="smartboxButton" subscriptions-display="NOT loggedIn"
subscriptions-lang="en"
subscriptions-action="subscribe-smartbutton"
subscriptions-service="subscribe.google.com"
subscriptions-message-number="1"
subscriptions-decorate>Yes I will Contribute</button>

<h3>"Smart Button (Dark)"</h3>
Expand All @@ -235,6 +233,7 @@ <h3>"Smart Button (Dark)"</h3>
subscriptions-lang="en"
subscriptions-action="subscribe-smartbutton-dark"
subscriptions-service="subscribe.google.com"
subscriptions-message-number="1"
subscriptions-decorate>Yes I will Contribute</button>

<h3>"Smart Button (Dark w/ custom message text color)"</h3>
Expand All @@ -244,8 +243,8 @@ <h3>"Smart Button (Dark w/ custom message text color)"</h3>
subscriptions-action="subscribe-smartbutton-dark"
subscriptions-service="subscribe.google.com"
subscriptions-message-text-color="rgba(0, 120, 255, 0.95)"
subscriptions-message-number="1"
subscriptions-decorate>Yes I will Contribute</button>


</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ export class GoogleSubscriptionsPlatform {
if (messageTextColor) {
opts.messageTextColor = messageTextColor;
}
const messageNumber = element.getAttribute(
'subscriptions-message-number'
);
if (messageNumber) {
opts.messageNumber = messageNumber;
}
this.runtime_.attachSmartButton(element, opts, () => {});
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,20 @@ describes.realWin('amp-subscriptions-google', {amp: true}, (env) => {
});
});

it('should use message number', () => {
const elem = env.win.document.createElement('div');
const attachStub = env.sandbox.stub(platform.runtime_, 'attachSmartButton');
elem.textContent = 'some html';
elem.setAttribute('subscriptions-lang', 'en');
elem.setAttribute('subscriptions-message-number', 1);
platform.decorateUI(elem, 'subscribe-smartbutton');
expect(attachStub).to.be.calledWith(elem, {
lang: 'en',
theme: 'light',
messageNumber: '1', // Message is 'Subscribe with just a few taps' on smartbox button.
});
});

it('should throw if smartButton language is missing', () => {
//expectAsyncConsoleError(/must have a language attrbiute​​​/);
const elem = env.win.document.createElement('div');
Expand Down