@kompasid/lit-web-components 0.8.0 → 0.8.1
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 +38 -2
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.d.ts +5 -0
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +68 -31
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.d.ts +18 -0
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +78 -0
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -1
- package/dist/src/components/kompasid-header-account/types.d.ts +2 -0
- package/dist/src/components/kompasid-header-account/types.js.map +1 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.d.ts +29 -2
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +115 -57
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-grace-period/KompasGracePeriod.ts +68 -30
- package/src/components/kompasid-grace-period/readme.md +2 -0
- package/src/components/kompasid-header-account/KompasHeaderAccount.ts +34 -0
- package/src/components/kompasid-header-account/types.ts +2 -0
- package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +84 -56
package/demo/index.html
CHANGED
|
@@ -101,11 +101,14 @@
|
|
|
101
101
|
const subscriptionUrl = ''
|
|
102
102
|
const readLaterUrl = '/baca-nanti'
|
|
103
103
|
const totalGracePeriod = '5'
|
|
104
|
+
const productId = 9802032
|
|
104
105
|
|
|
105
106
|
const userData = {
|
|
106
107
|
userName: 'User Fullname',
|
|
107
108
|
expired: 'Berakhir: 6 hari lagi',
|
|
108
109
|
isNearExpired: false,
|
|
110
|
+
totalGracePeriod: 2,
|
|
111
|
+
isGracePeriod: true,
|
|
109
112
|
activeInfo:
|
|
110
113
|
'Kompas Digital Premium 1 Bulan - Auto Renewal Example Text',
|
|
111
114
|
isMembership: true,
|
|
@@ -144,6 +147,21 @@
|
|
|
144
147
|
.subscription_url=${subscriptionUrl}
|
|
145
148
|
.read_later_url=${readLaterUrl}
|
|
146
149
|
.total_grace_period=${totalGracePeriod}
|
|
150
|
+
.paywall_location=${paywallLocation}
|
|
151
|
+
.paywall_subscription_package=${paywallSubscriptionPackage}
|
|
152
|
+
.paywall_subscription_id=${productId}
|
|
153
|
+
.paywall_subscription_price=${paywallSubscriptionPrice}
|
|
154
|
+
.paywall_position=${paywallPosition}
|
|
155
|
+
.tracker_page_type=${trackerPageType}
|
|
156
|
+
.tracker_content_id=${trackerContentId}
|
|
157
|
+
.tracker_content_type=${trackerContentType}
|
|
158
|
+
.tracker_content_title=${trackerContentTitle}
|
|
159
|
+
.tracker_content_categories=${trackerContentCategories}
|
|
160
|
+
.tracker_user_type=${trackerUserType}
|
|
161
|
+
.tracker_subscription_status=${trackerSubscriptionStatus}
|
|
162
|
+
.tracker_page_domain=${trackerPageDomain}
|
|
163
|
+
.metered_wall_type=${meteredWallType}
|
|
164
|
+
.tracker_metered_wall_balance=${trackerMeteredWallBalance}
|
|
147
165
|
style="margin-left: auto; height: 25px; display: flex; align-items: center"
|
|
148
166
|
></kompasid-header-account>
|
|
149
167
|
</div>
|
|
@@ -262,11 +280,29 @@
|
|
|
262
280
|
.tracker_page_domain=${trackerPageDomain}
|
|
263
281
|
></kompasid-metered-wall-register>
|
|
264
282
|
|
|
265
|
-
<!-- <kompasid-grace-period
|
|
283
|
+
<!-- <kompasid-grace-period
|
|
284
|
+
totalGracePeriod="2"
|
|
285
|
+
isShowButton="true"
|
|
286
|
+
.paywall_location=${paywallLocation}
|
|
287
|
+
.paywall_subscription_id=${productId}
|
|
288
|
+
.paywall_subscription_price=${paywallSubscriptionPrice}
|
|
289
|
+
.paywall_position=${paywallPosition}
|
|
290
|
+
.tracker_page_type=${trackerPageType}
|
|
291
|
+
.tracker_page_title=${trackerPageTitle}
|
|
292
|
+
.tracker_content_id=${trackerContentId}
|
|
293
|
+
.tracker_content_type=${trackerContentType}
|
|
294
|
+
.tracker_content_title=${trackerContentTitle}
|
|
295
|
+
.tracker_content_categories=${trackerContentCategories}
|
|
296
|
+
.tracker_user_type=${trackerUserType}
|
|
297
|
+
.tracker_page_domain=${trackerPageDomain}
|
|
298
|
+
.tracker_metered_wall_type=${meteredWallType}
|
|
299
|
+
.tracker_subscription_status=${trackerSubscriptionStatus}
|
|
300
|
+
.tracker_metered_wall_balance=${trackerMeteredWallBalance}
|
|
301
|
+
></kompasid-grace-period> -->
|
|
266
302
|
`,
|
|
267
303
|
document.querySelector('#demo')
|
|
268
304
|
)
|
|
269
305
|
window.dataLayer = window.dataLayer || []
|
|
270
306
|
</script>
|
|
271
307
|
</body>
|
|
272
|
-
</html>
|
|
308
|
+
</html>
|
|
@@ -8,6 +8,7 @@ export declare class KompasGracePeriod extends LitElement {
|
|
|
8
8
|
* property totalGracePeriod = how many days are left in grace period
|
|
9
9
|
* property isColumn = changes how the component looks on different screen sizes
|
|
10
10
|
* property isShowButton = shows or hides a subscription button
|
|
11
|
+
* property isEpaper = is paywall opened in epaper page
|
|
11
12
|
* property paywall_location = the location where user encounter the paywall
|
|
12
13
|
* property paywall_subscription_package = the name of the subscription package viewed by user
|
|
13
14
|
* property paywall_subscription_id = the ID of the subscription package viewed by user
|
|
@@ -23,10 +24,13 @@ export declare class KompasGracePeriod extends LitElement {
|
|
|
23
24
|
* property tracker_page_domain = page Domain
|
|
24
25
|
* property tracker_metered_wall_type = the type of Metered Wall
|
|
25
26
|
* property tracker_metered_wall_balance = the balance of their metered wall
|
|
27
|
+
* property tracker_epaper_edition = the edition of epaper viewed by user
|
|
26
28
|
*/
|
|
27
29
|
totalGracePeriod: number;
|
|
28
30
|
isColumn: boolean;
|
|
29
31
|
isShowButton: boolean;
|
|
32
|
+
isEpaper: boolean;
|
|
33
|
+
isBackgroundOnContentOnly: boolean;
|
|
30
34
|
paywall_location: string;
|
|
31
35
|
paywall_subscription_package: string;
|
|
32
36
|
paywall_subscription_id: number;
|
|
@@ -42,6 +46,7 @@ export declare class KompasGracePeriod extends LitElement {
|
|
|
42
46
|
tracker_page_domain: string;
|
|
43
47
|
tracker_metered_wall_type: string;
|
|
44
48
|
tracker_metered_wall_balance: number;
|
|
49
|
+
tracker_epaper_edition: string;
|
|
45
50
|
/**
|
|
46
51
|
* State
|
|
47
52
|
*/
|
|
@@ -13,6 +13,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
13
13
|
* property totalGracePeriod = how many days are left in grace period
|
|
14
14
|
* property isColumn = changes how the component looks on different screen sizes
|
|
15
15
|
* property isShowButton = shows or hides a subscription button
|
|
16
|
+
* property isEpaper = is paywall opened in epaper page
|
|
16
17
|
* property paywall_location = the location where user encounter the paywall
|
|
17
18
|
* property paywall_subscription_package = the name of the subscription package viewed by user
|
|
18
19
|
* property paywall_subscription_id = the ID of the subscription package viewed by user
|
|
@@ -28,10 +29,13 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
28
29
|
* property tracker_page_domain = page Domain
|
|
29
30
|
* property tracker_metered_wall_type = the type of Metered Wall
|
|
30
31
|
* property tracker_metered_wall_balance = the balance of their metered wall
|
|
32
|
+
* property tracker_epaper_edition = the edition of epaper viewed by user
|
|
31
33
|
*/
|
|
32
34
|
this.totalGracePeriod = 0;
|
|
33
35
|
this.isColumn = false;
|
|
34
36
|
this.isShowButton = false;
|
|
37
|
+
this.isEpaper = false;
|
|
38
|
+
this.isBackgroundOnContentOnly = false;
|
|
35
39
|
this.paywall_location = '';
|
|
36
40
|
this.paywall_subscription_package = '';
|
|
37
41
|
this.paywall_subscription_id = 0;
|
|
@@ -47,6 +51,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
47
51
|
this.tracker_page_domain = '';
|
|
48
52
|
this.tracker_metered_wall_type = '';
|
|
49
53
|
this.tracker_metered_wall_balance = 0;
|
|
54
|
+
this.tracker_epaper_edition = '';
|
|
50
55
|
/**
|
|
51
56
|
* State
|
|
52
57
|
*/
|
|
@@ -78,7 +83,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
78
83
|
}
|
|
79
84
|
redirectToBerlangganan() {
|
|
80
85
|
this.dataLayeronPerbaruiLanggananButton();
|
|
81
|
-
this.sendGtmEvent('subscribe_button_clicked');
|
|
86
|
+
this.sendGtmEvent('subscribe_button_clicked', true);
|
|
82
87
|
window.open(this.subscriptionPage);
|
|
83
88
|
}
|
|
84
89
|
redirectToCheckout() {
|
|
@@ -87,36 +92,46 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
87
92
|
this.sendGtmEvent('subscribe_button_clicked');
|
|
88
93
|
window.open(`${this.checkoutPage}/kdp?productId=${this.paywall_subscription_id}&referrer=${originHost}&source=article`);
|
|
89
94
|
}
|
|
90
|
-
getGtmParams() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
page_type
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
95
|
+
getGtmParams(excludeSubscriptionParams = false) {
|
|
96
|
+
const gtmParams = {};
|
|
97
|
+
if (!this.isEpaper) {
|
|
98
|
+
gtmParams.content_title = this.tracker_content_title;
|
|
99
|
+
gtmParams.content_id = this.tracker_content_id;
|
|
100
|
+
gtmParams.content_categories = this.tracker_content_categories;
|
|
101
|
+
gtmParams.content_type = this.tracker_content_type;
|
|
102
|
+
gtmParams.page_type = this.tracker_page_type;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
gtmParams.epaper_edition = this.tracker_epaper_edition;
|
|
106
|
+
}
|
|
107
|
+
if (!excludeSubscriptionParams) {
|
|
108
|
+
gtmParams.paywall_subscription_package = this.paywall_subscription_package;
|
|
109
|
+
gtmParams.paywall_subscription_id = this.paywall_subscription_id;
|
|
110
|
+
gtmParams.paywall_subscription_price = this.paywall_subscription_price;
|
|
111
|
+
}
|
|
112
|
+
gtmParams.paywall_location = this.paywall_location;
|
|
113
|
+
gtmParams.paywall_position = this.paywall_position;
|
|
114
|
+
gtmParams.user_type = this.tracker_user_type;
|
|
115
|
+
gtmParams.subscription_status = this.tracker_subscription_status;
|
|
116
|
+
gtmParams.page_domain = this.tracker_page_domain || 'Kompas.id';
|
|
117
|
+
gtmParams.metered_wall_type = this.tracker_metered_wall_type || 'GP';
|
|
118
|
+
gtmParams.metered_wall_balance = this.tracker_metered_wall_balance;
|
|
119
|
+
return gtmParams;
|
|
108
120
|
}
|
|
109
|
-
sendGtmEvent(event) {
|
|
121
|
+
sendGtmEvent(event, excludeSubscriptionParams = false) {
|
|
110
122
|
let gtmParams = { event };
|
|
111
123
|
if (event === 'paywall_viewed') {
|
|
112
124
|
gtmParams.impressions = [
|
|
113
125
|
{
|
|
114
|
-
...this.getGtmParams(),
|
|
126
|
+
...this.getGtmParams(excludeSubscriptionParams),
|
|
115
127
|
},
|
|
116
128
|
];
|
|
117
129
|
}
|
|
118
130
|
else {
|
|
119
|
-
gtmParams = {
|
|
131
|
+
gtmParams = {
|
|
132
|
+
...gtmParams,
|
|
133
|
+
...this.getGtmParams(excludeSubscriptionParams),
|
|
134
|
+
};
|
|
120
135
|
}
|
|
121
136
|
window.dataLayer.push(gtmParams);
|
|
122
137
|
}
|
|
@@ -137,19 +152,31 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
137
152
|
});
|
|
138
153
|
}
|
|
139
154
|
gracePeriodTemplate() {
|
|
155
|
+
const { isColumn, isBackgroundOnContentOnly } = this;
|
|
156
|
+
const wrapperColumnClass = isColumn
|
|
157
|
+
? 'rounded-lg'
|
|
158
|
+
: 'md:flex-row lg:px-8 md:space-x-4 px-4 py-4';
|
|
159
|
+
const buttonColumnClass = isColumn
|
|
160
|
+
? ''
|
|
161
|
+
: 'md:w-1/2 justify-end md:flex-row pt-4 md:pt-0';
|
|
162
|
+
const otherBtnColumnClass = isColumn ? '' : 'md:w-auto';
|
|
163
|
+
const wrapperBgClass = !isBackgroundOnContentOnly ? 'p-4' : '';
|
|
164
|
+
const contentBgClass = isBackgroundOnContentOnly
|
|
165
|
+
? 'bg-orange-100 p-4 rounded-lg mb-4'
|
|
166
|
+
: '';
|
|
140
167
|
return html `
|
|
141
168
|
<div
|
|
142
|
-
class="${
|
|
143
|
-
? 'rounded-lg'
|
|
144
|
-
: 'md:flex-row lg:px-8'} bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end px-4 py-4 md:space-x-4"
|
|
169
|
+
class="bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}"
|
|
145
170
|
>
|
|
146
|
-
<div
|
|
171
|
+
<div
|
|
172
|
+
class="self-center text-left text-sm text-grey-600 md:text-base ${contentBgClass}"
|
|
173
|
+
>
|
|
147
174
|
${this.getCountdownGracePeriod()}
|
|
148
175
|
</div>
|
|
149
|
-
${
|
|
176
|
+
${this.isShowButton
|
|
150
177
|
? html `
|
|
151
178
|
<div
|
|
152
|
-
class="flex w-full flex-col
|
|
179
|
+
class="flex w-full flex-col gap-4 self-center ${buttonColumnClass}"
|
|
153
180
|
>
|
|
154
181
|
<button
|
|
155
182
|
@click=${this.redirectToCheckout}
|
|
@@ -160,7 +187,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
160
187
|
<div class="md:block hidden">
|
|
161
188
|
<button
|
|
162
189
|
@click=${this.redirectToBerlangganan}
|
|
163
|
-
class="bg-transparent w-full rounded-md border border-green-500 p-
|
|
190
|
+
class="bg-transparent w-full rounded-md border border-green-500 p-1.5 px-5 text-sm font-bold text-green-500 md:text-base ${otherBtnColumnClass}"
|
|
164
191
|
>
|
|
165
192
|
Paket Lainnya
|
|
166
193
|
</button>
|
|
@@ -168,7 +195,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
168
195
|
<div class="md:hidden block">
|
|
169
196
|
<button
|
|
170
197
|
@click=${this.redirectToBerlangganan}
|
|
171
|
-
class="bg-transparent w-full rounded-md border border-green-500 p-
|
|
198
|
+
class="bg-transparent w-full rounded-md border border-green-500 p-1.5 px-5 text-sm font-bold text-green-500 md:text-base ${otherBtnColumnClass}"
|
|
172
199
|
>
|
|
173
200
|
Lihat Paket Lainnya
|
|
174
201
|
</button>
|
|
@@ -185,8 +212,9 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
|
|
|
185
212
|
this.dataLayeronGracePeriod();
|
|
186
213
|
}
|
|
187
214
|
render() {
|
|
215
|
+
const bgClass = !this.isBackgroundOnContentOnly ? 'bg-orange-100' : '';
|
|
188
216
|
return html `
|
|
189
|
-
<div class="sticky bottom-0 h-full w-full
|
|
217
|
+
<div class="sticky bottom-0 h-full w-full ${bgClass}">
|
|
190
218
|
${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}
|
|
191
219
|
</div>
|
|
192
220
|
`;
|
|
@@ -216,6 +244,12 @@ __decorate([
|
|
|
216
244
|
__decorate([
|
|
217
245
|
property({ type: Boolean })
|
|
218
246
|
], KompasGracePeriod.prototype, "isShowButton", void 0);
|
|
247
|
+
__decorate([
|
|
248
|
+
property({ type: Boolean })
|
|
249
|
+
], KompasGracePeriod.prototype, "isEpaper", void 0);
|
|
250
|
+
__decorate([
|
|
251
|
+
property({ type: Boolean })
|
|
252
|
+
], KompasGracePeriod.prototype, "isBackgroundOnContentOnly", void 0);
|
|
219
253
|
__decorate([
|
|
220
254
|
property({ type: String })
|
|
221
255
|
], KompasGracePeriod.prototype, "paywall_location", void 0);
|
|
@@ -261,6 +295,9 @@ __decorate([
|
|
|
261
295
|
__decorate([
|
|
262
296
|
property({ type: Number })
|
|
263
297
|
], KompasGracePeriod.prototype, "tracker_metered_wall_balance", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
property({ type: String })
|
|
300
|
+
], KompasGracePeriod.prototype, "tracker_epaper_edition", void 0);
|
|
264
301
|
__decorate([
|
|
265
302
|
state()
|
|
266
303
|
], KompasGracePeriod.prototype, "maxGracePeriod", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAiBL;;WAEG;QACH;;;;;;;;;;;;;;;;;;;WAmBG;QAEyB,qBAAgB,GAAG,CAAC,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,iBAAY,GAAG,KAAK,CAAA;QACrB,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC3B,+BAA0B,GAAG,CAAC,CAAA;QAC9B,qBAAgB,GAAG,CAAC,CAAA;QACpB,sBAAiB,GAAG,EAAE,CAAA;QACtB,uBAAkB,GAAG,EAAE,CAAA;QACvB,0BAAqB,GAAG,EAAE,CAAA;QAC1B,+BAA0B,GAAG,EAAE,CAAA;QAC/B,yBAAoB,GAAG,EAAE,CAAA;QACzB,sBAAiB,GAAG,EAAE,CAAA;QACtB,gCAA2B,GAAG,EAAE,CAAA;QAChC,wBAAmB,GAAG,EAAE,CAAA;QACxB,8BAAyB,GAAG,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B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAA4B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAA2B;AAC1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAiC;AAKnD;IAAR,KAAK,EAAE;yDAA2B;AAC1B;IAAR,KAAK,EAAE;2DAAgE;AAC/D;IAAR,KAAK,EAAE;uDAAsD;AAjEnD,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CA6N7B;SA7NY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property paywall_location = the location where user encounter the paywall\n * property paywall_subscription_package = the name of the subscription package viewed by user\n * property paywall_subscription_id = the ID of the subscription package viewed by user\n * property paywall_subscription_price = the price of the subscriprtion package viewed by user\n * property paywall_position = the position of the subscription package viewed by user\n * property tracker_page_type = type of the page\n * property tracker_content_id = ID of article (slug)\n * property tracker_content_type = whether it's free article or paid article\n * property tracker_content_title = the title of article\n * property tracker_content_categories = the category of the content\n * property tracker_user_type = type of user based on their subscription\n * property tracker_subscription_status = status of their subscription\n * property tracker_page_domain = page Domain\n * property tracker_metered_wall_type = the type of Metered Wall\n * property tracker_metered_wall_balance = the balance of their metered wall\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = false\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 = 0\n @property({ type: String }) tracker_page_type = ''\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 /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private subscriptionPage = 'https://www.kompas.id/berlangganan'\n @state() private checkoutPage = 'https://checkoutv2.kompas.id'\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n if (totalGracePeriod === 7) {\n return html`\n <p>\n Anda dalam <b class=\"text-orange-500\"> hari terakhir</b> masa tenggang\n langganan. Segera perbarui paket langganan untuk tetap mengakses\n konten premium tanpa batas.\n </p>\n `\n }\n return html`\n <p>\n Masa tenggang langganan Anda tersisa\n <b class=\"text-orange-500\"\n >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b\n >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n tanpa batas.\n </p>\n `\n }\n\n private redirectToBerlangganan(): void {\n this.dataLayeronPerbaruiLanggananButton()\n this.sendGtmEvent('subscribe_button_clicked')\n\n window.open(this.subscriptionPage)\n }\n\n private redirectToCheckout(): void {\n this.dataLayeronPerbaruiLanggananButton()\n const originHost: string = encodeURIComponent(window.location.href)\n\n this.sendGtmEvent('subscribe_button_clicked')\n\n window.open(\n `${this.checkoutPage}/kdp?productId=${this.paywall_subscription_id}&referrer=${originHost}&source=article`,\n )\n }\n\n private getGtmParams(): Record<string, any> {\n return {\n paywall_location: this.paywall_location,\n paywall_subscription_package: this.paywall_subscription_package,\n paywall_subscription_id: this.paywall_subscription_id,\n paywall_subscription_price: this.paywall_subscription_price,\n paywall_position: this.paywall_position,\n page_type: this.tracker_page_type,\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 user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n metered_wall_type: this.tracker_metered_wall_type || 'GP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n }\n\n private sendGtmEvent(event: string) {\n let gtmParams: Record<string, any> = { event }\n\n if (event === 'paywall_viewed') {\n gtmParams.impressions = [\n {\n ...this.getGtmParams(),\n },\n ]\n } else {\n gtmParams = { ...gtmParams, ...this.getGtmParams() }\n }\n\n window.dataLayer.push(gtmParams)\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n return html`\n <div\n class=\"${this.isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8'} bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end px-4 py-4 md:space-x-4\"\n >\n <div class=\"self-center text-left text-sm text-grey-600 md:text-base\">\n ${this.getCountdownGracePeriod()}\n </div>\n ${!this.isShowButton\n ? html`\n <div\n class=\"flex w-full flex-col justify-end gap-4 self-center pt-4 md:w-1/2 md:flex-row md:pt-0\"\n >\n <button\n @click=${this.redirectToCheckout}\n class=\"w-full rounded-md bg-green-500 p-2 px-5 text-sm font-bold text-grey-100 md:w-auto md:text-base\"\n >\n Perbarui Langganan\n </button>\n <div class=\"md:block hidden\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-green-500 p-2 px-5 text-sm font-bold text-green-500 md:w-auto md:text-base\"\n >\n Paket Lainnya\n </button>\n </div>\n <div class=\"md:hidden block\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-green-500 p-2 px-5 text-sm font-bold text-green-500 md:w-auto md:text-base\"\n >\n Lihat Paket Lainnya\n </button>\n </div>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n\n this.sendGtmEvent('paywall_viewed')\n\n this.dataLayeronGracePeriod()\n }\n\n render() {\n return html`\n <div class=\"sticky bottom-0 h-full w-full bg-orange-100\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAiBL;;WAEG;QACH;;;;;;;;;;;;;;;;;;;;;WAqBG;QAEyB,qBAAgB,GAAG,CAAC,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,iBAAY,GAAG,KAAK,CAAA;QACpB,aAAQ,GAAG,KAAK,CAAA;QAChB,8BAAyB,GAAG,KAAK,CAAA;QAClC,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC3B,+BAA0B,GAAG,CAAC,CAAA;QAC9B,qBAAgB,GAAG,CAAC,CAAA;QACpB,sBAAiB,GAAG,EAAE,CAAA;QACtB,uBAAkB,GAAG,EAAE,CAAA;QACvB,0BAAqB,GAAG,EAAE,CAAA;QAC1B,+BAA0B,GAAG,EAAE,CAAA;QAC/B,yBAAoB,GAAG,EAAE,CAAA;QACzB,sBAAiB,GAAG,EAAE,CAAA;QACtB,gCAA2B,GAAG,EAAE,CAAA;QAChC,wBAAmB,GAAG,EAAE,CAAA;QACxB,8BAAyB,GAAG,EAAE,CAAA;QAC9B,iCAA4B,GAAG,CAAC,CAAA;QAChC,2BAAsB,GAAG,EAAE,CAAA;QAEvD;;WAEG;QACc,mBAAc,GAAG,C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othing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property isEpaper = is paywall opened in epaper page\n * property paywall_location = the location where user encounter the paywall\n * property paywall_subscription_package = the name of the subscription package viewed by user\n * property paywall_subscription_id = the ID of the subscription package viewed by user\n * property paywall_subscription_price = the price of the subscriprtion package viewed by user\n * property paywall_position = the position of the subscription package viewed by user\n * property tracker_page_type = type of the page\n * property tracker_content_id = ID of article (slug)\n * property tracker_content_type = whether it's free article or paid article\n * property tracker_content_title = the title of article\n * property tracker_content_categories = the category of the content\n * property tracker_user_type = type of user based on their subscription\n * property tracker_subscription_status = status of their subscription\n * property tracker_page_domain = page Domain\n * property tracker_metered_wall_type = the type of Metered Wall\n * property tracker_metered_wall_balance = the balance of their metered wall\n * property tracker_epaper_edition = the edition of epaper viewed by user\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = false\n @property({ type: Boolean }) isEpaper = false\n @property({ type: Boolean }) isBackgroundOnContentOnly = false\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 = 0\n @property({ type: String }) tracker_page_type = ''\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 @property({ type: String }) tracker_epaper_edition = ''\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private subscriptionPage = 'https://www.kompas.id/berlangganan'\n @state() private checkoutPage = 'https://checkoutv2.kompas.id'\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n if (totalGracePeriod === 7) {\n return html`\n <p>\n Anda dalam <b class=\"text-orange-500\"> hari terakhir</b> masa tenggang\n langganan. Segera perbarui paket langganan untuk tetap mengakses\n konten premium tanpa batas.\n </p>\n `\n }\n return html`\n <p>\n Masa tenggang langganan Anda tersisa\n <b class=\"text-orange-500\"\n >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b\n >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n tanpa batas.\n </p>\n `\n }\n\n private redirectToBerlangganan(): void {\n this.dataLayeronPerbaruiLanggananButton()\n this.sendGtmEvent('subscribe_button_clicked', true)\n\n window.open(this.subscriptionPage)\n }\n\n private redirectToCheckout(): void {\n this.dataLayeronPerbaruiLanggananButton()\n const originHost: string = encodeURIComponent(window.location.href)\n\n this.sendGtmEvent('subscribe_button_clicked')\n\n window.open(\n `${this.checkoutPage}/kdp?productId=${this.paywall_subscription_id}&referrer=${originHost}&source=article`,\n )\n }\n\n private getGtmParams(\n excludeSubscriptionParams: boolean = false,\n ): Record<string, any> {\n const gtmParams: Record<string, any> = {}\n\n if (!this.isEpaper) {\n gtmParams.content_title = this.tracker_content_title\n gtmParams.content_id = this.tracker_content_id\n gtmParams.content_categories = this.tracker_content_categories\n gtmParams.content_type = this.tracker_content_type\n gtmParams.page_type = this.tracker_page_type\n } else {\n gtmParams.epaper_edition = this.tracker_epaper_edition\n }\n\n if (!excludeSubscriptionParams) {\n gtmParams.paywall_subscription_package = this.paywall_subscription_package\n gtmParams.paywall_subscription_id = this.paywall_subscription_id\n gtmParams.paywall_subscription_price = this.paywall_subscription_price\n }\n\n gtmParams.paywall_location = this.paywall_location\n gtmParams.paywall_position = this.paywall_position\n gtmParams.user_type = this.tracker_user_type\n gtmParams.subscription_status = this.tracker_subscription_status\n gtmParams.page_domain = this.tracker_page_domain || 'Kompas.id'\n gtmParams.metered_wall_type = this.tracker_metered_wall_type || 'GP'\n gtmParams.metered_wall_balance = this.tracker_metered_wall_balance\n\n return gtmParams\n }\n\n private sendGtmEvent(\n event: string,\n excludeSubscriptionParams: boolean = false,\n ) {\n let gtmParams: Record<string, any> = { event }\n\n if (event === 'paywall_viewed') {\n gtmParams.impressions = [\n {\n ...this.getGtmParams(excludeSubscriptionParams),\n },\n ]\n } else {\n gtmParams = {\n ...gtmParams,\n ...this.getGtmParams(excludeSubscriptionParams),\n }\n }\n\n window.dataLayer.push(gtmParams)\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n const { isColumn, isBackgroundOnContentOnly } = this\n\n const wrapperColumnClass = isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8 md:space-x-4 px-4 py-4'\n const buttonColumnClass = isColumn\n ? ''\n : 'md:w-1/2 justify-end md:flex-row pt-4 md:pt-0'\n const otherBtnColumnClass = isColumn ? '' : 'md:w-auto'\n const wrapperBgClass = !isBackgroundOnContentOnly ? 'p-4' : ''\n const contentBgClass = isBackgroundOnContentOnly\n ? 'bg-orange-100 p-4 rounded-lg mb-4'\n : ''\n\n return html`\n <div\n class=\"bottom-0 mx-auto flex w-full max-w-7xl flex-col justify-end ${wrapperColumnClass} ${wrapperBgClass}\"\n >\n <div\n class=\"self-center text-left text-sm text-grey-600 md:text-base ${contentBgClass}\"\n >\n ${this.getCountdownGracePeriod()}\n </div>\n ${this.isShowButton\n ? html`\n <div\n class=\"flex w-full flex-col gap-4 self-center ${buttonColumnClass}\"\n >\n <button\n @click=${this.redirectToCheckout}\n class=\"w-full rounded-md bg-green-500 p-2 px-5 text-sm font-bold text-grey-100 md:w-auto md:text-base\"\n >\n Perbarui Langganan\n </button>\n <div class=\"md:block hidden\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-green-500 p-1.5 px-5 text-sm font-bold text-green-500 md:text-base ${otherBtnColumnClass}\"\n >\n Paket Lainnya\n </button>\n </div>\n <div class=\"md:hidden block\">\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-transparent w-full rounded-md border border-green-500 p-1.5 px-5 text-sm font-bold text-green-500 md:text-base ${otherBtnColumnClass}\"\n >\n Lihat Paket Lainnya\n </button>\n </div>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n\n this.sendGtmEvent('paywall_viewed')\n\n this.dataLayeronGracePeriod()\n }\n\n render() {\n const bgClass = !this.isBackgroundOnContentOnly ? 'bg-orange-100' : ''\n return html`\n <div class=\"sticky bottom-0 h-full w-full ${bgClass}\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
|
|
@@ -18,6 +18,24 @@ export declare class KompasHeaderAccount extends LitElement {
|
|
|
18
18
|
sidebarTopSpacing: number;
|
|
19
19
|
subscriptionUrl: string;
|
|
20
20
|
totalGracePeriod: number;
|
|
21
|
+
/**
|
|
22
|
+
* Props For Grace Period Tracker
|
|
23
|
+
*/
|
|
24
|
+
paywall_location: string;
|
|
25
|
+
paywall_subscription_package: string;
|
|
26
|
+
paywall_subscription_id: number;
|
|
27
|
+
paywall_subscription_price: number;
|
|
28
|
+
paywall_position: number;
|
|
29
|
+
tracker_page_type: string;
|
|
30
|
+
tracker_content_id: string;
|
|
31
|
+
tracker_content_title: string;
|
|
32
|
+
tracker_content_categories: string;
|
|
33
|
+
tracker_content_type: string;
|
|
34
|
+
tracker_user_type: string;
|
|
35
|
+
tracker_subscription_status: string;
|
|
36
|
+
tracker_page_domain: string;
|
|
37
|
+
tracker_metered_wall_type: string;
|
|
38
|
+
tracker_metered_wall_balance: number;
|
|
21
39
|
private toggleSidebar;
|
|
22
40
|
private getInitialUserName;
|
|
23
41
|
private account;
|
|
@@ -23,6 +23,24 @@ let KompasHeaderAccount = class KompasHeaderAccount extends LitElement {
|
|
|
23
23
|
this.sidebarTopSpacing = 0;
|
|
24
24
|
this.subscriptionUrl = '';
|
|
25
25
|
this.totalGracePeriod = 0;
|
|
26
|
+
/**
|
|
27
|
+
* Props For Grace Period Tracker
|
|
28
|
+
*/
|
|
29
|
+
this.paywall_location = '';
|
|
30
|
+
this.paywall_subscription_package = '';
|
|
31
|
+
this.paywall_subscription_id = 0;
|
|
32
|
+
this.paywall_subscription_price = 0;
|
|
33
|
+
this.paywall_position = 0;
|
|
34
|
+
this.tracker_page_type = '';
|
|
35
|
+
this.tracker_content_id = '';
|
|
36
|
+
this.tracker_content_title = '';
|
|
37
|
+
this.tracker_content_categories = '';
|
|
38
|
+
this.tracker_content_type = '';
|
|
39
|
+
this.tracker_user_type = '';
|
|
40
|
+
this.tracker_subscription_status = '';
|
|
41
|
+
this.tracker_page_domain = '';
|
|
42
|
+
this.tracker_metered_wall_type = '';
|
|
43
|
+
this.tracker_metered_wall_balance = 0;
|
|
26
44
|
}
|
|
27
45
|
toggleSidebar() {
|
|
28
46
|
this.isShowSidebar = !this.isShowSidebar;
|
|
@@ -99,6 +117,21 @@ let KompasHeaderAccount = class KompasHeaderAccount extends LitElement {
|
|
|
99
117
|
.userData=${this.formattedUserData}
|
|
100
118
|
.subscriptionUrl=${this.subscriptionUrl}
|
|
101
119
|
.totalGracePeriod=${this.totalGracePeriod}
|
|
120
|
+
paywall_location=${this.paywall_location}
|
|
121
|
+
paywall_subscription_package=${this.paywall_subscription_package}
|
|
122
|
+
paywall_subscription_id=${this.paywall_subscription_id}
|
|
123
|
+
paywall_subscription_price=${this.paywall_subscription_price}
|
|
124
|
+
paywall_position=${this.paywall_position}
|
|
125
|
+
tracker_page_type=${this.tracker_page_type}
|
|
126
|
+
tracker_content_id=${this.tracker_content_id}
|
|
127
|
+
tracker_content_title=${this.tracker_content_title}
|
|
128
|
+
tracker_content_categories=${this.tracker_content_categories}
|
|
129
|
+
tracker_content_type=${this.tracker_content_type}
|
|
130
|
+
tracker_user_type=${this.tracker_user_type}
|
|
131
|
+
tracker_subscription_status=${this.tracker_subscription_status}
|
|
132
|
+
tracker_page_domain=${this.tracker_page_domain}
|
|
133
|
+
tracker_metered_wall_type=${this.tracker_metered_wall_type}
|
|
134
|
+
tracker_metered_wall_balance=${this.tracker_metered_wall_balance}
|
|
102
135
|
></kompasid-header-account-profile>
|
|
103
136
|
<div class="pl-4 pr-3 py-4 text-left">
|
|
104
137
|
<kompasid-header-account-menu
|
|
@@ -251,6 +284,51 @@ __decorate([
|
|
|
251
284
|
__decorate([
|
|
252
285
|
property({ type: Number })
|
|
253
286
|
], KompasHeaderAccount.prototype, "totalGracePeriod", void 0);
|
|
287
|
+
__decorate([
|
|
288
|
+
property({ type: String })
|
|
289
|
+
], KompasHeaderAccount.prototype, "paywall_location", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
property({ type: String })
|
|
292
|
+
], KompasHeaderAccount.prototype, "paywall_subscription_package", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
property({ type: Number })
|
|
295
|
+
], KompasHeaderAccount.prototype, "paywall_subscription_id", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
property({ type: Number })
|
|
298
|
+
], KompasHeaderAccount.prototype, "paywall_subscription_price", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
property({ type: Number })
|
|
301
|
+
], KompasHeaderAccount.prototype, "paywall_position", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
property({ type: String })
|
|
304
|
+
], KompasHeaderAccount.prototype, "tracker_page_type", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
property({ type: String })
|
|
307
|
+
], KompasHeaderAccount.prototype, "tracker_content_id", void 0);
|
|
308
|
+
__decorate([
|
|
309
|
+
property({ type: String })
|
|
310
|
+
], KompasHeaderAccount.prototype, "tracker_content_title", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
property({ type: String })
|
|
313
|
+
], KompasHeaderAccount.prototype, "tracker_content_categories", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
property({ type: String })
|
|
316
|
+
], KompasHeaderAccount.prototype, "tracker_content_type", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
property({ type: String })
|
|
319
|
+
], KompasHeaderAccount.prototype, "tracker_user_type", void 0);
|
|
320
|
+
__decorate([
|
|
321
|
+
property({ type: String })
|
|
322
|
+
], KompasHeaderAccount.prototype, "tracker_subscription_status", void 0);
|
|
323
|
+
__decorate([
|
|
324
|
+
property({ type: String })
|
|
325
|
+
], KompasHeaderAccount.prototype, "tracker_page_domain", void 0);
|
|
326
|
+
__decorate([
|
|
327
|
+
property({ type: String })
|
|
328
|
+
], KompasHeaderAccount.prototype, "tracker_metered_wall_type", void 0);
|
|
329
|
+
__decorate([
|
|
330
|
+
property({ type: Number })
|
|
331
|
+
], KompasHeaderAccount.prototype, "tracker_metered_wall_balance", void 0);
|
|
254
332
|
KompasHeaderAccount = __decorate([
|
|
255
333
|
customElement('kompasid-header-account')
|
|
256
334
|
], KompasHeaderAccount);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KompasHeaderAccount.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/KompasHeaderAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,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AAC;sDAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAAqB;AAjGrC,mBAAmB;IAD/B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,mBAAmB,CAkN/B;SAlNY,mBAAmB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js'\nimport { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'\nimport { User } from './types.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport '../kompasid-header-account-profile/KompasHeaderAccountProfile.js'\nimport '../kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js'\nimport '../kompasid-header-account-menu/KompasHeaderAccountMenu.js'\n\n@customElement('kompasid-header-account')\nexport class KompasHeaderAccount extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .header {\n background-color: #0356a8;\n }\n .account-profile {\n overflow-y: auto;\n }\n\n .header-account-help-center--item {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0.75rem;\n }\n\n .header-account-help-center--content {\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n margin-left: 1rem;\n line-height: 1.5rem;\n }\n\n .header-account--membership-icon {\n position: absolute;\n bottom: -2px;\n right: -2px;\n }\n\n .header-account--notification-indicator {\n position: absolute;\n top: 0;\n height: 0.5rem;\n width: 0.5rem;\n background-color: #f6ad55;\n border-radius: 50%;\n right: -0.563rem;\n top: -0.281rem;\n }\n\n .header-account-sidebar {\n width: 19rem;\n background-color: #edf2f7;\n box-shadow: 0px 0.125rem 0.25rem rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.875rem;\n }\n .z-index-max {\n z-index: 99999;\n }\n\n /* Custom Scrollbar for header */\n /* width */\n ::-webkit-scrollbar {\n width: 4px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background: #0356a8;\n border-radius: 100px;\n }\n\n /* Handle on hover */\n ::-webkit-scrollbar-thumb:hover {\n background: #0356a8;\n }\n `,\n TWStyles,\n ]\n\n @state() isShowSidebar: boolean = false\n\n formattedUserData: User = {} as User\n\n @property({ type: String }) cartUrl = ''\n @property({ type: String }) logoutUrl = ''\n @property({ type: String }) manageAccountUrl = ''\n @property({ type: Number }) notificationTotal = 0\n @property({ type: String }) notificationUrl = ''\n @property({ type: String }) ordersUrl = ''\n @property({ type: String }) readLaterUrl = ''\n @property({ type: Object }) userData = {}\n @property({ type: Number }) sidebarTopSpacing = 0\n @property({ type: String }) subscriptionUrl = ''\n @property({ type: Number }) totalGracePeriod = 0\n\n private toggleSidebar() {\n this.isShowSidebar = !this.isShowSidebar\n }\n\n private getInitialUserName() {\n return this.formattedUserData?.userName\n ? this.formattedUserData.userName.charAt(0)\n : ''\n }\n\n private account() {\n const notificationIndicator = () => {\n if (!this.notificationTotal) return html``\n return html`<div class=\"header-account--notification-indicator\"></div>`\n }\n\n const membershipIcon = () => {\n if (!this.formattedUserData?.isMembership) return html``\n return html`\n <div>\n <img\n class=\"header-account--membership-icon h-2.5 w-2.5\"\n src=\"https://cdn-www.kompas.id/global-header/crown-royal-blue-60.svg\"\n alt=\"membership-crown-icon\"\n />\n </div>\n `\n }\n\n return html`\n <button @click=${this.toggleSidebar} class=\"cursor-pointer \">\n <div class=\"flex flex-row items-center self-center\">\n ${!this.getInitialUserName()\n ? html`<div\n class=\"bg-grey-300 rounded-full h-6 w-6 animate-pulse\"\n ></div>`\n : html`\n <div\n class=\"flex bg-grey-100 rounded-full h-6 w-6 items-center justify-center relative\"\n >\n <span class=\"capitalize text-xxs text-blue-600 font-bold\"\n >${this.getInitialUserName()}</span\n >\n ${notificationIndicator()} ${membershipIcon()}\n </div>\n `}\n <div\n class=\"ml-3 icon-xs text-white chevron-icon ${this.isShowSidebar\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-up'))}\n </div>\n </div>\n </button>\n `\n }\n\n private accountSidebar() {\n return html`\n <nav\n class=\"w-screen fixed right-0 top-0 bottom-0\"\n @keyup=\"${this.onkeyup}\"\n @click=${this.toggleSidebar}\n >\n <div\n class=\"bg-grey-100 pb-20 pt-0 shadow-lg w-76 z-index-max ml-auto\"\n style=${`margin-top: ${this.sidebarTopSpacing}px;height:100vh;overflow-y:auto`}\n @keyup=\"${this.onkeyup}\"\n @click=${(ev: any) => ev.stopPropagation()}\n >\n <kompasid-header-account-profile\n .userInitialName=${this.getInitialUserName()}\n .userData=${this.formattedUserData}\n .subscriptionUrl=${this.subscriptionUrl}\n .totalGracePeriod=${this.totalGracePeriod}\n ></kompasid-header-account-profile>\n <div class=\"pl-4 pr-3 py-4 text-left\">\n <kompasid-header-account-menu\n .cart-url=${this.cartUrl}\n .manage-account-url=${this.manageAccountUrl}\n .logout-url=${this.logoutUrl}\n .notification-url=${this.notificationUrl}\n .notification-total=${this.notificationTotal}\n .orders-url=${this.ordersUrl}\n .read-later-url=${this.readLaterUrl}\n ></kompasid-header-account-menu>\n <kompasid-header-account-help-center></kompasid-header-account-help-center>\n </div>\n </div>\n </nav>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.isShowSidebar = false\n if (typeof this.userData === 'string') {\n this.formattedUserData = JSON.parse(this.userData)\n } else if (typeof this.userData === 'object' && this.userData !== null) {\n // If userData is already an object, you might not need to parse it.\n // You can assign it directly to formattedUserData:\n this.formattedUserData = this.userData as User\n }\n }\n\n render() {\n return html`\n ${this.account()} ${this.isShowSidebar ? this.accountSidebar() : ''}\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KompasHeaderAccount.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/KompasHeaderAccount.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,kEAAkE,CAAA;AACzE,OAAO,yEAAyE,CAAA;AAChF,OAAO,4DAA4D,CAAA;AAG5D,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,UAAU;IAA5C;;QAmFI,kBAAa,GAAY,KAAK,CAAA;QAEvC,sBAAiB,GAAS,EAAU,CAAA;QAER,YAAO,GAAG,EAAE,CAAA;QACZ,cAAS,GAAG,EAAE,CAAA;QACd,qBAAgB,GAAG,EAAE,CAAA;QACrB,sBAAiB,GAAG,CAAC,CAAA;QACrB,oBAAe,GAAG,EAAE,CAAA;QACpB,cAAS,GAAG,EAAE,CAAA;QACd,iBAAY,GAAG,EAAE,CAAA;QACjB,aAAQ,GAAG,EAAE,CAAA;QACb,sBAAiB,GAAG,CAAC,CAAA;QACrB,oBAAe,GAAG,EAAE,CAAA;QACpB,qBAAgB,GAAG,CAAC,CAAA;QAEhD;;WAEG;QACyB,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC3B,+BAA0B,GAAG,CAAC,CAAA;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AAI,EAAE,MAAM,EAAE,CAAC;gEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yEAAiC;AApHjD,mBAAmB;IAD/B,aAAa,CAAC,yBAAyB,CAAC;GAC5B,mBAAmB,CAoP/B;SApPY,mBAAmB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js'\nimport { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'\nimport { User } from './types.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport '../kompasid-header-account-profile/KompasHeaderAccountProfile.js'\nimport '../kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js'\nimport '../kompasid-header-account-menu/KompasHeaderAccountMenu.js'\n\n@customElement('kompasid-header-account')\nexport class KompasHeaderAccount extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .header {\n background-color: #0356a8;\n }\n .account-profile {\n overflow-y: auto;\n }\n\n .header-account-help-center--item {\n display: flex;\n flex-direction: row;\n align-items: center;\n padding: 0.75rem;\n }\n\n .header-account-help-center--content {\n display: flex;\n flex-direction: column;\n flex-grow: 1;\n margin-left: 1rem;\n line-height: 1.5rem;\n }\n\n .header-account--membership-icon {\n position: absolute;\n bottom: -2px;\n right: -2px;\n }\n\n .header-account--notification-indicator {\n position: absolute;\n top: 0;\n height: 0.5rem;\n width: 0.5rem;\n background-color: #f6ad55;\n border-radius: 50%;\n right: -0.563rem;\n top: -0.281rem;\n }\n\n .header-account-sidebar {\n width: 19rem;\n background-color: #edf2f7;\n box-shadow: 0px 0.125rem 0.25rem rgba(0, 0, 0, 0.1);\n display: flex;\n flex-direction: column;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.875rem;\n }\n .z-index-max {\n z-index: 99999;\n }\n\n /* Custom Scrollbar for header */\n /* width */\n ::-webkit-scrollbar {\n width: 4px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background: #0356a8;\n border-radius: 100px;\n }\n\n /* Handle on hover */\n ::-webkit-scrollbar-thumb:hover {\n background: #0356a8;\n }\n `,\n TWStyles,\n ]\n\n @state() isShowSidebar: boolean = false\n\n formattedUserData: User = {} as User\n\n @property({ type: String }) cartUrl = ''\n @property({ type: String }) logoutUrl = ''\n @property({ type: String }) manageAccountUrl = ''\n @property({ type: Number }) notificationTotal = 0\n @property({ type: String }) notificationUrl = ''\n @property({ type: String }) ordersUrl = ''\n @property({ type: String }) readLaterUrl = ''\n @property({ type: Object }) userData = {}\n @property({ type: Number }) sidebarTopSpacing = 0\n @property({ type: String }) subscriptionUrl = ''\n @property({ type: Number }) totalGracePeriod = 0\n\n /**\n * Props For Grace Period Tracker\n */\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 = 0\n @property({ type: String }) tracker_page_type = ''\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 private toggleSidebar() {\n this.isShowSidebar = !this.isShowSidebar\n }\n\n private getInitialUserName() {\n return this.formattedUserData?.userName\n ? this.formattedUserData.userName.charAt(0)\n : ''\n }\n\n private account() {\n const notificationIndicator = () => {\n if (!this.notificationTotal) return html``\n return html`<div class=\"header-account--notification-indicator\"></div>`\n }\n\n const membershipIcon = () => {\n if (!this.formattedUserData?.isMembership) return html``\n return html`\n <div>\n <img\n class=\"header-account--membership-icon h-2.5 w-2.5\"\n src=\"https://cdn-www.kompas.id/global-header/crown-royal-blue-60.svg\"\n alt=\"membership-crown-icon\"\n />\n </div>\n `\n }\n\n return html`\n <button @click=${this.toggleSidebar} class=\"cursor-pointer \">\n <div class=\"flex flex-row items-center self-center\">\n ${!this.getInitialUserName()\n ? html`<div\n class=\"bg-grey-300 rounded-full h-6 w-6 animate-pulse\"\n ></div>`\n : html`\n <div\n class=\"flex bg-grey-100 rounded-full h-6 w-6 items-center justify-center relative\"\n >\n <span class=\"capitalize text-xxs text-blue-600 font-bold\"\n >${this.getInitialUserName()}</span\n >\n ${notificationIndicator()} ${membershipIcon()}\n </div>\n `}\n <div\n class=\"ml-3 icon-xs text-white chevron-icon ${this.isShowSidebar\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-up'))}\n </div>\n </div>\n </button>\n `\n }\n\n private accountSidebar() {\n return html`\n <nav\n class=\"w-screen fixed right-0 top-0 bottom-0\"\n @keyup=\"${this.onkeyup}\"\n @click=${this.toggleSidebar}\n >\n <div\n class=\"bg-grey-100 pb-20 pt-0 shadow-lg w-76 z-index-max ml-auto\"\n style=${`margin-top: ${this.sidebarTopSpacing}px;height:100vh;overflow-y:auto`}\n @keyup=\"${this.onkeyup}\"\n @click=${(ev: any) => ev.stopPropagation()}\n >\n <kompasid-header-account-profile\n .userInitialName=${this.getInitialUserName()}\n .userData=${this.formattedUserData}\n .subscriptionUrl=${this.subscriptionUrl}\n .totalGracePeriod=${this.totalGracePeriod}\n paywall_location=${this.paywall_location}\n paywall_subscription_package=${this.paywall_subscription_package}\n paywall_subscription_id=${this.paywall_subscription_id}\n paywall_subscription_price=${this.paywall_subscription_price}\n paywall_position=${this.paywall_position}\n tracker_page_type=${this.tracker_page_type}\n tracker_content_id=${this.tracker_content_id}\n tracker_content_title=${this.tracker_content_title}\n tracker_content_categories=${this.tracker_content_categories}\n tracker_content_type=${this.tracker_content_type}\n tracker_user_type=${this.tracker_user_type}\n tracker_subscription_status=${this.tracker_subscription_status}\n tracker_page_domain=${this.tracker_page_domain}\n tracker_metered_wall_type=${this.tracker_metered_wall_type}\n tracker_metered_wall_balance=${this.tracker_metered_wall_balance}\n ></kompasid-header-account-profile>\n <div class=\"pl-4 pr-3 py-4 text-left\">\n <kompasid-header-account-menu\n .cart-url=${this.cartUrl}\n .manage-account-url=${this.manageAccountUrl}\n .logout-url=${this.logoutUrl}\n .notification-url=${this.notificationUrl}\n .notification-total=${this.notificationTotal}\n .orders-url=${this.ordersUrl}\n .read-later-url=${this.readLaterUrl}\n ></kompasid-header-account-menu>\n <kompasid-header-account-help-center></kompasid-header-account-help-center>\n </div>\n </div>\n </nav>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.isShowSidebar = false\n if (typeof this.userData === 'string') {\n this.formattedUserData = JSON.parse(this.userData)\n } else if (typeof this.userData === 'object' && this.userData !== null) {\n // If userData is already an object, you might not need to parse it.\n // You can assign it directly to formattedUserData:\n this.formattedUserData = this.userData as User\n }\n }\n\n render() {\n return html`\n ${this.account()} ${this.isShowSidebar ? this.accountSidebar() : ''}\n `\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface User {\n userName: string\n expired: string\n isNearExpired: boolean\n activeInfo: string\n isMembership: boolean\n updateMembership: string\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface User {\n userName: string\n expired: string\n isNearExpired: boolean\n totalGracePeriod: number\n isGracePeriod: boolean\n activeInfo: string\n isMembership: boolean\n updateMembership: string\n}\n"]}
|
|
@@ -1,10 +1,37 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
+
import { User } from '../kompasid-header-account/types.js';
|
|
3
|
+
import '../kompasid-grace-period/KompasGracePeriod.js';
|
|
2
4
|
export declare class KompasHeaderAccountProfile extends LitElement {
|
|
3
5
|
static styles: import("lit").CSSResult[];
|
|
6
|
+
/**
|
|
7
|
+
* Props
|
|
8
|
+
*/
|
|
4
9
|
userInitialName: string;
|
|
5
|
-
userData:
|
|
6
|
-
subscriptionUrl: string;
|
|
10
|
+
userData: User;
|
|
7
11
|
totalGracePeriod: number;
|
|
12
|
+
/**
|
|
13
|
+
* Props For Grace Period Tracker
|
|
14
|
+
*/
|
|
15
|
+
paywall_location: string;
|
|
16
|
+
paywall_subscription_package: string;
|
|
17
|
+
paywall_subscription_id: number;
|
|
18
|
+
paywall_subscription_price: number;
|
|
19
|
+
paywall_position: number;
|
|
20
|
+
tracker_page_type: string;
|
|
21
|
+
tracker_content_id: string;
|
|
22
|
+
tracker_content_title: string;
|
|
23
|
+
tracker_content_categories: string;
|
|
24
|
+
tracker_content_type: string;
|
|
25
|
+
tracker_user_type: string;
|
|
26
|
+
tracker_subscription_status: string;
|
|
27
|
+
tracker_page_domain: string;
|
|
28
|
+
tracker_metered_wall_type: string;
|
|
29
|
+
tracker_metered_wall_balance: number;
|
|
30
|
+
/**
|
|
31
|
+
* State
|
|
32
|
+
*/
|
|
33
|
+
private maxGracePeriod;
|
|
34
|
+
formatDate(date: Date | string): string;
|
|
8
35
|
private renderSkeletonLoading;
|
|
9
36
|
private renderProfileContent;
|
|
10
37
|
connectedCallback(): Promise<void>;
|