@kompasid/lit-web-components 0.9.10 → 0.9.13
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 +2 -2
- package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +9 -24
- package/dist/src/components/kompasid-freewall/KompasFreewall.js +44 -100
- package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.d.ts +96 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js +305 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js.map +1 -0
- package/dist/src/components/kompasid-freewall/types.d.ts +26 -0
- package/dist/src/components/kompasid-freewall/types.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +9 -14
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +58 -102
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.d.ts +34 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js +228 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js.map +1 -0
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +8 -19
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +33 -52
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -1
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.d.ts +38 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js +125 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js.map +1 -0
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +1 -1
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +10 -13
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
- package/dist/src/components/kompasid-metered-paywall/KompasMeteredPaywall.js +19 -17
- package/dist/src/components/kompasid-metered-paywall/KompasMeteredPaywall.js.map +1 -1
- package/dist/tailwind/tailwind.js +50 -10
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-freewall/KompasFreewall.ts +52 -85
- package/src/components/kompasid-freewall/old_KompasFreewall.ts +255 -0
- package/src/components/kompasid-freewall/readme.md +40 -84
- package/src/components/kompasid-freewall/types.ts +29 -0
- package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +59 -101
- package/src/components/kompasid-freewall-body/old_KompasFreewallBody.ts +224 -0
- package/src/components/kompasid-freewall-body/readme.md +31 -7
- package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +31 -39
- package/src/components/kompasid-freewall-head/old_KompasFreewallHead.ts +103 -0
- package/src/components/kompasid-freewall-head/readme.md +29 -13
- package/src/components/kompasid-grace-period/KompasGracePeriod.ts +1 -1
- package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +10 -13
- package/src/components/kompasid-metered-paywall/KompasMeteredPaywall.ts +21 -18
- package/tailwind/tailwind.css +50 -8
- package/tailwind/tailwind.ts +50 -10
- package/tailwind.config.js +1 -1
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html, css, LitElement, nothing } from 'lit';
|
|
3
|
+
import { property, customElement, state } from 'lit/decorators.js';
|
|
4
|
+
import { TWStyles } from '../../../tailwind/tailwind.js';
|
|
5
|
+
import { redirectToCheckout } from '../../utils/cta.js';
|
|
6
|
+
import '../kompasid-freewall-head/KompasFreewallHead.js';
|
|
7
|
+
import '../kompasid-freewall-body/KompasFreewallBody.js';
|
|
8
|
+
let KompasFreewall = class KompasFreewall extends LitElement {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* Props
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* property isLogin untuk menghandle apakah user sudah login atau belum
|
|
16
|
+
* property type untuk menghandle tipe freewall
|
|
17
|
+
* property head_copy_expand to update copy header when expand
|
|
18
|
+
* property head_copy_collapse to update copy header when collapse
|
|
19
|
+
* property expand to handle expand/collapse
|
|
20
|
+
* property paywall_location is the location where user encounter the paywall
|
|
21
|
+
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
22
|
+
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
23
|
+
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
24
|
+
* property paywall_position is the position of the subscription package viewed by user
|
|
25
|
+
* property tracker_page_type is the type of the page
|
|
26
|
+
* property tracker_page_title is the title of the page
|
|
27
|
+
* property tracker_content_id is the ID of article (slug)
|
|
28
|
+
* property content_title is the title of article
|
|
29
|
+
* property tracker_content_categories is the category of the content
|
|
30
|
+
* property tracker_content_type is to decide whether it's free article or paid article
|
|
31
|
+
* property tracker_user_type is the type of user based on their subscription
|
|
32
|
+
* property tracker_subscription_status is the status of their subscription
|
|
33
|
+
* property tracker_page_domain is the page domain
|
|
34
|
+
* property tracker_metered_wall_type is the type of metered wall
|
|
35
|
+
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
36
|
+
*/
|
|
37
|
+
this.isLogin = false;
|
|
38
|
+
this.type = 'article';
|
|
39
|
+
this.head_copy_expand = '';
|
|
40
|
+
this.head_copy_collapse = '';
|
|
41
|
+
this.expand = true;
|
|
42
|
+
this.paywall_location = '';
|
|
43
|
+
this.paywall_subscription_package = '';
|
|
44
|
+
this.paywall_subscription_id = 0;
|
|
45
|
+
this.paywall_subscription_price = 0;
|
|
46
|
+
this.paywall_position = 1;
|
|
47
|
+
this.tracker_page_type = '';
|
|
48
|
+
this.tracker_page_title = '';
|
|
49
|
+
this.tracker_content_id = '';
|
|
50
|
+
this.tracker_content_title = '';
|
|
51
|
+
this.tracker_content_categories = '';
|
|
52
|
+
this.tracker_content_type = '';
|
|
53
|
+
this.tracker_user_type = '';
|
|
54
|
+
this.tracker_subscription_status = '';
|
|
55
|
+
this.tracker_page_domain = '';
|
|
56
|
+
this.tracker_metered_wall_type = '';
|
|
57
|
+
this.tracker_metered_wall_balance = 0;
|
|
58
|
+
this.showPackage = {
|
|
59
|
+
duration: 1,
|
|
60
|
+
durationType: 3,
|
|
61
|
+
id: '9802035',
|
|
62
|
+
link: 'kdp?productId=9802035&referrer=',
|
|
63
|
+
price: 50000,
|
|
64
|
+
position: 1,
|
|
65
|
+
title: 'Kompas Digital Premium 1 Bulan',
|
|
66
|
+
slug: 'cash-b2c-halaman-berlangganan-reguler_digital-kdp-1',
|
|
67
|
+
referrer: '',
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* State
|
|
71
|
+
*/
|
|
72
|
+
this.isLoading = true;
|
|
73
|
+
this.isExpand = true;
|
|
74
|
+
this.packageData = {};
|
|
75
|
+
this.jsonPackageData = {};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Getter
|
|
79
|
+
*/
|
|
80
|
+
get isArticle() {
|
|
81
|
+
return this.type === 'article';
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Data Layer
|
|
85
|
+
*/
|
|
86
|
+
prepareImpressionsData() {
|
|
87
|
+
const baseData = {
|
|
88
|
+
paywall_location: this.paywall_location,
|
|
89
|
+
paywall_subscription_package: this.paywall_subscription_package || this.packageData.slug,
|
|
90
|
+
paywall_subscription_id: this.paywall_subscription_id || this.packageData.id,
|
|
91
|
+
paywall_subscription_price: this.paywall_subscription_price || this.packageData.price,
|
|
92
|
+
paywall_position: this.paywall_position || this.packageData.position,
|
|
93
|
+
user_type: this.tracker_user_type,
|
|
94
|
+
subscription_status: this.tracker_subscription_status,
|
|
95
|
+
page_domain: this.tracker_page_domain || 'Kompas.id',
|
|
96
|
+
page_type: this.tracker_page_type,
|
|
97
|
+
metered_wall_type: this.tracker_metered_wall_type || 'FP',
|
|
98
|
+
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
99
|
+
};
|
|
100
|
+
if (this.isArticle) {
|
|
101
|
+
return {
|
|
102
|
+
...baseData,
|
|
103
|
+
content_id: this.tracker_content_id,
|
|
104
|
+
content_title: this.tracker_content_title,
|
|
105
|
+
content_categories: this.tracker_content_categories,
|
|
106
|
+
content_type: this.tracker_content_type,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
...baseData,
|
|
111
|
+
page_title: this.tracker_page_title,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
sendDataLayer(event, includeImpressions = false) {
|
|
115
|
+
const impressionsData = this.prepareImpressionsData();
|
|
116
|
+
const data = includeImpressions
|
|
117
|
+
? { event, impressions: [impressionsData] }
|
|
118
|
+
: { event, ...impressionsData };
|
|
119
|
+
window.dataLayer.push(data);
|
|
120
|
+
}
|
|
121
|
+
sendDataLayerPaywallViewed() {
|
|
122
|
+
if (this.isExpand)
|
|
123
|
+
this.sendDataLayer('paywall_viewed', true);
|
|
124
|
+
}
|
|
125
|
+
sendDataLayerSubscribeButtonClicked() {
|
|
126
|
+
this.sendDataLayer('subscribe_button_clicked');
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Logic Function
|
|
130
|
+
*/
|
|
131
|
+
toggleExpand() {
|
|
132
|
+
this.isExpand = !this.isExpand;
|
|
133
|
+
this.sendDataLayerPaywallViewed();
|
|
134
|
+
}
|
|
135
|
+
onSubscriptionClick() {
|
|
136
|
+
this.sendDataLayerSubscribeButtonClicked();
|
|
137
|
+
redirectToCheckout({
|
|
138
|
+
link: `${this.jsonPackageData.subscriptionUrl}&referrer=${this.packageData.referrer}`,
|
|
139
|
+
source: this.type,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Lifecycle
|
|
144
|
+
*/
|
|
145
|
+
async connectedCallback() {
|
|
146
|
+
super.connectedCallback();
|
|
147
|
+
await this.updateComplete;
|
|
148
|
+
this.isExpand = this.expand;
|
|
149
|
+
const originHost = encodeURIComponent(window.location.href);
|
|
150
|
+
this.packageData = { ...this.showPackage, referrer: originHost };
|
|
151
|
+
this.getFreewallData();
|
|
152
|
+
this.sendDataLayerPaywallViewed();
|
|
153
|
+
}
|
|
154
|
+
async getFreewallData() {
|
|
155
|
+
try {
|
|
156
|
+
const response = await fetch('https://cdn-www.kompas.id/web-component/freewall.json');
|
|
157
|
+
const json = await response.json();
|
|
158
|
+
this.jsonPackageData = {
|
|
159
|
+
headCopyCollapse: json.headCopyCollapse,
|
|
160
|
+
headCopyExpand: json.headCopyExpand,
|
|
161
|
+
subscriptionUrl: json.subscriptionUrl,
|
|
162
|
+
subscriptionTitle: json.subscriptionTitle,
|
|
163
|
+
subscriptionTitleGuest: json.subscriptionTitleGuest,
|
|
164
|
+
subscriptionDescription: json.subscriptionDescription,
|
|
165
|
+
subscriptionButtonText: json.subscriptionButtonText,
|
|
166
|
+
registerTitle: json.registerTitle,
|
|
167
|
+
registerDescription: json.registerDescription,
|
|
168
|
+
registerButtonText: json.registerButtonText,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
throw Error('Failed to get metered paywall data');
|
|
173
|
+
}
|
|
174
|
+
finally {
|
|
175
|
+
this.isLoading = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Render Statement
|
|
180
|
+
*/
|
|
181
|
+
render() {
|
|
182
|
+
return !this.isLoading
|
|
183
|
+
? html `
|
|
184
|
+
<div class="sticky bottom-0 w-full h-full z-20 top-shadow">
|
|
185
|
+
<div
|
|
186
|
+
class="flex flex-col w-full bg-blue-100 justify-center ${this
|
|
187
|
+
.isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24"
|
|
188
|
+
>
|
|
189
|
+
<kompasid-freewall-head
|
|
190
|
+
.expand=${this.isExpand}
|
|
191
|
+
.type=${this.type}
|
|
192
|
+
.head_copy_expand=${this.jsonPackageData.headCopyExpand}
|
|
193
|
+
.head_copy_collapse=${this.jsonPackageData.headCopyCollapse}
|
|
194
|
+
.toggleExpand=${() => this.toggleExpand()}
|
|
195
|
+
.onSubscriptionClick=${() => this.onSubscriptionClick()}
|
|
196
|
+
.packageData=${this.packageData}
|
|
197
|
+
.jsonPackageData=${this.jsonPackageData}
|
|
198
|
+
></kompasid-freewall-head>
|
|
199
|
+
${this.isExpand
|
|
200
|
+
? html `<kompasid-freewall-body
|
|
201
|
+
.type=${this.type}
|
|
202
|
+
.onSubscriptionClick=${() => this.onSubscriptionClick()}
|
|
203
|
+
.packageData=${this.packageData}
|
|
204
|
+
.jsonPackageData=${this.jsonPackageData}
|
|
205
|
+
?isLogin=${this.isLogin}
|
|
206
|
+
></kompasid-freewall-body>`
|
|
207
|
+
: nothing}
|
|
208
|
+
</div>
|
|
209
|
+
</div>
|
|
210
|
+
`
|
|
211
|
+
: nothing;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
KompasFreewall.styles = [
|
|
215
|
+
css `
|
|
216
|
+
:host {
|
|
217
|
+
font-family: 'PT Sans', sans-serif;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.top-shadow {
|
|
221
|
+
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);
|
|
222
|
+
}
|
|
223
|
+
`,
|
|
224
|
+
TWStyles,
|
|
225
|
+
];
|
|
226
|
+
__decorate([
|
|
227
|
+
property({ type: Boolean })
|
|
228
|
+
], KompasFreewall.prototype, "isLogin", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property({ type: String })
|
|
231
|
+
], KompasFreewall.prototype, "type", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ type: String })
|
|
234
|
+
], KompasFreewall.prototype, "head_copy_expand", void 0);
|
|
235
|
+
__decorate([
|
|
236
|
+
property({ type: String })
|
|
237
|
+
], KompasFreewall.prototype, "head_copy_collapse", void 0);
|
|
238
|
+
__decorate([
|
|
239
|
+
property({ type: Boolean })
|
|
240
|
+
], KompasFreewall.prototype, "expand", void 0);
|
|
241
|
+
__decorate([
|
|
242
|
+
property({ type: String })
|
|
243
|
+
], KompasFreewall.prototype, "paywall_location", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
property({ type: String })
|
|
246
|
+
], KompasFreewall.prototype, "paywall_subscription_package", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property({ type: Number })
|
|
249
|
+
], KompasFreewall.prototype, "paywall_subscription_id", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property({ type: Number })
|
|
252
|
+
], KompasFreewall.prototype, "paywall_subscription_price", void 0);
|
|
253
|
+
__decorate([
|
|
254
|
+
property({ type: Number })
|
|
255
|
+
], KompasFreewall.prototype, "paywall_position", void 0);
|
|
256
|
+
__decorate([
|
|
257
|
+
property({ type: String })
|
|
258
|
+
], KompasFreewall.prototype, "tracker_page_type", void 0);
|
|
259
|
+
__decorate([
|
|
260
|
+
property({ type: String })
|
|
261
|
+
], KompasFreewall.prototype, "tracker_page_title", void 0);
|
|
262
|
+
__decorate([
|
|
263
|
+
property({ type: String })
|
|
264
|
+
], KompasFreewall.prototype, "tracker_content_id", void 0);
|
|
265
|
+
__decorate([
|
|
266
|
+
property({ type: String })
|
|
267
|
+
], KompasFreewall.prototype, "tracker_content_title", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
property({ type: String })
|
|
270
|
+
], KompasFreewall.prototype, "tracker_content_categories", void 0);
|
|
271
|
+
__decorate([
|
|
272
|
+
property({ type: String })
|
|
273
|
+
], KompasFreewall.prototype, "tracker_content_type", void 0);
|
|
274
|
+
__decorate([
|
|
275
|
+
property({ type: String })
|
|
276
|
+
], KompasFreewall.prototype, "tracker_user_type", void 0);
|
|
277
|
+
__decorate([
|
|
278
|
+
property({ type: String })
|
|
279
|
+
], KompasFreewall.prototype, "tracker_subscription_status", void 0);
|
|
280
|
+
__decorate([
|
|
281
|
+
property({ type: String })
|
|
282
|
+
], KompasFreewall.prototype, "tracker_page_domain", void 0);
|
|
283
|
+
__decorate([
|
|
284
|
+
property({ type: String })
|
|
285
|
+
], KompasFreewall.prototype, "tracker_metered_wall_type", void 0);
|
|
286
|
+
__decorate([
|
|
287
|
+
property({ type: Number })
|
|
288
|
+
], KompasFreewall.prototype, "tracker_metered_wall_balance", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
state()
|
|
291
|
+
], KompasFreewall.prototype, "isLoading", void 0);
|
|
292
|
+
__decorate([
|
|
293
|
+
state()
|
|
294
|
+
], KompasFreewall.prototype, "isExpand", void 0);
|
|
295
|
+
__decorate([
|
|
296
|
+
state()
|
|
297
|
+
], KompasFreewall.prototype, "packageData", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
state()
|
|
300
|
+
], KompasFreewall.prototype, "jsonPackageData", void 0);
|
|
301
|
+
KompasFreewall = __decorate([
|
|
302
|
+
customElement('kompasid-freewall')
|
|
303
|
+
], KompasFreewall);
|
|
304
|
+
export { KompasFreewall };
|
|
305
|
+
//# sourceMappingURL=old_KompasFreewall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"old_KompasFreewall.js","sourceRoot":"","sources":["../../../../src/components/kompasid-freewall/old_KompasFreewall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,iDAAiD,CAAA;AACxD,OAAO,iDAAiD,CAAA;AAGjD,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAcL;;WAEG;QACH;;;;;;;;;;;;;;;;;;;;;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AC;kEAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAiC;AAkBnD;IAAR,KAAK,EAAE;iDAAkC;AACjC;IAAR,KAAK,EAAE;gDAAiC;AAChC;IAAR,KAAK,EAAE;mDAAqD;AACpD;IAAR,KAAK,EAAE;uDAAiE;AAlF9D,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CAqP1B;SArPY,cAAc","sourcesContent":["import { html, css, LitElement, nothing } from 'lit'\nimport { property, customElement, state } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { JsonPackageData, PackageData } from './types.js'\nimport { redirectToCheckout } from '../../utils/cta.js'\nimport '../kompasid-freewall-head/KompasFreewallHead.js'\nimport '../kompasid-freewall-body/KompasFreewallBody.js'\n\n@customElement('kompasid-freewall')\nexport class KompasFreewall extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .top-shadow {\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property isLogin untuk menghandle apakah user sudah login atau belum\n * property type untuk menghandle tipe freewall\n * property head_copy_expand to update copy header when expand\n * property head_copy_collapse to update copy header when collapse\n * property expand to handle expand/collapse\n * property paywall_location is the location where user encounter the paywall\n * property paywall_subscription_package is the name of the subscription package viewed by user\n * property paywall_subscription_id is the ID of the subscription package viewed by user\n * property paywall_subscription_price is the price of the subscription package viewed by user\n * property paywall_position is the position of the subscription package viewed by user\n * property tracker_page_type is the type of the page\n * property tracker_page_title is the title of the page\n * property tracker_content_id is the ID of article (slug)\n * property content_title is the title of article\n * property tracker_content_categories is the category of the content\n * property tracker_content_type is to decide whether it's free article or paid article\n * property tracker_user_type is the type of user based on their subscription\n * property tracker_subscription_status is the status of their subscription\n * property tracker_page_domain is the page domain\n * property tracker_metered_wall_type is the type of metered wall\n * property tracker_metered_wall_balance is the balance of their metered wall\n */\n\n @property({ type: Boolean }) isLogin = false\n @property({ type: String }) type: 'article' | 'landing_page' = 'article'\n @property({ type: String }) head_copy_expand = ''\n @property({ type: String }) head_copy_collapse = ''\n @property({ type: Boolean }) expand = true\n @property({ type: String }) paywall_location = ''\n @property({ type: String }) paywall_subscription_package = ''\n @property({ type: Number }) paywall_subscription_id = 0\n @property({ type: Number }) paywall_subscription_price = 0\n @property({ type: Number }) paywall_position = 1\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_page_title = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n showPackage = {\n duration: 1,\n durationType: 3,\n id: '9802035',\n link: 'kdp?productId=9802035&referrer=',\n price: 50000,\n position: 1,\n title: 'Kompas Digital Premium 1 Bulan',\n slug: 'cash-b2c-halaman-berlangganan-reguler_digital-kdp-1',\n referrer: '',\n }\n\n /**\n * State\n */\n\n @state() private isLoading: Boolean = true\n @state() private isExpand: boolean = true\n @state() private packageData: PackageData = {} as PackageData\n @state() private jsonPackageData: JsonPackageData = {} as JsonPackageData\n\n /**\n * Getter\n */\n\n get isArticle() {\n return this.type === 'article'\n }\n\n /**\n * Data Layer\n */\n\n private prepareImpressionsData(): Record<string, any> {\n const baseData = {\n paywall_location: this.paywall_location,\n paywall_subscription_package:\n this.paywall_subscription_package || this.packageData.slug,\n paywall_subscription_id:\n this.paywall_subscription_id || this.packageData.id,\n paywall_subscription_price:\n this.paywall_subscription_price || this.packageData.price,\n paywall_position: this.paywall_position || this.packageData.position,\n user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n page_type: this.tracker_page_type,\n metered_wall_type: this.tracker_metered_wall_type || 'FP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n\n if (this.isArticle) {\n return {\n ...baseData,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_categories: this.tracker_content_categories,\n content_type: this.tracker_content_type,\n }\n }\n return {\n ...baseData,\n page_title: this.tracker_page_title,\n }\n }\n\n private sendDataLayer(\n event: string,\n includeImpressions: boolean = false\n ): void {\n const impressionsData = this.prepareImpressionsData()\n\n const data = includeImpressions\n ? { event, impressions: [impressionsData] }\n : { event, ...impressionsData }\n\n window.dataLayer.push(data)\n }\n\n private sendDataLayerPaywallViewed(): void {\n if (this.isExpand) this.sendDataLayer('paywall_viewed', true)\n }\n\n private sendDataLayerSubscribeButtonClicked(): void {\n this.sendDataLayer('subscribe_button_clicked')\n }\n\n /**\n * Logic Function\n */\n\n private toggleExpand() {\n this.isExpand = !this.isExpand\n this.sendDataLayerPaywallViewed()\n }\n\n private onSubscriptionClick() {\n this.sendDataLayerSubscribeButtonClicked()\n redirectToCheckout({\n link: `${this.jsonPackageData.subscriptionUrl}&referrer=${this.packageData.referrer}`,\n source: this.type,\n })\n }\n\n /**\n * Lifecycle\n */\n\n override async connectedCallback() {\n super.connectedCallback()\n await this.updateComplete\n\n this.isExpand = this.expand\n\n const originHost: string = encodeURIComponent(window.location.href)\n this.packageData = { ...this.showPackage, referrer: originHost }\n this.getFreewallData()\n\n this.sendDataLayerPaywallViewed()\n }\n\n async getFreewallData() {\n try {\n const response = await fetch(\n 'https://cdn-www.kompas.id/web-component/freewall.json'\n )\n const json = await response.json()\n this.jsonPackageData = {\n headCopyCollapse: json.headCopyCollapse,\n headCopyExpand: json.headCopyExpand,\n subscriptionUrl: json.subscriptionUrl,\n subscriptionTitle: json.subscriptionTitle,\n subscriptionTitleGuest: json.subscriptionTitleGuest,\n subscriptionDescription: json.subscriptionDescription,\n subscriptionButtonText: json.subscriptionButtonText,\n registerTitle: json.registerTitle,\n registerDescription: json.registerDescription,\n registerButtonText: json.registerButtonText,\n }\n } catch (error) {\n throw Error('Failed to get metered paywall data')\n } finally {\n this.isLoading = false\n }\n }\n\n /**\n * Render Statement\n */\n\n render() {\n return !this.isLoading\n ? html`\n <div class=\"sticky bottom-0 w-full h-full z-20 top-shadow\">\n <div\n class=\"flex flex-col w-full bg-blue-100 justify-center ${this\n .isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24\"\n >\n <kompasid-freewall-head\n .expand=${this.isExpand}\n .type=${this.type}\n .head_copy_expand=${this.jsonPackageData.headCopyExpand}\n .head_copy_collapse=${this.jsonPackageData.headCopyCollapse}\n .toggleExpand=${() => this.toggleExpand()}\n .onSubscriptionClick=${() => this.onSubscriptionClick()}\n .packageData=${this.packageData}\n .jsonPackageData=${this.jsonPackageData}\n ></kompasid-freewall-head>\n ${this.isExpand\n ? html`<kompasid-freewall-body\n .type=${this.type}\n .onSubscriptionClick=${() => this.onSubscriptionClick()}\n .packageData=${this.packageData}\n .jsonPackageData=${this.jsonPackageData}\n ?isLogin=${this.isLogin}\n ></kompasid-freewall-body>`\n : nothing}\n </div>\n </div>\n `\n : nothing\n }\n}\n"]}
|
|
@@ -21,3 +21,29 @@ export interface JsonPackageData {
|
|
|
21
21
|
registerDescription: string[];
|
|
22
22
|
registerButtonText: string;
|
|
23
23
|
}
|
|
24
|
+
export interface CardPackage {
|
|
25
|
+
title: string;
|
|
26
|
+
ribbon: boolean;
|
|
27
|
+
packageSlug: string;
|
|
28
|
+
packageId: string;
|
|
29
|
+
priceBased: number;
|
|
30
|
+
priceDiscount: number;
|
|
31
|
+
position: number;
|
|
32
|
+
duration: string;
|
|
33
|
+
cta: {
|
|
34
|
+
text: string;
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface HeadDataFreeWall {
|
|
39
|
+
headCopyExpand: string;
|
|
40
|
+
headCopyCollapse: string;
|
|
41
|
+
cta: {
|
|
42
|
+
text: string;
|
|
43
|
+
url: string;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface JsonPullDataFreeWall {
|
|
47
|
+
head: HeadDataFreeWall;
|
|
48
|
+
body: CardPackage[];
|
|
49
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-freewall/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface PackageData {\n duration: number\n durationType: number\n id: string\n link: string\n price: number\n position: number\n title: string\n slug: string\n referrer: string\n}\n\nexport interface JsonPackageData {\n headCopyCollapse: string\n headCopyExpand: string\n subscriptionUrl: string\n subscriptionTitle: string\n subscriptionTitleGuest: string\n subscriptionDescription: string[]\n subscriptionButtonText: string\n registerTitle: string\n registerDescription: string[]\n registerButtonText: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-freewall/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface PackageData {\n duration: number\n durationType: number\n id: string\n link: string\n price: number\n position: number\n title: string\n slug: string\n referrer: string\n}\n\nexport interface JsonPackageData {\n headCopyCollapse: string\n headCopyExpand: string\n subscriptionUrl: string\n subscriptionTitle: string\n subscriptionTitleGuest: string\n subscriptionDescription: string[]\n subscriptionButtonText: string\n registerTitle: string\n registerDescription: string[]\n registerButtonText: string\n}\n\nexport interface CardPackage {\n title: string\n ribbon: boolean\n packageSlug: string\n packageId: string\n priceBased: number\n priceDiscount: number\n position: number\n duration: string\n cta: {\n text: string\n url: string\n }\n}\n\nexport interface HeadDataFreeWall {\n headCopyExpand: string\n headCopyCollapse: string\n cta: {\n text: string\n url: string\n }\n}\n\nexport interface JsonPullDataFreeWall {\n head: HeadDataFreeWall\n body: CardPackage[]\n}\n"]}
|
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import {
|
|
2
|
+
import { CardPackage } from '../kompasid-freewall/types.js';
|
|
3
3
|
export declare class KompasFreewallBody extends LitElement {
|
|
4
4
|
static styles: import("lit").CSSResult[];
|
|
5
5
|
/**
|
|
6
6
|
* Props
|
|
7
7
|
*/
|
|
8
8
|
/**
|
|
9
|
-
* property
|
|
10
|
-
* property
|
|
11
|
-
* property onSubscriptionClick to handle cta when subscription button is clicked
|
|
12
|
-
* packageData sebagai data package yang diambil dari kompasid-freewall
|
|
9
|
+
* property bodyData to handle multiple data card CardPackage
|
|
10
|
+
* property onButtonClick to handle cta when button is clicked and set specific card url and position
|
|
13
11
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
description: string[];
|
|
12
|
+
onButtonClick: (url: string, position: number) => {
|
|
13
|
+
url: string;
|
|
14
|
+
position: number;
|
|
15
|
+
};
|
|
16
|
+
bodyData: CardPackage[];
|
|
20
17
|
/**
|
|
21
18
|
* Lifecycle
|
|
22
19
|
*/
|
|
@@ -24,9 +21,7 @@ export declare class KompasFreewallBody extends LitElement {
|
|
|
24
21
|
/**
|
|
25
22
|
* Component
|
|
26
23
|
*/
|
|
27
|
-
private
|
|
28
|
-
private registerCardComponent;
|
|
29
|
-
private descriptionSection;
|
|
24
|
+
private newCard;
|
|
30
25
|
/**
|
|
31
26
|
* Render Statement
|
|
32
27
|
*/
|
|
@@ -3,8 +3,7 @@ import { html, css, LitElement, nothing } from 'lit';
|
|
|
3
3
|
import { property, customElement } from 'lit/decorators.js';
|
|
4
4
|
import { TWStyles } from '../../../tailwind/tailwind.js';
|
|
5
5
|
import { addGoogleFonts } from '../../utils/googleFont.js';
|
|
6
|
-
import {
|
|
7
|
-
import { redirectToRegister } from '../../utils/cta.js';
|
|
6
|
+
import { formatRupiah } from '../../utils/formatRupiah.js';
|
|
8
7
|
let KompasFreewallBody = class KompasFreewallBody extends LitElement {
|
|
9
8
|
constructor() {
|
|
10
9
|
super(...arguments);
|
|
@@ -12,21 +11,14 @@ let KompasFreewallBody = class KompasFreewallBody extends LitElement {
|
|
|
12
11
|
* Props
|
|
13
12
|
*/
|
|
14
13
|
/**
|
|
15
|
-
* property
|
|
16
|
-
* property
|
|
17
|
-
* property onSubscriptionClick to handle cta when subscription button is clicked
|
|
18
|
-
* packageData sebagai data package yang diambil dari kompasid-freewall
|
|
14
|
+
* property bodyData to handle multiple data card CardPackage
|
|
15
|
+
* property onButtonClick to handle cta when button is clicked and set specific card url and position
|
|
19
16
|
*/
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.
|
|
25
|
-
this.description = [
|
|
26
|
-
'Akses seluruh konten Kompas.id di web & aplikasi',
|
|
27
|
-
'ePaper hingga 30 edisi terakhir',
|
|
28
|
-
'Buku digital tiap bulannya di aplikasi ',
|
|
29
|
-
];
|
|
17
|
+
this.onButtonClick = (url, position) => ({
|
|
18
|
+
url,
|
|
19
|
+
position,
|
|
20
|
+
});
|
|
21
|
+
this.bodyData = [];
|
|
30
22
|
}
|
|
31
23
|
/**
|
|
32
24
|
* Lifecycle
|
|
@@ -39,107 +31,80 @@ let KompasFreewallBody = class KompasFreewallBody extends LitElement {
|
|
|
39
31
|
/**
|
|
40
32
|
* Component
|
|
41
33
|
*/
|
|
42
|
-
|
|
34
|
+
newCard(item) {
|
|
43
35
|
return html `
|
|
44
|
-
<div class="relative">
|
|
36
|
+
<div class="relative snap-start scroll-mx-4 w-[276px] flex lg:w-auto">
|
|
45
37
|
<div
|
|
46
38
|
id="subscription-card"
|
|
47
|
-
class="flex justify-between items-
|
|
48
|
-
.isLogin
|
|
49
|
-
? 'md:w-[580px]'
|
|
50
|
-
: 'md:w-[350px] lg:w-[410px]'} py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] border-2 border-yellow-400 bg-white"
|
|
39
|
+
class="flex justify-between items-start relative z-10 flex-col w-[328px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white border border-grey-300"
|
|
51
40
|
>
|
|
52
|
-
<div
|
|
53
|
-
class="
|
|
54
|
-
|
|
55
|
-
: 'items-start text-start'}"
|
|
56
|
-
>
|
|
57
|
-
<h5
|
|
58
|
-
class="font-lora text-lg md:text-xl font-bold leading-[30px] ${this
|
|
59
|
-
.isLogin && 'w-60 md:w-full'} text-grey-600"
|
|
60
|
-
>
|
|
61
|
-
${this.isLogin
|
|
62
|
-
? this.jsonPackageData.subscriptionTitle
|
|
63
|
-
: this.jsonPackageData.subscriptionTitleGuest}
|
|
41
|
+
<div class="flex w-full flex-col items-start mb-4 text-start">
|
|
42
|
+
<h5 class="font-lora leading-[30px] text-grey-600">
|
|
43
|
+
${item.title}
|
|
64
44
|
</h5>
|
|
65
|
-
|
|
45
|
+
</div>
|
|
46
|
+
<div class="text-xl text-grey-600 font-lora mb-8">
|
|
47
|
+
<div>
|
|
48
|
+
${item.priceDiscount
|
|
49
|
+
? html `
|
|
50
|
+
<span class="text-sm text-grey-400"
|
|
51
|
+
><s>${formatRupiah(item.priceBased)}</s></span
|
|
52
|
+
>
|
|
53
|
+
`
|
|
54
|
+
: nothing}
|
|
55
|
+
<span class="${item.priceDiscount ? 'text-orange-400' : ''}"
|
|
56
|
+
>${formatRupiah(item.priceDiscount ? item.priceDiscount : item.priceBased)}</span
|
|
57
|
+
>/<span>${item.duration}</span>
|
|
58
|
+
</div>
|
|
59
|
+
${item.priceDiscount
|
|
60
|
+
? html ` <div class="text-sm text-grey-500 font-sans mt-3">
|
|
61
|
+
Selanjutnya ${formatRupiah(item.priceBased)}/${item.duration}
|
|
62
|
+
</div>`
|
|
63
|
+
: nothing}
|
|
66
64
|
</div>
|
|
67
65
|
<button
|
|
68
|
-
@click=${this.
|
|
69
|
-
class="
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
@click=${() => this.onButtonClick(item.cta.url, item.position)}
|
|
67
|
+
class="whitespace-nowrap w-full rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base font-bold leading-[18px] ${item.ribbon
|
|
68
|
+
? 'text-white bg-brand-1'
|
|
69
|
+
: 'text-brand-1 bg-white border border-brand-1'}"
|
|
72
70
|
>
|
|
73
|
-
${
|
|
71
|
+
${item.cta.text}
|
|
74
72
|
</button>
|
|
75
73
|
</div>
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
${item.ribbon
|
|
75
|
+
? html `<div id="ribbon-container">
|
|
76
|
+
<div
|
|
77
|
+
class="text-[11px] font-medium text-grey-600 font-roboto-condensed flex justify-center items-center"
|
|
78
|
+
>
|
|
79
|
+
<span class="-ml-2">Penawaran Terbaik</span>
|
|
80
|
+
</div>
|
|
81
|
+
</div>`
|
|
82
|
+
: nothing}
|
|
83
83
|
</div>
|
|
84
84
|
`;
|
|
85
85
|
}
|
|
86
|
-
registerCardComponent() {
|
|
87
|
-
return html `
|
|
88
|
-
<div
|
|
89
|
-
class="flex flex-col justify-between md:min-h-[244px] lg:min-h-[220px] w-[328px] md:w-[350px] lg:w-[410px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white"
|
|
90
|
-
>
|
|
91
|
-
<div>
|
|
92
|
-
<h5
|
|
93
|
-
class="font-lora text-lg md:text-xl font-bold leading-[30px] text-grey-600"
|
|
94
|
-
>
|
|
95
|
-
${this.jsonPackageData.registerTitle}
|
|
96
|
-
</h5>
|
|
97
|
-
<div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
|
|
98
|
-
${this.jsonPackageData.registerDescription.map(item => html `
|
|
99
|
-
<div class="flex items-start lg:items-center">
|
|
100
|
-
<div class="mt-1 lg:mt-0">${faCheck()}</div>
|
|
101
|
-
<h6 class="text-base text-grey-600 ml-1 text-start">
|
|
102
|
-
${item}
|
|
103
|
-
</h6>
|
|
104
|
-
</div>
|
|
105
|
-
`)}
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
<button
|
|
109
|
-
@click=${() => redirectToRegister('freewall')}
|
|
110
|
-
class="bg-white border border-brand-1 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-brand-1 font-bold leading-[18px]"
|
|
111
|
-
>
|
|
112
|
-
${this.jsonPackageData.registerButtonText}
|
|
113
|
-
</button>
|
|
114
|
-
</div>
|
|
115
|
-
`;
|
|
116
|
-
}
|
|
117
|
-
descriptionSection() {
|
|
118
|
-
return html `<div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
|
|
119
|
-
${this.jsonPackageData.subscriptionDescription.map(item => html `
|
|
120
|
-
<div class="flex items-start lg:items-center">
|
|
121
|
-
<div class="mt-1 lg:mt-0">${faCheck()}</div>
|
|
122
|
-
<h6 class="text-base text-grey-600 ml-1 text-start">${item}</h6>
|
|
123
|
-
</div>
|
|
124
|
-
`)}
|
|
125
|
-
</div>`;
|
|
126
|
-
}
|
|
127
86
|
/**
|
|
128
87
|
* Render Statement
|
|
129
88
|
*/
|
|
130
89
|
render() {
|
|
131
90
|
return html `
|
|
132
91
|
<div
|
|
133
|
-
class="w-full h-full flex flex-
|
|
92
|
+
class="w-full h-full flex flex-row pt-[5px] relative snap-x overflow-x-scroll gap-4 hideScroll px-4 sm:px-0 sm:gap-6 sm:justify-center"
|
|
134
93
|
>
|
|
135
|
-
${this.
|
|
136
|
-
${!this.isLogin ? this.registerCardComponent() : nothing}
|
|
94
|
+
${this.bodyData.map(item => this.newCard(item))}
|
|
137
95
|
</div>
|
|
138
96
|
`;
|
|
139
97
|
}
|
|
140
98
|
};
|
|
141
99
|
KompasFreewallBody.styles = [
|
|
142
100
|
css `
|
|
101
|
+
.hideScroll::-webkit-scrollbar {
|
|
102
|
+
height: 0px;
|
|
103
|
+
}
|
|
104
|
+
.hideScroll {
|
|
105
|
+
scrollbar-width: none;
|
|
106
|
+
}
|
|
107
|
+
|
|
143
108
|
.font-lora {
|
|
144
109
|
font-family: 'Lora', 'Georgia', 'serif';
|
|
145
110
|
}
|
|
@@ -206,21 +171,12 @@ KompasFreewallBody.styles = [
|
|
|
206
171
|
`,
|
|
207
172
|
TWStyles,
|
|
208
173
|
];
|
|
209
|
-
__decorate([
|
|
210
|
-
property({ type: Boolean })
|
|
211
|
-
], KompasFreewallBody.prototype, "isLogin", void 0);
|
|
212
|
-
__decorate([
|
|
213
|
-
property({ type: String })
|
|
214
|
-
], KompasFreewallBody.prototype, "type", void 0);
|
|
215
174
|
__decorate([
|
|
216
175
|
property()
|
|
217
|
-
], KompasFreewallBody.prototype, "
|
|
218
|
-
__decorate([
|
|
219
|
-
property({ type: Object })
|
|
220
|
-
], KompasFreewallBody.prototype, "packageData", void 0);
|
|
176
|
+
], KompasFreewallBody.prototype, "onButtonClick", void 0);
|
|
221
177
|
__decorate([
|
|
222
178
|
property({ type: Object })
|
|
223
|
-
], KompasFreewallBody.prototype, "
|
|
179
|
+
], KompasFreewallBody.prototype, "bodyData", void 0);
|
|
224
180
|
KompasFreewallBody = __decorate([
|
|
225
181
|
customElement('kompasid-freewall-body')
|
|
226
182
|
], KompasFreewallBody);
|