@kompasid/lit-web-components 0.4.0 → 0.4.2
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/.github/workflows/npm-publish.yml +2 -2
- package/assets/video.jpg +0 -0
- package/demo/index.html +28 -27
- package/dist/src/components/kompasid-footer/KompasFooter.d.ts +1 -2
- package/dist/src/components/kompasid-footer/KompasFooter.js +4 -9
- package/dist/src/components/kompasid-footer/KompasFooter.js.map +1 -1
- package/dist/src/components/kompasid-paywall/KompasPaywall.js +5 -8
- package/dist/src/components/kompasid-paywall/KompasPaywall.js.map +1 -1
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.d.ts +34 -8
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js +359 -262
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js.map +1 -1
- package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.d.ts +42 -5
- package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js +182 -107
- package/dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js.map +1 -1
- package/dist/src/utils/formatRupiah.d.ts +1 -0
- package/dist/src/utils/formatRupiah.js +7 -0
- package/dist/src/utils/formatRupiah.js.map +1 -0
- package/dist/src/utils/googleFont.d.ts +1 -0
- package/dist/src/utils/googleFont.js +17 -0
- package/dist/src/utils/googleFont.js.map +1 -0
- package/dist/tailwind/tailwind.js +123 -95
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-footer/KompasFooter.ts +4 -11
- package/src/components/kompasid-paywall/KompasPaywall.ts +5 -8
- package/src/components/kompasid-paywall-body/KompasPaywallBody.ts +332 -210
- package/src/components/kompasid-paywall-video/KompasPaywallVideo.ts +178 -90
- package/src/components/kompasid-paywall-video/readme.md +1 -0
- package/src/utils/formatRupiah.ts +6 -0
- package/src/utils/googleFont.ts +19 -0
- package/tailwind/tailwind.css +120 -92
- package/tailwind/tailwind.ts +123 -95
- package/tailwind.config.js +3 -1
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/* eslint-disable class-methods-use-this */
|
|
2
|
-
import { html, css, LitElement } from 'lit'
|
|
2
|
+
import { html, css, LitElement, nothing } from 'lit'
|
|
3
3
|
import { property, customElement, state } from 'lit/decorators.js'
|
|
4
4
|
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
5
5
|
import { deviceType } from '../../utils/deviceType.js'
|
|
6
|
+
import { formatRupiah } from '../../utils/formatRupiah.js'
|
|
7
|
+
import { addGoogleFonts } from '../../utils/googleFont.js'
|
|
6
8
|
|
|
7
9
|
@customElement('kompasid-paywall-video')
|
|
8
10
|
export class KompasPaywallVideo extends LitElement {
|
|
9
|
-
static styles = [
|
|
11
|
+
static styles = [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
font-family: 'PT Sans', sans-serif;
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
17
|
+
TWStyles,
|
|
18
|
+
]
|
|
10
19
|
|
|
11
20
|
/**
|
|
12
21
|
* Props
|
|
@@ -28,11 +37,9 @@ export class KompasPaywallVideo extends LitElement {
|
|
|
28
37
|
* prop page_domain = Page Domain
|
|
29
38
|
* prop metered_wall_type = The type of Metered Wall
|
|
30
39
|
* prop metered_wall_balance = The balance of their metered wall
|
|
40
|
+
* prop type = The type of video paywall
|
|
31
41
|
*/
|
|
32
42
|
|
|
33
|
-
@state() private subscriptionUrl: string =
|
|
34
|
-
'https://www.kompas.id/berlangganan'
|
|
35
|
-
|
|
36
43
|
@property({ type: Boolean }) isLogin = false
|
|
37
44
|
@property({ type: String }) paywall_location = ''
|
|
38
45
|
@property({ type: String }) paywall_subscription_package = ''
|
|
@@ -49,24 +56,41 @@ export class KompasPaywallVideo extends LitElement {
|
|
|
49
56
|
@property({ type: String }) tracker_page_domain = ''
|
|
50
57
|
@property({ type: String }) tracker_metered_wall_type = ''
|
|
51
58
|
@property({ type: Number }) tracker_metered_wall_balance = 0
|
|
59
|
+
@property({ type: String }) type: 'article' | 'homepage' = 'article'
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* State
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
@state() private subscriptionUrl: string =
|
|
66
|
+
'https://www.kompas.id/berlangganan'
|
|
67
|
+
@state() private checkoutHost: string = 'https://checkoutv2.kompas.id'
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Component
|
|
71
|
+
*/
|
|
52
72
|
|
|
53
|
-
private
|
|
73
|
+
private regulerRegistrationSection() {
|
|
54
74
|
return html`
|
|
55
|
-
<div
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
<div
|
|
76
|
+
class="flex flex-col text-white text-sm md:text-base items-center justify-center"
|
|
77
|
+
>
|
|
78
|
+
<div>
|
|
79
|
+
<button
|
|
80
|
+
@click=${() => this.redirectToRegister('Daftar')}
|
|
81
|
+
class="text-blue-300 font-bold"
|
|
82
|
+
>
|
|
83
|
+
Daftar
|
|
84
|
+
</button>
|
|
85
|
+
<span> untuk akses konten gratis.</span>
|
|
86
|
+
</div>
|
|
87
|
+
<div>
|
|
88
|
+
<span>Sudah punya akun? </span>
|
|
65
89
|
<button
|
|
66
|
-
@click=${
|
|
67
|
-
class="
|
|
90
|
+
@click=${this.redirectToLogin}
|
|
91
|
+
class="text-blue-300 font-bold"
|
|
68
92
|
>
|
|
69
|
-
|
|
93
|
+
Masuk<span class="text-white font-normal">.</span>
|
|
70
94
|
</button>
|
|
71
95
|
</div>
|
|
72
96
|
</div>
|
|
@@ -75,73 +99,88 @@ export class KompasPaywallVideo extends LitElement {
|
|
|
75
99
|
|
|
76
100
|
private defaultComponent() {
|
|
77
101
|
return html`
|
|
78
|
-
<div>
|
|
79
|
-
${this.sendDataLayeronNonLogin()} ${this.
|
|
102
|
+
<div class="flex flex-col items-center space-y-2 md:space-y-4">
|
|
103
|
+
${this.sendDataLayeronNonLogin()} ${this.sendDataLayerPaywallViewed()}
|
|
80
104
|
<h5
|
|
81
|
-
class="leading-6 text-white text-center text-base md:
|
|
105
|
+
class="leading-5 md:leading-6 w-[296px] md:w-[400px] text-white text-center text-base mb-2 md:mb-0 ${!this
|
|
106
|
+
.isLogin &&
|
|
107
|
+
!this.isArticle &&
|
|
108
|
+
'mb-0'} md:text-xl max-w-xl"
|
|
82
109
|
>
|
|
83
|
-
|
|
84
|
-
|
|
110
|
+
${this.isArticle
|
|
111
|
+
? 'Langganan untuk lanjut menonton video'
|
|
112
|
+
: 'Langganan sekarang untuk akses seluruh konten Kompas.id'}
|
|
85
113
|
</h5>
|
|
86
|
-
<
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
class="rounded text-sm text-white px-4 py-1.5 ring-1 ring-grey-100"
|
|
90
|
-
>
|
|
91
|
-
Masuk
|
|
92
|
-
</button>
|
|
93
|
-
<button
|
|
94
|
-
@click=${() => this.redirectToBerlangganan()}
|
|
95
|
-
class="bg-green-500 rounded px-4 py-1.5 text-sm text-white font-bold"
|
|
96
|
-
>
|
|
97
|
-
Berlangganan
|
|
98
|
-
</button>
|
|
99
|
-
</div>
|
|
100
|
-
<p
|
|
101
|
-
class="text-center text-sm leading-4 text-white mt-6 max-w-xs md:max-w-none"
|
|
114
|
+
<button
|
|
115
|
+
@click=${this.redirectToSelectedPackage}
|
|
116
|
+
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]"
|
|
102
117
|
>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
Langganan ${formatRupiah(this.showPackage.price)}
|
|
119
|
+
/${this.generateCopyDuration(this.showPackage.durationType)}
|
|
120
|
+
</button>
|
|
121
|
+
<button
|
|
122
|
+
@click=${this.redirectToBerlangganan}
|
|
123
|
+
class="text-sm md:text-lg leading-[22px] text-white font-bold underline ${!this
|
|
124
|
+
.isLogin && this.isArticle
|
|
125
|
+
? 'pb-3'
|
|
126
|
+
: 'pb-2'} md:pb-4"
|
|
127
|
+
>
|
|
128
|
+
Paket Lainnya
|
|
129
|
+
</button>
|
|
130
|
+
${!this.isLogin ? this.regulerRegistrationSection() : nothing}
|
|
112
131
|
</div>
|
|
113
132
|
`
|
|
114
133
|
}
|
|
115
134
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
interface: deviceType(),
|
|
120
|
-
})
|
|
121
|
-
}
|
|
135
|
+
/**
|
|
136
|
+
* Data Layer
|
|
137
|
+
*/
|
|
122
138
|
|
|
123
|
-
private
|
|
124
|
-
|
|
125
|
-
event
|
|
139
|
+
private sendDataLayer(event: string): void {
|
|
140
|
+
const baseData = {
|
|
141
|
+
event,
|
|
126
142
|
paywall_location: this.paywall_location,
|
|
127
|
-
paywall_subscription_package:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
content_categories: this.tracker_content_categories,
|
|
135
|
-
content_type: this.tracker_content_type,
|
|
143
|
+
paywall_subscription_package:
|
|
144
|
+
this.paywall_subscription_package || this.showPackage.title,
|
|
145
|
+
paywall_subscription_id:
|
|
146
|
+
this.paywall_subscription_id || this.showPackage.id,
|
|
147
|
+
paywall_subscription_price:
|
|
148
|
+
this.paywall_subscription_price || this.showPackage.price,
|
|
149
|
+
paywall_position: this.paywall_position || this.showPackage.position,
|
|
136
150
|
user_type: this.tracker_user_type,
|
|
137
151
|
subscription_status: this.tracker_subscription_status,
|
|
138
152
|
page_domain: this.tracker_page_domain || 'Kompas.id',
|
|
139
153
|
metered_wall_type: this.tracker_metered_wall_type || 'HP',
|
|
140
154
|
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
141
|
-
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const data = this.isArticle
|
|
158
|
+
? {
|
|
159
|
+
...baseData,
|
|
160
|
+
page_type: this.tracker_page_type,
|
|
161
|
+
content_id: this.tracker_content_id,
|
|
162
|
+
content_title: this.tracker_content_title,
|
|
163
|
+
content_categories: this.tracker_content_categories,
|
|
164
|
+
content_type: this.tracker_content_type,
|
|
165
|
+
}
|
|
166
|
+
: baseData
|
|
167
|
+
|
|
168
|
+
window.dataLayer.push(data)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private sendDataLayerPaywallViewed(): void {
|
|
172
|
+
this.sendDataLayer('paywall_viewed')
|
|
142
173
|
}
|
|
143
174
|
|
|
144
|
-
private
|
|
175
|
+
private sendDataLayerSubscribeButtonClicked(): void {
|
|
176
|
+
this.sendDataLayer('subscribe_button_clicked')
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private sendDataLayerOtherPackagesClicked(): void {
|
|
180
|
+
this.sendDataLayer('other_packages_clicked')
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private sendDataLayeronButtonLogin(triggerClick: string): void {
|
|
145
184
|
window.dataLayer.push({
|
|
146
185
|
event: 'registrationOfferClick',
|
|
147
186
|
interface: deviceType(),
|
|
@@ -149,46 +188,95 @@ export class KompasPaywallVideo extends LitElement {
|
|
|
149
188
|
})
|
|
150
189
|
}
|
|
151
190
|
|
|
152
|
-
private
|
|
191
|
+
private sendDataLayeronNonLogin(): void {
|
|
153
192
|
window.dataLayer.push({
|
|
154
|
-
event: '
|
|
155
|
-
|
|
156
|
-
paywall_subscription_package: this.paywall_subscription_package,
|
|
157
|
-
paywall_subscription_id: this.paywall_subscription_id,
|
|
158
|
-
paywall_subscription_price: this.paywall_subscription_price,
|
|
159
|
-
paywall_position: this.paywall_position,
|
|
160
|
-
page_type: this.tracker_page_type,
|
|
161
|
-
content_id: this.tracker_content_id,
|
|
162
|
-
content_title: this.tracker_content_title,
|
|
163
|
-
content_categories: this.tracker_content_categories,
|
|
164
|
-
content_type: this.tracker_content_type,
|
|
165
|
-
user_type: this.tracker_user_type,
|
|
166
|
-
subscription_status: this.tracker_subscription_status,
|
|
167
|
-
page_domain: this.tracker_page_domain || 'Kompas.id',
|
|
168
|
-
metered_wall_type: this.tracker_metered_wall_type || 'HP',
|
|
169
|
-
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
193
|
+
event: 'registrationOfferimppression',
|
|
194
|
+
interface: deviceType(),
|
|
170
195
|
})
|
|
171
196
|
}
|
|
172
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Getter
|
|
200
|
+
*/
|
|
201
|
+
|
|
202
|
+
get isArticle() {
|
|
203
|
+
return this.type === 'article'
|
|
204
|
+
}
|
|
205
|
+
|
|
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
|
+
/**
|
|
220
|
+
* Logic Function
|
|
221
|
+
*/
|
|
222
|
+
|
|
173
223
|
private redirectToRegister(triggerClick: string): void {
|
|
174
224
|
this.sendDataLayeronButtonLogin(triggerClick)
|
|
175
225
|
const registerHost: string = 'https://account.kompas.id/register'
|
|
176
226
|
const nextParams: string = encodeURIComponent(window.location.href)
|
|
177
|
-
const directUrlRegister: string = `${registerHost}?next=${nextParams}?status=sukses_login&status_login=login`
|
|
227
|
+
const directUrlRegister: string = `${registerHost}?next=${nextParams}?status=sukses_login&status_login=login&loc=video_paywall`
|
|
178
228
|
window.open(directUrlRegister, '_blank')
|
|
179
229
|
}
|
|
180
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')
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private redirectToSelectedPackage(): void {
|
|
239
|
+
const url = `${this.checkoutHost}/${this.showPackage.link}&source=${this.type}`
|
|
240
|
+
this.sendDataLayerSubscribeButtonClicked()
|
|
241
|
+
window.open(url, '_blank')
|
|
242
|
+
}
|
|
243
|
+
|
|
181
244
|
private redirectToBerlangganan(): void {
|
|
182
|
-
this.
|
|
245
|
+
this.sendDataLayerOtherPackagesClicked()
|
|
183
246
|
window.open(this.subscriptionUrl, '_blank')
|
|
184
247
|
}
|
|
185
248
|
|
|
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
|
+
override async connectedCallback() {
|
|
265
|
+
super.connectedCallback()
|
|
266
|
+
await this.updateComplete
|
|
267
|
+
addGoogleFonts(['pt-sans'])
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Render Statement
|
|
272
|
+
*/
|
|
273
|
+
|
|
186
274
|
render() {
|
|
187
275
|
return html`
|
|
188
276
|
<div
|
|
189
|
-
class="radius absolute z-20 bg-black bg-opacity-
|
|
277
|
+
class="radius absolute z-20 bg-black bg-opacity-75 p-4 top-0 bottom-0 left-0 flex flex-col w-full h-full justify-center items-center"
|
|
190
278
|
>
|
|
191
|
-
${this.
|
|
279
|
+
${this.defaultComponent()}
|
|
192
280
|
</div>
|
|
193
281
|
`
|
|
194
282
|
}
|
|
@@ -36,6 +36,7 @@ Contoh Penerapan:
|
|
|
36
36
|
| `tracker_page_type` | `tracker_page_type` | prop page_type = Type of the page | `string` | `''` |
|
|
37
37
|
| `tracker_subscription_status` | `tracker_subscription_status` | prop subscription_status = Status of their subscription | `string` | `''` |
|
|
38
38
|
| `tracker_user_type` | `tracker_user_type` | prop user_type = Type of user based on their subscription | `string` | `''` |
|
|
39
|
+
| `type` | `type` | prop type = The type of video paywall | `"article" \| "homepage"` | `"article"` |
|
|
39
40
|
|
|
40
41
|
----------------------------------------------
|
|
41
42
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const addGoogleFonts = (fonts: string[]) => {
|
|
2
|
+
const fontMap: { [key: string]: string } = {
|
|
3
|
+
lora: 'https://fonts.googleapis.com/css2?family=Lora:wght@700&display=swap',
|
|
4
|
+
'pt-sans':
|
|
5
|
+
'https://fonts.googleapis.com/css2?family=PT+Sans:ital,wght@0,400;0,700;1,400;1,700&display=swap',
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
fonts.forEach(font => {
|
|
9
|
+
const fontCssUrl = fontMap[font]
|
|
10
|
+
const existingElement = document.querySelector(`link[href="${fontCssUrl}"]`)
|
|
11
|
+
|
|
12
|
+
if (!existingElement && fontCssUrl) {
|
|
13
|
+
const newElement = document.createElement('link')
|
|
14
|
+
newElement.setAttribute('rel', 'stylesheet')
|
|
15
|
+
newElement.setAttribute('href', fontCssUrl)
|
|
16
|
+
document.head.appendChild(newElement)
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
}
|