Skip to content

Commit 82c6b9f

Browse files
committed
Publish 2024-12-11
1 parent 6e1ddb5 commit 82c6b9f

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

elements/plus-tiers.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const Prices = {
5858
CNY: '¥68.00',
5959
AUD: '$14.99',
6060
},
61+
/*
6162
PLUS: {
6263
USD: '$4.99',
6364
GBP: '£3.99',
@@ -67,6 +68,16 @@ const Prices = {
6768
CNY: '¥38.00',
6869
AUD: '$7.99',
6970
},
71+
*/
72+
PLUS: {
73+
USD: '$9.99',
74+
GBP: '£7.99',
75+
EUR: '€9.99',
76+
JPY: '¥1,500',
77+
CAD: '$12.99',
78+
CNY: '¥68.00',
79+
AUD: '$14.99',
80+
},
7081
CORPORATE: {
7182
USD: '$9.99/yr',
7283
GBP: '£7.99/yr',
@@ -146,6 +157,7 @@ const htmlText = `
146157
</label>
147158
</div>
148159
<div class="button-wrapper">
160+
<!--
149161
<a class="button-link button-link--paypal js-link-paypal" href="${DEFAULT_LINK_PAYPAL}" target="_blank" rel="noopener" data-s="d-plus-paypal">
150162
<span class="button-link__text">Pay with <span class="button-link__text--paypal">PayPal</span></span>
151163
</a>
@@ -156,6 +168,20 @@ const htmlText = `
156168
<a class="button-link button-link--other button-link--inactive js-link-other" href="${Links.Redirect.CORPORATE}" target="_blank" rel="noopener" data-s="d-plus-other">
157169
<span class="button-link__text" data-text="more">More options</span>
158170
</a>
171+
-->
172+
<a class="button-link button-link--paddle js-link-paddle" href="#pay" data-s="d-side-paddle">
173+
<span class="button-link__text">
174+
<span data-text="pay">Pay</span>
175+
<span class="js-price-regular">${DEFAULT_PRICE_PLUS}</span>
176+
</span>
177+
</a>
178+
</div>
179+
<div class="payment-methods">
180+
<i class="payment-methods__paypal"></i>
181+
<i class="payment-methods__gpay"></i>
182+
<i class="payment-methods__visa"></i>
183+
<i class="payment-methods__mastercard"></i>
184+
<i class="payment-methods__amex"></i>
159185
</div>
160186
</div>
161187
</section>
@@ -411,6 +437,9 @@ const cssText = `
411437
text-transform: none;
412438
transform: none;
413439
}
440+
.button-link--paddle {
441+
font-weight: bold;
442+
}
414443
.currencies {
415444
align-items: center;
416445
display: flex;
@@ -447,6 +476,7 @@ const cssText = `
447476
flex: none;
448477
font-weight: 300;
449478
}
479+
450480
.flag {
451481
background-image: url('/images/flags.svg');
452482
background-position-y: center;
@@ -479,6 +509,47 @@ const cssText = `
479509
.flag-au {
480510
background-position-x: -9em;
481511
}
512+
513+
.payment-methods {
514+
align-items: center;
515+
display: flex;
516+
flex-direction: row;
517+
gap: 0.75rem;
518+
justify-content: center;
519+
margin-top: 0.25rem;
520+
}
521+
.payment-methods i {
522+
background-position: center;
523+
background-repeat: no-repeat;
524+
background-size: contain;
525+
display: inline-block;
526+
}
527+
.payment-methods__paypal {
528+
aspect-ratio: 101 / 32;
529+
background-image: url(/images/paypal-logo-white.svg);
530+
height: 1rem;
531+
}
532+
.payment-methods__gpay {
533+
aspect-ratio: 41 / 17;
534+
background-image: url(/images/icon-gpay.svg);
535+
height: 1rem;
536+
}
537+
.payment-methods__visa {
538+
aspect-ratio: 1 / 1;
539+
background-image: url('https://buy.paddle.com/images/icons/visa.svg');
540+
height: 1.5rem;
541+
}
542+
.payment-methods__mastercard {
543+
aspect-ratio: 1 / 1;
544+
background-image: url('https://buy.paddle.com/images/icons/mastercard.svg');
545+
height: 1.5rem;
546+
}
547+
.payment-methods__amex {
548+
aspect-ratio: 1 / 1;
549+
background-image: url('https://buy.paddle.com/images/icons/amex.svg');
550+
height: 1.5rem;
551+
}
552+
482553
:host {
483554
container-type: inline-size;
484555
font-size: 1.25rem;
@@ -547,4 +618,39 @@ class PlusTiersElement extends HTMLElement {
547618
}
548619
}
549620

621+
/** @typedef {any} Paddle */
622+
623+
let didInitializePaddle = false;
624+
625+
/**
626+
* @param {PlusTiersElement} element
627+
*/
628+
async function initPaddle(element) {
629+
/** @type {any} */
630+
let Paddle;
631+
if (!didInitializePaddle) {
632+
// @ts-ignore
633+
await import('https://cdn.paddle.com/paddle/v2/paddle.js');
634+
Paddle = /** @type {any} */(window).Paddle;
635+
// Paddle.initialize({
636+
// token: 'live_b32a4d21e35479ee3ea2b849be9',
637+
// });
638+
}
639+
element.shadowRoot?.querySelector('.js-link-paddle')?.addEventListener('click', () => {
640+
Paddle.Checkout.open({
641+
token: 'live_b32a4d21e35479ee3ea2b849be9',
642+
settings: {
643+
displayMode: 'overlay',
644+
variant: 'one-page',
645+
},
646+
items: [
647+
{
648+
priceId: 'pri_01je4ebmn474jsee5eh2gmfan9',
649+
quantity: 1,
650+
},
651+
],
652+
});
653+
});
654+
}
655+
550656
customElements.define('darkreader-plus-tiers', PlusTiersElement);

images/icon-gpay.svg

Lines changed: 1 addition & 0 deletions
Loading

images/icon-paypal.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)