@kompasid/lit-web-components 0.4.4 → 0.5.0

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.
Files changed (53) hide show
  1. package/assets/font-awesome.ts +7 -4
  2. package/demo/index.html +147 -118
  3. package/dist/assets/font-awesome.d.ts +1 -1
  4. package/dist/assets/font-awesome.js +7 -4
  5. package/dist/assets/font-awesome.js.map +1 -1
  6. package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +91 -0
  7. package/dist/src/components/kompasid-freewall/KompasFreewall.js +256 -0
  8. package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -0
  9. package/dist/src/components/kompasid-freewall/types.d.ts +10 -0
  10. package/dist/src/components/kompasid-freewall/types.js +2 -0
  11. package/dist/src/components/kompasid-freewall/types.js.map +1 -0
  12. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +33 -0
  13. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +223 -0
  14. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -0
  15. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +37 -0
  16. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +122 -0
  17. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -0
  18. package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.d.ts +0 -1
  19. package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js +3 -8
  20. package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js.map +1 -1
  21. package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.d.ts +12 -13
  22. package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js +30 -49
  23. package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js.map +1 -1
  24. package/dist/src/index.d.ts +1 -0
  25. package/dist/src/index.js +1 -0
  26. package/dist/src/index.js.map +1 -1
  27. package/dist/src/utils/cta.d.ts +6 -0
  28. package/dist/src/utils/cta.js +18 -0
  29. package/dist/src/utils/cta.js.map +1 -0
  30. package/dist/src/utils/generateCopyDuration.d.ts +1 -0
  31. package/dist/src/utils/generateCopyDuration.js +15 -0
  32. package/dist/src/utils/generateCopyDuration.js.map +1 -0
  33. package/dist/src/utils/googleFont.js +1 -0
  34. package/dist/src/utils/googleFont.js.map +1 -1
  35. package/dist/tailwind/tailwind.js +215 -0
  36. package/dist/tailwind/tailwind.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +1 -1
  39. package/src/components/kompasid-freewall/KompasFreewall.ts +205 -0
  40. package/src/components/kompasid-freewall/readme.md +31 -0
  41. package/src/components/kompasid-freewall/types.ts +10 -0
  42. package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +219 -0
  43. package/src/components/kompasid-freewall-body/readme.md +13 -0
  44. package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +102 -0
  45. package/src/components/kompasid-freewall-head/readme.md +17 -0
  46. package/src/components/kompasid-paywall-body/KompasPaywallBody.ts +3 -9
  47. package/src/components/kompasid-paywall-video/KompasPaywallVideo.ts +36 -51
  48. package/src/index.ts +1 -0
  49. package/src/utils/cta.ts +25 -0
  50. package/src/utils/generateCopyDuration.ts +14 -0
  51. package/src/utils/googleFont.ts +2 -0
  52. package/tailwind/tailwind.css +215 -0
  53. package/tailwind/tailwind.ts +215 -0
