@kompasid/lit-web-components 0.9.29 → 0.9.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/demo/index.html CHANGED
@@ -282,9 +282,10 @@
282
282
  >
283
283
  </kompasid-metered-paywall>
284
284
  <kompasid-metered-paywall-personalize
285
- segment="Passive Faders"
285
+ segment="Unaware"
286
286
  offering="Q3"
287
287
  user_name="Dummy User"
288
+ rubrik="Politik &amp; Hukum"
288
289
  .paywall_location=${paywallLocation}
289
290
  .paywall_subscription_id=${paywallSubscriptionId}
290
291
  .paywall_subscription_price=${paywallSubscriptionPrice}
@@ -0,0 +1,85 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Kompas Paywall Demo</title>
8
+ <link rel="icon" type="image/x-icon" href="/assets/kompas-icon.svg" />
9
+ <style>
10
+ body {
11
+ background: #fafafa;
12
+ margin: 0;
13
+ padding: 20px;
14
+ font-family: sans-serif;
15
+ }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <script type="module">
21
+ import { html, render } from 'lit'
22
+ import '../dist/src/components/kompasid-paywall/KompasPaywall.js'
23
+
24
+ const type = 'proMiningArticle'
25
+ const theme = ''
26
+ const paywallLocation = 'paywall_location'
27
+ const paywallSubscriptionId = 'testId'
28
+ const paywallSubscriptionPrice = 0
29
+ const paywallPosition = 1
30
+ const trackerPageType = 'page_type'
31
+ const trackerContentId = 'content_id'
32
+ const trackerContentType = 'content_type'
33
+ const trackerContentTitle = 'content_title'
34
+ const trackerContentCategories = 'content_categories'
35
+ const trackerUserType = 'user_type'
36
+ const trackerContentPublisher = 'publisher'
37
+ const subscriptionStatus = 'subscription_status'
38
+ const trackerPageDomain = 'page_domain'
39
+ const meteredWallType = 'metered_wall_type'
40
+ const trackerEpaperEdition = 'edition'
41
+ const meteredWallBalance = 0
42
+ const isLogin = false
43
+ const isWithHeader = false
44
+ const textHeader = 'this is message for header information'
45
+ const userGuid = '111000'
46
+ const trackerSubscriptionStatus = 'register'
47
+ const swgEnable = true
48
+
49
+ render(
50
+ html`
51
+ <kompasid-paywall
52
+ .type=${type}
53
+ .theme=${theme}
54
+ .paywall_location=${paywallLocation}
55
+ .paywall_subscription_id=${paywallSubscriptionId}
56
+ .paywall_subscription_price=${paywallSubscriptionPrice}
57
+ .paywall_position=${paywallPosition}
58
+ .tracker_page_type=${trackerPageType}
59
+ .tracker_content_id=${trackerContentId}
60
+ .tracker_content_type=${trackerContentType}
61
+ .tracker_content_title=${trackerContentTitle}
62
+ .tracker_content_categories=${trackerContentCategories}
63
+ .tracker_user_type=${trackerUserType}
64
+ .subscriptionStatus=${subscriptionStatus}
65
+ .tracker_page_domain=${trackerPageDomain}
66
+ .metered_wall_type=${meteredWallType}
67
+ .subscriptionStatus=${subscriptionStatus}
68
+ .tracker_epaper_edition=${trackerEpaperEdition}
69
+ .metered_wall_balance=${meteredWallBalance}
70
+ .tracker_content_publisher=${trackerContentPublisher}
71
+ .isLogin=${isLogin}
72
+ .isWithHeader=${isWithHeader}
73
+ .swgEnable=${swgEnable}
74
+ .textHeader=${textHeader}
75
+ .userGuid=${userGuid}
76
+ .tracker_subscription_status=${trackerSubscriptionStatus}
77
+ >
78
+ </kompasid-paywall>
79
+ `,
80
+ document.body
81
+ )
82
+ </script>
83
+ </body>
84
+
85
+ </html>
@@ -12,6 +12,7 @@ export declare class KompasMeteredPaywallPersonalize extends LitElement {
12
12
  * prop segment untuk menentukan paywall template dari segmen apa yang di pakai, bila tidak ada yang cocok jangan render paywall
13
13
  * prop offering untuk handle offering yang akan di berikan, bila tidak di isi maka akan default menjadi Q1
14
14
  * prop user_name untuk menerima nama user yang akan di tampilkan paywall specific
15
+ * prop rubrik untuk menerika rubrikasi dari implementor
15
16
  * prop paywall_location = The location where user encounter the paywall
16
17
  * prop paywall_subscription_package = The name of the subscription package viewed by user
17
18
  * prop paywall_subscription_id = The ID of the subscription package viewed by user
@@ -33,6 +34,7 @@ export declare class KompasMeteredPaywallPersonalize extends LitElement {
33
34
  segment: string;
34
35
  offering: string;
35
36
  user_name: string;
37
+ rubrik: string;
36
38
  paywall_location: string;
37
39
  paywall_subscription_package: string;
38
40
  paywall_subscription_id: string;
@@ -62,6 +64,8 @@ export declare class KompasMeteredPaywallPersonalize extends LitElement {
62
64
  private replacePlaceholdersFromOffering;
63
65
  private engageReturners;
64
66
  private passiveFaders;
67
+ private lostButCurious;
68
+ private unaware;
65
69
  private pickTemplate;
66
70
  render(): import("lit-html").TemplateResult<1> | typeof nothing;
67
71
  }
@@ -19,6 +19,7 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
19
19
  * prop segment untuk menentukan paywall template dari segmen apa yang di pakai, bila tidak ada yang cocok jangan render paywall
20
20
  * prop offering untuk handle offering yang akan di berikan, bila tidak di isi maka akan default menjadi Q1
21
21
  * prop user_name untuk menerima nama user yang akan di tampilkan paywall specific
22
+ * prop rubrik untuk menerika rubrikasi dari implementor
22
23
  * prop paywall_location = The location where user encounter the paywall
23
24
  * prop paywall_subscription_package = The name of the subscription package viewed by user
24
25
  * prop paywall_subscription_id = The ID of the subscription package viewed by user
@@ -40,6 +41,7 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
40
41
  this.segment = '';
41
42
  this.offering = '';
42
43
  this.user_name = '';
44
+ this.rubrik = '';
43
45
  this.paywall_location = '';
44
46
  this.paywall_subscription_package = '';
45
47
  this.paywall_subscription_id = '';
@@ -64,7 +66,7 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
64
66
  }
65
67
  async getMeteredPaywallData() {
66
68
  try {
67
- const getSegment = this.segment.toLocaleLowerCase().replace(' ', '_');
69
+ const getSegment = this.segment.toLocaleLowerCase().replace(/ /g, '_');
68
70
  const response = await fetch(`https://cdn-www.kompas.id/web-component/metered-paywall-personalize/${getSegment}.json`);
69
71
  const json = await response.json();
70
72
  this.packageData = json;
@@ -140,7 +142,6 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
140
142
  }
141
143
  computedstateDefaultPaywall() {
142
144
  this.stateDefaultPaywall = !this.stateDefaultPaywall;
143
- this.requestUpdate();
144
145
  }
145
146
  /**
146
147
  * Ganti placeholder _key_ di template dengan nilai dari data offering
@@ -232,7 +233,7 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
232
233
  class="flex flex-col lg:flex-row w-full bg-blue-100 py-4 justify-center gap-4 px-4 lg:px-0 bottom-0"
233
234
  >
234
235
  <div
235
- class="text-grey-600 text-base self-center text-left message-collapse-engage-returners font-bold"
236
+ class="text-grey-600 text-base self-center text-left message-formatter font-bold"
236
237
  >
237
238
  ${unsafeHTML(textTemplateFormater)}
238
239
  </div>
@@ -257,7 +258,10 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
257
258
  return html `
258
259
  <div class="sticky bottom-0 w-full h-full">
259
260
  <div
260
- class="flex flex-col lg:flex-row w-full bg-blue-100 py-4 gap-4 px-4 bottom-0"
261
+ class="flex flex-col lg:flex-row w-full bg-blue-100 ${this
262
+ .stateDefaultPaywall
263
+ ? 'py-4 lg:py-3'
264
+ : 'py-4 lg:py-8'} gap-4 px-4 bottom-0"
261
265
  >
262
266
  <div
263
267
  class="flex flex-col lg:flex-row w-full justify-between max-w-[1200px] gap-4 mx-auto "
@@ -269,7 +273,7 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
269
273
  class="flex flex-col lg:flex-row justify-center items-center lg:items-start lg:justify-between w-full max-w-5xl"
270
274
  >
271
275
  <div
272
- class="text-grey-600 font-lora message-collapse-engage-returners order-2"
276
+ class="text-grey-600 font-lora message-formatter order-2"
273
277
  >
274
278
  <div
275
279
  class="text-xl lg:text-2xl font-bold mb-3 text-center lg:text-start"
@@ -293,11 +297,11 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
293
297
  : nothing}
294
298
  </div>
295
299
  <div
296
- class="text-grey-600 font-sans text-sm lg:text-base self-center text-left message-collapse-engage-returners mb-4"
300
+ class="text-grey-600 font-sans text-sm lg:text-base self-center text-left message-formatter mb-4"
297
301
  >
298
302
  ${unsafeHTML(descriptionExpand)}
299
303
  </div>
300
- <div>
304
+ <div class="font-sans">
301
305
  <button
302
306
  @click="${this.redirectToBerlangganan}"
303
307
  class="bg-brand-1 flex whitespace-nowrap items-center justify-center rounded md:rounded h-10 px-4 md:px-5 text-base text-white font-bold leading-[18px] w-full lg:w-auto"
@@ -328,10 +332,10 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
328
332
  </div>
329
333
  `
330
334
  : html `
331
- <div class="h-9 w-9 flex"></div>
335
+ <div class="hidden h-9 w-9 lg:flex"></div>
332
336
  <div class="flex justify-between">
333
337
  <div
334
- class="text-grey-600 text-base self-center text-left message-collapse-engage-returners font-bold"
338
+ class="text-grey-600 text-base self-center text-left message-formatter font-bold"
335
339
  >
336
340
  ${unsafeHTML(messageTitleCollapse)}
337
341
  </div>
@@ -376,12 +380,219 @@ let KompasMeteredPaywallPersonalize = class KompasMeteredPaywallPersonalize exte
376
380
  </div>
377
381
  `;
378
382
  }
383
+ lostButCurious() {
384
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
385
+ const messageTitleCollapse = this.replacePlaceholdersFromOffering(((_a = this.packageData) === null || _a === void 0 ? void 0 : _a.paywall.messageTitleCollapse) || '', ((_b = this.packageData) === null || _b === void 0 ? void 0 : _b.offering[this.offering ? this.offering : 'Q1']) ||
386
+ {});
387
+ const descriptionExpand = this.replacePlaceholdersFromOffering(((_c = this.packageData) === null || _c === void 0 ? void 0 : _c.paywall.descriptionExpand) || '', ((_d = this.packageData) === null || _d === void 0 ? void 0 : _d.offering[this.offering ? this.offering : 'Q1']) ||
388
+ {});
389
+ return html `
390
+ <div class="sticky bottom-0 w-full h-full leading-none">
391
+ <div
392
+ class="flex flex-col lg:flex-row w-full bg-blue-100 ${this
393
+ .stateDefaultPaywall
394
+ ? 'py-4 lg:py-3'
395
+ : 'py-4 lg:py-8'} gap-4 px-4 bottom-0"
396
+ >
397
+ <div
398
+ class="flex flex-col lg:flex-row w-full justify-between max-w-[1200px] gap-4 mx-auto "
399
+ >
400
+ ${!this.stateDefaultPaywall
401
+ ? html `
402
+ <div class="h-9 w-9 hidden lg:flex"></div>
403
+ <div
404
+ class="flex flex-col lg:flex-row justify-center items-center lg:items-start lg:justify-between w-full max-w-5xl"
405
+ >
406
+ <div class="text-grey-600 font-sans order-2">
407
+ <div
408
+ class="text-xl lg:text-2xl font-lora font-bold mb-3 lg:mb-2 text-center lg:text-start"
409
+ >
410
+ <span
411
+ >Halo
412
+ ${this.user_name
413
+ ? this.user_name
414
+ : 'Pembaca Setia Kompas'},</span
415
+ >
416
+ ${(_e = this.packageData) === null || _e === void 0 ? void 0 : _e.paywall.messageTitleExpand}
417
+ <span>${this.rubrik}</span>
418
+ </div>
419
+ <div
420
+ class="text-grey-600 font-sans text-sm lg:text-base self-center text-left message-formatter mb-2"
421
+ >
422
+ ${unsafeHTML(descriptionExpand)}
423
+ </div>
424
+ <div class="text-base lg:text-lg text-grey-400 mb-1">
425
+ <s
426
+ >${formatRupiah(((_f = this.packageData) === null || _f === void 0 ? void 0 : _f.offering[this.offering ? this.offering : 'Q1'].harga_coret) || 0)}</s
427
+ >
428
+ <span
429
+ class="text-lg lg:text-2xl text-orange-400 font-bold"
430
+ >
431
+ ${formatRupiah(((_g = this.packageData) === null || _g === void 0 ? void 0 : _g.offering[this.offering ? this.offering : 'Q1'].offering_price) || 0)}
432
+ </span>
433
+ ${((_h = this.packageData) === null || _h === void 0 ? void 0 : _h.offering[this.offering ? this.offering : 'Q1'].duration)
434
+ ? html `
435
+ <span class="text-base lg:text-lg text-grey-600"
436
+ >${(_j = this.packageData) === null || _j === void 0 ? void 0 : _j.offering[this.offering ? this.offering : 'Q1'].duration}</span
437
+ >
438
+ `
439
+ : nothing}
440
+ </div>
441
+ <div class="mb-3 lg:mb-4">untuk tahun pertama.</div>
442
+ <div class="font-sans">
443
+ <button
444
+ @click="${this.redirectToBerlangganan}"
445
+ class="bg-brand-1 flex whitespace-nowrap items-center justify-center rounded md:rounded h-10 px-4 md:px-5 text-base text-white font-bold leading-[18px] w-full lg:w-auto"
446
+ >
447
+ ${(_k = this.packageData) === null || _k === void 0 ? void 0 : _k.offering[this.offering ? this.offering : 'Q1'].checkout_text}
448
+ </button>
449
+ </div>
450
+ </div>
451
+ <div
452
+ class="flex self-center mt-10 mb-3 lg:mb-0 lg:mt-0 lg:ml-6 order-1 lg:order-2"
453
+ >
454
+ <image
455
+ src="${(_l = this.packageData) === null || _l === void 0 ? void 0 : _l.paywall.image}"
456
+ alt="content"
457
+ class="w-[112px] lg:w-[202px]"
458
+ />
459
+ </div>
460
+ </div>
461
+ <div>
462
+ <button
463
+ @click="${this.computedstateDefaultPaywall}"
464
+ class="h-9 w-9 absolute lg:static flex items-center justify-center text-blue-500 rounded bg-blue-200 right-4 top-4"
465
+ >
466
+ <div>
467
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}
468
+ </div>
469
+ </button>
470
+ </div>
471
+ `
472
+ : html `
473
+ <div class="hidden h-9 w-9 lg:flex"></div>
474
+ <div class="flex justify-between">
475
+ <div
476
+ class="text-grey-600 text-base self-center text-left message-formatter font-bold"
477
+ >
478
+ ${unsafeHTML(messageTitleCollapse)}
479
+ </div>
480
+ <div class="hidden lg:flex ml-6">
481
+ <button
482
+ @click="${this.redirectToBerlangganan}"
483
+ class="bg-brand-1 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-base text-white font-bold leading-[18px] w-full lg:w-auto"
484
+ >
485
+ ${(_m = this.packageData) === null || _m === void 0 ? void 0 : _m.offering[this.offering ? this.offering : 'Q1'].checkout_text}
486
+ </button>
487
+ </div>
488
+ <div class="flex lg:hidden ml-4">
489
+ <button
490
+ @click="${this.computedstateDefaultPaywall}"
491
+ class="h-9 w-9 flex items-center justify-center text-blue-500 rounded bg-blue-200"
492
+ >
493
+ <div>
494
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-up'))}
495
+ </div>
496
+ </button>
497
+ </div>
498
+ </div>
499
+ <div>
500
+ <button
501
+ @click="${this.computedstateDefaultPaywall}"
502
+ class="h-9 w-9 hidden lg:flex items-center justify-center text-blue-500 rounded bg-blue-200"
503
+ >
504
+ <div>
505
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-up'))}
506
+ </div>
507
+ </button>
508
+ <button
509
+ @click="${this.redirectToBerlangganan}"
510
+ class="bg-brand-1 lg:hidden flex whitespace-nowrap items-center justify-center rounded md:rounded h-10 px-4 md:px-5 text-base text-white font-bold leading-[18px] w-full"
511
+ >
512
+ ${(_o = this.packageData) === null || _o === void 0 ? void 0 : _o.offering[this.offering ? this.offering : 'Q1'].checkout_text}
513
+ </button>
514
+ </div>
515
+ `}
516
+ </div>
517
+ </div>
518
+ </div>
519
+ `;
520
+ }
521
+ unaware() {
522
+ var _a, _b, _c, _d, _e, _f, _g;
523
+ const descriptionExpand = this.replacePlaceholdersFromOffering(((_a = this.packageData) === null || _a === void 0 ? void 0 : _a.paywall.descriptionExpand) || '', ((_b = this.packageData) === null || _b === void 0 ? void 0 : _b.offering[this.offering ? this.offering : 'Q1']) ||
524
+ {});
525
+ return html `
526
+ <div class="w-full h-full max-w-4xl mx-auto">
527
+ <div
528
+ class="flex flex-col lg:flex-row w-full bg-blue-100 py-6 px-4 lg:py-9 lg:px-6 gap-4 rounded-lg"
529
+ >
530
+ <div
531
+ class="flex flex-col lg:flex-row w-full justify-between max-w-[1200px] gap-4 mx-auto"
532
+ >
533
+ <div
534
+ class="flex flex-col lg:flex-row justify-center items-center lg:items-start lg:justify-between w-full max-w-5xl"
535
+ >
536
+ <div class="text-grey-600 font-lora message-formatter order-2">
537
+ <div
538
+ class="text-xl lg:text-2xl font-bold mb-2 text-center lg:text-start"
539
+ >
540
+ ${(_c = this.packageData) === null || _c === void 0 ? void 0 : _c.paywall.messageTitleExpand}${this
541
+ .user_name
542
+ ? `, ${this.user_name}!`
543
+ : ''}
544
+ </div>
545
+ <div class="mb-2 font-sans">
546
+ ${unsafeHTML(descriptionExpand)}
547
+ </div>
548
+ <div class="flex flex-col font-sans gap-3 mb-4">
549
+ ${((_d = this.packageData) === null || _d === void 0 ? void 0 : _d.paywall.listBenefits)
550
+ ? (_e = this.packageData) === null || _e === void 0 ? void 0 : _e.paywall.listBenefits.map(item => html `
551
+ <div class="flex items-baseline align-baseline">
552
+ <div
553
+ class="bg-white text-green-500 h-3 w-3 mr-1 rounded-full flex justify-center items-center"
554
+ >
555
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'circle-check', 12, 12))}
556
+ </div>
557
+ <h6 class="text-base ml-1">${item}</h6>
558
+ </div>
559
+ `)
560
+ : nothing}
561
+ </div>
562
+ <div class="font-sans">
563
+ <button
564
+ @click="${this.redirectToBerlangganan}"
565
+ class="bg-brand-1 flex whitespace-nowrap items-center justify-center rounded md:rounded h-8 lg:h-10 px-4 md:px-5 text-sm lg:text-base text-white font-bold leading-[18px] w-full lg:w-auto"
566
+ >
567
+ ${(_f = this.packageData) === null || _f === void 0 ? void 0 : _f.offering[this.offering ? this.offering : 'Q1'].checkout_text}
568
+ </button>
569
+ </div>
570
+ </div>
571
+ <div
572
+ class="flex self-center mt-10 mb-3 lg:mb-0 lg:mt-0 lg:ml-6 order-1 lg:order-2"
573
+ >
574
+ <image
575
+ src="${(_g = this.packageData) === null || _g === void 0 ? void 0 : _g.paywall.image}"
576
+ alt="content"
577
+ class="w-[112px] lg:w-[202px]"
578
+ />
579
+ </div>
580
+ </div>
581
+ </div>
582
+ </div>
583
+ </div>
584
+ `;
585
+ }
379
586
  pickTemplate() {
380
- switch (this.segment) {
381
- case 'Engaged Returners':
587
+ switch (this.segment.toLocaleLowerCase()) {
588
+ case 'engaged returners':
382
589
  return this.engageReturners();
383
- case 'Passive Faders':
590
+ case 'passive faders':
384
591
  return this.passiveFaders();
592
+ case 'lost but curious':
593
+ return this.lostButCurious();
594
+ case 'unaware':
595
+ return this.unaware();
385
596
  default:
386
597
  return nothing;
387
598
  }
@@ -404,15 +615,16 @@ KompasMeteredPaywallPersonalize.styles = [
404
615
  width: 100%;
405
616
  }
406
617
 
407
- .message-collapse-engage-returners span {
618
+ .message-formatter span {
408
619
  color: #ff7a00;
409
620
  font-weight: 700;
410
621
  text-wrap: nowrap;
411
622
  }
412
623
 
413
- .message-collapse-engage-returners s {
624
+ .message-formatter s {
414
625
  color: #999999;
415
626
  text-wrap: nowrap;
627
+ font-weight: 400;
416
628
  }
417
629
 
418
630
  .font-lora {
@@ -455,6 +667,9 @@ __decorate([
455
667
  __decorate([
456
668
  property({ type: String })
457
669
  ], KompasMeteredPaywallPersonalize.prototype, "user_name", void 0);
670
+ __decorate([
671
+ property({ type: String })
672
+ ], KompasMeteredPaywallPersonalize.prototype, "rubrik", void 0);
458
673
  __decorate([
459
674
  property({ type: String })
460
675
  ], KompasMeteredPaywallPersonalize.prototype, "paywall_location", void 0);
@@ -500,6 +715,9 @@ __decorate([
500
715
  __decorate([
501
716
  property({ type: Number })
502
717
  ], KompasMeteredPaywallPersonalize.prototype, "tracker_metered_wall_balance", void 0);
718
+ __decorate([
719
+ state()
720
+ ], KompasMeteredPaywallPersonalize.prototype, "stateDefaultPaywall", void 0);
503
721
  KompasMeteredPaywallPersonalize = __decorate([
504
722
  customElement('kompasid-metered-paywall-personalize')
505
723
  ], KompasMeteredPaywallPersonalize);