@@ -0,0 +1,219 @@
1
+ import { html, css, LitElement, nothing } from 'lit'
2
+ import { property, customElement } from 'lit/decorators.js'
3
+ import { TWStyles } from '../../../tailwind/tailwind.js'
4
+ import { addGoogleFonts } from '../../utils/googleFont.js'
5
+ import { formatRupiah } from '../../utils/formatRupiah.js'
6
+ import { generateCopyDuration } from '../../utils/generateCopyDuration.js'
7
+ import { PackageData } from '../kompasid-freewall/types.js'
8
+ import { faCheck } from '../../../assets/font-awesome.js'
9
+ import { redirectToRegister } from '../../utils/cta.js'
10
+
11
+ @customElement('kompasid-freewall-body')
12
+ export class KompasFreewallBody extends LitElement {
13
+ static styles = [
14
+ css`
15
+ .font-lora {
16
+ font-family: 'Lora', 'Georgia', 'serif';
17
+ }
18
+
19
+ .font-roboto-condensed {
20
+ font-family: 'Roboto Condensed', sans-serif;
21
+ }
22
+
23
+ /* ----- Ribbon Container ---------------------------------------*/
24
+ #ribbon-container {
25
+ background: transparent;
26
+ height: 130px;
27
+ width: 200px;
28
+ position: absolute;
29
+ top: -5px;
30
+ right: -5px;
31
+ overflow: hidden;
32
+ }
33
+
34
+ /* ----- Top Curl ---------------------------------------*/
35
+ #ribbon-container:before {
36
+ content: '';
37
+ display: block;
38
+ -webkit-border-radius: 10px 10px 0px 0px;
39
+ border-radius: 10px 10px 0px 0px;
40
+ width: 35px;
41
+ height: 10px;
42
+ position: absolute;
43
+ right: 60px;
44
+ background: #b78b00;
45
+ z-index: 1;
46
+ }
47
+
48
+ /* ----- Right Curl ---------------------------------------*/
49
+ #ribbon-container:after {
50
+ content: '';
51
+ display: block;
52
+ -webkit-border-radius: 0px 10px 10px 0px;
53
+ border-radius: 0px 10px 10px 0px;
54
+ width: 10px;
55
+ height: 35px;
56
+ position: absolute;
57
+ right: 0px;
58
+ top: 60px;
59
+ background: #b78b00;
60
+ }
61
+
62
+ /* ----- Ribbon ---------------------------------------*/
63
+ #ribbon-container > div {
64
+ width: 140px;
65
+ height: 28px;
66
+ position: relative;
67
+ top: 24px;
68
+ right: -100px;
69
+ z-index: 11;
70
+ overflow: hidden;
71
+ transform: rotate(45deg);
72
+ -ms-transform: rotate(45deg); /* IE 9 */
73
+ -moz-transform: rotate(45deg); /* Firefox */
74
+ -webkit-transform: rotate(45deg); /* Safari and Chrome */
75
+ -o-transform: rotate(45deg); /* Opera */
76
+ background: #ffcc00;
77
+ }
78
+ `,
79
+ TWStyles,
80
+ ]
81
+
82
+ /**
83
+ * Props
84
+ */
85
+ /**
86
+ * property isLogin untuk menghandle apakah user sudah login atau belum
87
+ * property type untuk menghandle tipe freewall
88
+ * property onSubscriptionClick to handle cta when subscription button is clicked
89
+ * packageData sebagai data package yang diambil dari kompasid-freewall
90
+ */
91
+
92
+ @property({ type: Boolean }) isLogin = false
93
+ @property({ type: String }) type: 'article' | 'landing_page' = 'article'
94
+ @property() onSubscriptionClick = () => {}
95
+ @property({ type: Object }) packageData: PackageData = {} as PackageData
96
+
97
+ description = [
98
+ 'Akses seluruh konten Kompas.id di web & aplikasi',
99
+ 'ePaper hingga 30 edisi terakhir',
100
+ 'Buku digital tiap bulannya di aplikasi ',
101
+ ]
102
+
103
+ /**
104
+ * Lifecycle
105
+ */
106
+
107
+ override async connectedCallback() {
108
+ super.connectedCallback()
109
+ await this.updateComplete
110
+ addGoogleFonts(['pt-sans', 'lora', 'roboto-condensed'])
111
+ }
112
+
113
+ /**
114
+ * Component
115
+ */
116
+
117
+ private subscriptionCardComponent() {
118
+ return html`
119
+ <div class="relative">
120
+ <div
121
+ id="subscription-card"
122
+ class="flex justify-between items-center relative z-10 flex-col w-[328px] ${this
123
+ .isLogin
124
+ ? 'h-[277px] md:w-[580px] md:h-[240px]'
125
+ : 'h-[223px] md:w-[350px] lg:w-[410px] md:h-[210px]'} py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] border-2 border-yellow-400 bg-white"
126
+ >
127
+ <div
128
+ class="flex w-full flex-col ${this.isLogin
129
+ ? 'items-center md:w-[374px] text-center'
130
+ : 'items-start text-start'}"
131
+ >
132
+ <h5
133
+ class="font-lora text-lg md:text-xl font-bold leading-[30px] ${this
134
+ .isLogin && 'w-60 md:w-full'} text-grey-600"
135
+ >
136
+ ${this.isLogin
137
+ ? 'Dukung Jurnalisme Mencerahkan dengan Berlangganan'
138
+ : 'Mulai Berlangganan'}
139
+ </h5>
140
+ ${this.descriptionSection()}
141
+ </div>
142
+ <button
143
+ @click=${this.onSubscriptionClick}
144
+ class="bg-green-500 whitespace-nowrap w-full rounded ${this
145
+ .isLogin &&
146
+ 'md:w-[370px]'} md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
147
+ >
148
+ Langganan ${formatRupiah(this.packageData.price)}
149
+ /${generateCopyDuration(this.packageData.durationType)}
150
+ </button>
151
+ </div>
152
+ <div id="ribbon-container">
153
+ <div
154
+ class="text-[11px] font-medium font-roboto-condensed flex justify-center items-center"
155
+ >
156
+ <span class="-ml-2">Penawaran Terbaik</span>
157
+ </div>
158
+ </div>
159
+ </div>
160
+ `
161
+ }
162
+
163
+ private registerCardComponent() {
164
+ return html`
165
+ <div
166
+ class="flex flex-col justify-between w-[328px] h-[159px] md:w-[350px] lg:w-[410px] md:h-[210px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white"
167
+ >
168
+ <div>
169
+ <h5
170
+ class="font-lora text-lg md:text-xl font-bold leading-[30px] text-grey-600"
171
+ >
172
+ Daftar Akun Gratis
173
+ </h5>
174
+ <div class="flex items-start lg:items-center mt-1 md:mt-3">
175
+ <div class="mt-1 lg:mt-0">${faCheck()}</div>
176
+ <h6 class="text-base text-grey-600 ml-1">
177
+ Akses ke 3 artikel berbayar gratis tiap bulan
178
+ </h6>
179
+ </div>
180
+ </div>
181
+ <button
182
+ @click=${() => redirectToRegister('freewall')}
183
+ class="bg-white border border-blue-600 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-blue-600 font-bold leading-[18px]"
184
+ >
185
+ Daftar Gratis
186
+ </button>
187
+ </div>
188
+ `
189
+ }
190
+
191
+ private descriptionSection() {
192
+ return html`<div class="flex flex-col space-y-1 mt-1 lg:mt-3">
193
+ ${this.description.map(
194
+ item =>
195
+ html`
196
+ <div class="flex items-start lg:items-center">
197
+ <div class="mt-1 lg:mt-0">${faCheck()}</div>
198
+ <h6 class="text-base text-grey-600 ml-1 text-start">${item}</h6>
199
+ </div>
200
+ `
201
+ )}
202
+ </div>`
203
+ }
204
+
205
+ /**
206
+ * Render Statement
207
+ */
208
+
209
+ render() {
210
+ return html`
211
+ <div
212
+ class="w-full h-full flex flex-col md:flex-row pt-6 md:pt-3 relative px-4 md:px-0 py-3 space-y-4 md:space-x-5 md:space-y-0 justify-center items-center"
213
+ >
214
+ ${this.subscriptionCardComponent()}
215
+ ${!this.isLogin ? this.registerCardComponent() : nothing}
216
+ </div>
217
+ `
218
+ }
219
+ }
@@ -0,0 +1,13 @@
1
+ # kompasid-freewall-body
2
+
3
+ ## Properties
4
+
5
+ | Property | Attribute | Description | Type | Default |
6
+ | ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------- | -------- | ------- |
7
+ | `isLogin` | `isLogin` | property isLogin untuk menghandle apakah user sudah login atau belum | `boolean` | `false` |
8
+ | `type` | `type` | property type untuk menghandle tipe freewall | `"article" \| "landing_page"` | `"article"` |
9
+ | `packageData` | `packageData` | packageData sebagai data package yang akan di offer | `PackageData` | `{}` |
10
+
11
+ ----------------------------------------------
12
+
13
+ *Terbikin oleh tim front-end kompas.id*
@@ -0,0 +1,102 @@
1
+ import { html, css, LitElement, nothing } from 'lit'
2
+ import { property, customElement } from 'lit/decorators.js'
3
+ import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
4
+ import { TWStyles } from '../../../tailwind/tailwind.js'
5
+ import { addGoogleFonts } from '../../utils/googleFont.js'
6
+ import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
7
+ import { formatRupiah } from '../../utils/formatRupiah.js'
8
+ import { generateCopyDuration } from '../../utils/generateCopyDuration.js'
9
+ import { PackageData } from '../kompasid-freewall/types.js'
10
+
11
+ @customElement('kompasid-freewall-head')
12
+ export class KompasFreewallHead extends LitElement {
13
+ static styles = [css``, TWStyles]
14
+
15
+ /**
16
+ * Props
17
+ */
18
+ /**
19
+ * property isLogin untuk menghandle apakah user sudah login atau belum
20
+ * property type untuk menghandle tipe freewall
21
+ * property head_copy_expand to update copy header when expand
22
+ * property head_copy_collapse to update copy header when collapse
23
+ * property expand to handle expand/collapse
24
+ * property toggleExpand to handle toggle expand/collapse
25
+ * property onSubscriptionClick to handle cta when subscription button is clicked
26
+ */
27
+
28
+ @property({ type: Boolean }) isLogin = false
29
+ @property({ type: String }) type: 'article' | 'landing_page' = 'article'
30
+ @property({ type: String }) head_copy_expand = ''
31
+ @property({ type: String }) head_copy_collapse = ''
32
+ @property({ type: Boolean }) expand = true
33
+ @property() toggleExpand = () => {}
34
+ @property() onSubscriptionClick = () => {}
35
+ @property({ type: Object }) packageData: PackageData = {} as PackageData
36
+
37
+ /**
38
+ * Getter
39
+ */
40
+
41
+ get headCopy() {
42
+ return (
43
+ (this.expand ? this.head_copy_expand : this.head_copy_collapse) ||
44
+ 'Akses seluruh konten dan fitur Kompas.id dengan berlangganan.'
45
+ )
46
+ }
47
+
48
+ /**
49
+ * Lifecycle
50
+ */
51
+
52
+ override async connectedCallback() {
53
+ super.connectedCallback()
54
+ await this.updateComplete
55
+ addGoogleFonts(['pt-sans'])
56
+ }
57
+
58
+ /**
59
+ * Render Statement
60
+ */
61
+
62
+ render() {
63
+ return html`
64
+ <div class="flex flex-col px-4 md:px-0 space-y-4">
65
+ <div class="flex justify-between items-center h-full space-x-3">
66
+ <div class="hidden md:block"></div>
67
+ <div class="flex items-center md:justify-start space-x-3">
68
+ <p class="w-[280px] md:w-full">${this.headCopy}</p>
69
+ ${!this.expand
70
+ ? html`<button
71
+ @click=${this.onSubscriptionClick}
72
+ class="bg-green-500 hidden md:block whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
73
+ >
74
+ Langganan ${formatRupiah(this.packageData.price)}
75
+ /${generateCopyDuration(this.packageData.durationType)}
76
+ </button>`
77
+ : nothing}
78
+ </div>
79
+ <div>
80
+ <button
81
+ @click=${this.toggleExpand}
82
+ class="h-9 w-9 flex items-center justify-center text-blue-500 rounded bg-blue-200"
83
+ >
84
+ <div class="${!this.expand && 'rotate-180'}">
85
+ ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}
86
+ </div>
87
+ </button>
88
+ </div>
89
+ </div>
90
+ ${!this.expand
91
+ ? html`<button
92
+ @click=${this.onSubscriptionClick}
93
+ class="bg-green-500 block md:hidden whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
94
+ >
95
+ Langganan ${formatRupiah(this.packageData.price)}
96
+ /${generateCopyDuration(this.packageData.durationType)}
97
+ </button>`
98
+ : nothing}
99
+ </div>
100
+ `
101
+ }
102
+ }
@@ -0,0 +1,17 @@
1
+ # kompasid-freewall-head
2
+
3
+ ## Properties
4
+
5
+ | Property | Attribute | Description | Type | Default |
6
+ | ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------- | -------- | ------- |
7
+ | `isLogin` | `isLogin` | property isLogin untuk menghandle apakah user sudah login atau belum | `boolean` | `false` |
8
+ | `type` | `type` | property type untuk menghandle tipe freewall | `"article" \| "landing_page"` | `"article"`
9
+ | `expand` | `expand` | property expand to handle expand/collapse | `boolean` | `true` |
10
+ | `head_copy_expand` | `head_copy_expand` |property head_copy_expand to update copy header when expand | `string` | `""` |
11
+ | `head_copy_collapse` | `head_copy_collapse` |property head_copy_expand to update copy header when collapse | `string` | `""` |
12
+ | `packageData` | `packageData` | packageData sebagai data package yang akan di offer | `PackageData` | `{}` |
13
+ | `toggleExpand` | `toggleExpand` |property toggleExpand to handle toggle expand/collapse | `Function` | `() => {}` |
14
+
15
+ ----------------------------------------------
16
+
17
+ *Terbikin oleh tim front-end kompas.id*
@@ -14,6 +14,7 @@ import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
14
14
  import { deviceType } from '../../utils/deviceType.js'
15
15
  import { formatRupiah } from '../../utils/formatRupiah.js'
16
16
  import { addGoogleFonts } from '../../utils/googleFont.js'
17
+ import { redirectToRegister } from '../../utils/cta.js'
17
18
 
18
19
  @customElement('kompasid-paywall-body')
19
20
  export class KompasIdPaywallBody extends LitElement {
@@ -116,7 +117,7 @@ export class KompasIdPaywallBody extends LitElement {
116
117
  get loginUrl() {
117
118
  return `${this.kompasLoginHost}?next=${encodeURIComponent(
118
119
  this.selfHost + window.location.pathname
119
- )}`
120
+ )}&loc=hard_paywall`
120
121
  }
121
122
 
122
123
  get isDark() {
@@ -150,13 +151,6 @@ export class KompasIdPaywallBody extends LitElement {
150
151
  window.open('https://www.kompas.id/berlangganan')
151
152
  }
152
153
 
153
- private redirectToRegister(): void {
154
- const loginHost: string = 'https://account.kompas.id/register'
155
- const nextParams: string = encodeURIComponent(window.location.href)
156
- const directUrlRegister: string = `${loginHost}?next=${nextParams}?status=sukses_login&status_login=login`
157
- window.location.href = directUrlRegister
158
- }
159
-
160
154
  private redirectToLogin = (): void => {
161
155
  window.location.href = this.loginUrl
162
156
  }
@@ -680,7 +674,7 @@ export class KompasIdPaywallBody extends LitElement {
680
674
  <div class="flex flex-col items-center justify-center">
681
675
  <div>
682
676
  <button
683
- @click=${this.redirectToRegister}
677
+ @click=${() => redirectToRegister('hard_paywall')}
684
678
  class="text-sm md:text-base font-bold ${this.isDark
685
679
  ? 'text-blue-300'
686
680
  : 'text-blue-600'} underline"
@@ -5,6 +5,13 @@ import { TWStyles } from '../../../tailwind/tailwind.js'
5
5
  import { deviceType } from '../../utils/deviceType.js'
6
6
  import { formatRupiah } from '../../utils/formatRupiah.js'
7
7
  import { addGoogleFonts } from '../../utils/googleFont.js'
8
+ import { generateCopyDuration } from '../../utils/generateCopyDuration.js'
9
+ import { PackageData } from '../kompasid-freewall/types.js'
10
+ import {
11
+ redirectToCheckout,
12
+ redirectToLogin,
13
+ redirectToRegister,
14
+ } from '../../utils/cta.js'
8
15
 
9
16
  @customElement('kompasid-paywall-video')
10
17
  export class KompasPaywallVideo extends LitElement {
@@ -58,13 +65,24 @@ export class KompasPaywallVideo extends LitElement {
58
65
  @property({ type: Number }) tracker_metered_wall_balance = 0
59
66
  @property({ type: String }) type: 'article' | 'homepage' = 'article'
60
67
 
68
+ showPackage = {
69
+ duration: 1,
70
+ durationType: 3,
71
+ id: '9802035',
72
+ link: 'kdp?productId=9802035&referrer=',
73
+ price: 50000,
74
+ position: 1,
75
+ title: 'Kompas Digital Premium 1 Bulan',
76
+ referrer: '',
77
+ }
78
+
61
79
  /**
62
80
  * State
63
81
  */
64
82
 
65
83
  @state() private subscriptionUrl: string =
66
84
  'https://www.kompas.id/berlangganan'
67
- @state() private checkoutHost: string = 'https://checkoutv2.kompas.id'
85
+ @state() private packageData: PackageData = {} as PackageData
68
86
 
69
87
  /**
70
88
  * Component
@@ -77,7 +95,7 @@ export class KompasPaywallVideo extends LitElement {
77
95
  >
78
96
  <div>
79
97
  <button
80
- @click=${() => this.redirectToRegister('Daftar')}
98
+ @click=${() => this.onRegisterClick('Daftar')}
81
99
  class="text-blue-300 font-bold"
82
100
  >
83
101
  Daftar
@@ -87,7 +105,7 @@ export class KompasPaywallVideo extends LitElement {
87
105
  <div>
88
106
  <span>Sudah punya akun? </span>
89
107
  <button
90
- @click=${this.redirectToLogin}
108
+ @click=${() => redirectToLogin('video_paywall')}
91
109
  class="text-blue-300 font-bold"
92
110
  >
93
111
  Masuk<span class="text-grey-300 font-normal">.</span>
@@ -115,8 +133,8 @@ export class KompasPaywallVideo extends LitElement {
115
133
  @click=${this.redirectToSelectedPackage}
116
134
  class="bg-green-500 rounded md:rounded-lg h-8 md:h-12 px-4 md:px-6 text-sm md:text-lg text-white font-bold leading-[18px]"
117
135
  >
118
- Langganan ${formatRupiah(this.showPackage.price)}
119
- /${this.generateCopyDuration(this.showPackage.durationType)}
136
+ Langganan ${formatRupiah(this.packageData.price)}
137
+ /${generateCopyDuration(this.packageData.durationType)}
120
138
  </button>
121
139
  <button
122
140
  @click=${this.redirectToBerlangganan}
@@ -141,12 +159,12 @@ export class KompasPaywallVideo extends LitElement {
141
159
  event,
142
160
  paywall_location: this.paywall_location,
143
161
  paywall_subscription_package:
144
- this.paywall_subscription_package || this.showPackage.title,
162
+ this.paywall_subscription_package || this.packageData.title,
145
163
  paywall_subscription_id:
146
- this.paywall_subscription_id || this.showPackage.id,
164
+ this.paywall_subscription_id || this.packageData.id,
147
165
  paywall_subscription_price:
148
- this.paywall_subscription_price || this.showPackage.price,
149
- paywall_position: this.paywall_position || this.showPackage.position,
166
+ this.paywall_subscription_price || this.packageData.price,
167
+ paywall_position: this.paywall_position || this.packageData.position,
150
168
  user_type: this.tracker_user_type,
151
169
  subscription_status: this.tracker_subscription_status,
152
170
  page_domain: this.tracker_page_domain || 'Kompas.id',
@@ -203,42 +221,21 @@ export class KompasPaywallVideo extends LitElement {
203
221
  return this.type === 'article'
204
222
  }
205
223
 
206
- // temporary mocking data package for component and dataLayer
207
- get showPackage() {
208
- return {
209
- duration: 1,
210
- durationType: 3,
211
- id: '9802035',
212
- link: 'kdp?productId=9802035&referrer=https%3A%2F%2Fwww.kompas.cloud%2Fberlangganan',
213
- price: 50000,
214
- position: 1,
215
- title: 'Kompas Digital Premium 1 Bulan',
216
- }
217
- }
218
-
219
224
  /**
220
225
  * Logic Function
221
226
  */
222
227
 
223
- private redirectToRegister(triggerClick: string): void {
228
+ private onRegisterClick(triggerClick: string): void {
224
229
  this.sendDataLayeronButtonLogin(triggerClick)
225
- const registerHost: string = 'https://account.kompas.id/register'
226
- const nextParams: string = encodeURIComponent(window.location.href)
227
- const directUrlRegister: string = `${registerHost}?next=${nextParams}?status=sukses_login&status_login=login&loc=video_paywall`
228
- window.open(directUrlRegister, '_blank')
229
- }
230
-
231
- private redirectToLogin(): void {
232
- const loginHost: string = 'https://account.kompas.id/login'
233
- const nextParams: string = encodeURIComponent(window.location.href)
234
- const directUrlLogin: string = `${loginHost}?next=${nextParams}&loc=video_paywall`
235
- window.open(directUrlLogin, '_blank')
230
+ redirectToRegister('video_paywall')
236
231
  }
237
232
 
238
233
  private redirectToSelectedPackage(): void {
239
- const url = `${this.checkoutHost}/${this.showPackage.link}&source=${this.type}`
240
234
  this.sendDataLayerSubscribeButtonClicked()
241
- window.open(url, '_blank')
235
+ redirectToCheckout({
236
+ link: `${this.packageData.link}${this.packageData.referrer}`,
237
+ source: this.type,
238
+ })
242
239
  }
243
240
 
244
241
  private redirectToBerlangganan(): void {
@@ -246,25 +243,13 @@ export class KompasPaywallVideo extends LitElement {
246
243
  window.open(this.subscriptionUrl, '_blank')
247
244
  }
248
245
 
249
- private generateCopyDuration(type: number): string {
250
- switch (type) {
251
- case 1:
252
- return 'hari'
253
- case 2:
254
- return 'minggu'
255
- case 3:
256
- return 'bulan'
257
- case 4:
258
- return 'tahun'
259
- default:
260
- return ''
261
- }
262
- }
263
-
264
246
  override async connectedCallback() {
265
247
  super.connectedCallback()
266
248
  await this.updateComplete
267
249
  addGoogleFonts(['pt-sans'])
250
+
251
+ const originHost: string = encodeURIComponent(window.location.href)
252
+ this.packageData = { ...this.showPackage, referrer: originHost }
268
253
  }
269
254
 
270
255
  /**
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ export { KompasPaywall } from './components/kompasid-paywall/KompasPaywall.js'
2
2
  export { KompasFooter } from './components/kompasid-footer/KompasFooter.js'
3
3
  export { KompasPaywallVideo } from './components/kompasid-paywall-video/KompasPaywallVideo.js'
4
4
  export { KompasMeteredPaywall } from './components/kompasid-metered-paywall/KompasMeteredPaywall.js'
5
+ export { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js'
5
6
 
6
7
  declare global {
7
8
  interface Window {
@@ -0,0 +1,25 @@
1
+ export function redirectToRegister(loc: string): void {
2
+ const loginHost: string = 'https://account.kompas.id/register'
3
+ const nextParams: string = encodeURIComponent(window.location.href)
4
+ const directUrlRegister: string = `${loginHost}?next=${nextParams}?status=sukses_login&status_login=login&loc=${loc}`
5
+ window.location.href = directUrlRegister
6
+ }
7
+
8
+ export function redirectToLogin(loc: string): void {
9
+ const loginHost: string = 'https://account.kompas.id/login'
10
+ const nextParams: string = encodeURIComponent(window.location.href)
11
+ const directUrlLogin: string = `${loginHost}?next=${nextParams}&loc=${loc}`
12
+ window.open(directUrlLogin, '_blank')
13
+ }
14
+
15
+ export function redirectToCheckout({
16
+ link,
17
+ source,
18
+ }: {
19
+ link: string
20
+ source: string
21
+ }): void {
22
+ const checkoutHost = 'https://checkoutv2.kompas.id'
23
+ const url = `${checkoutHost}/${link}&source=${source}`
24
+ window.open(url, '_blank')
25
+ }
@@ -0,0 +1,14 @@
1
+ export const generateCopyDuration = (type: number): string => {
2
+ switch (type) {
3
+ case 1:
4
+ return 'hari'
5
+ case 2:
6
+ return 'minggu'
7
+ case 3:
8
+ return 'bulan'
9
+ case 4:
10
+ return 'tahun'
11
+ default:
12
+ return ''
13
+ }
14
+ }
@@ -3,6 +3,8 @@ export const addGoogleFonts = (fonts: string[]) => {
3
3
  lora: 'https://fonts.googleapis.com/css2?family=Lora:wght@700&display=swap',
4
4
  'pt-sans':
5
5
  'https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap',
6
+ 'roboto-condensed':
7
+ 'https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@500&display=swap',
6
8
  }
7
9
 
8
10
  fonts.forEach(font => {