@kompasid/lit-web-components 0.8.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/index.html +38 -3
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.d.ts +5 -0
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +69 -32
- 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 -1
- package/dist/src/components/kompasid-header-account/types.js.map +1 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.d.ts +29 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +121 -34
- 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 +70 -32
- 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 -1
- package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +89 -36
|
@@ -1,15 +1,46 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html, css } from 'lit';
|
|
3
|
-
import {
|
|
3
|
+
import { format, subDays, addDays } from 'date-fns';
|
|
4
|
+
import { id } from 'date-fns/locale/id';
|
|
5
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
6
|
import { TWStyles } from '../../../tailwind/tailwind.js';
|
|
5
7
|
import { truncate } from '../../utils/text.js';
|
|
8
|
+
import '../kompasid-grace-period/KompasGracePeriod.js';
|
|
6
9
|
let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitElement {
|
|
7
10
|
constructor() {
|
|
8
11
|
super(...arguments);
|
|
12
|
+
/**
|
|
13
|
+
* Props
|
|
14
|
+
*/
|
|
9
15
|
this.userInitialName = '';
|
|
10
16
|
this.userData = {};
|
|
11
17
|
this.subscriptionUrl = '';
|
|
12
18
|
this.totalGracePeriod = 0;
|
|
19
|
+
/**
|
|
20
|
+
* Props For Grace Period Tracker
|
|
21
|
+
*/
|
|
22
|
+
this.paywall_location = '';
|
|
23
|
+
this.paywall_subscription_package = '';
|
|
24
|
+
this.paywall_subscription_id = 0;
|
|
25
|
+
this.paywall_subscription_price = 0;
|
|
26
|
+
this.paywall_position = 0;
|
|
27
|
+
this.tracker_page_type = '';
|
|
28
|
+
this.tracker_content_id = '';
|
|
29
|
+
this.tracker_content_title = '';
|
|
30
|
+
this.tracker_content_categories = '';
|
|
31
|
+
this.tracker_content_type = '';
|
|
32
|
+
this.tracker_user_type = '';
|
|
33
|
+
this.tracker_subscription_status = '';
|
|
34
|
+
this.tracker_page_domain = '';
|
|
35
|
+
this.tracker_metered_wall_type = '';
|
|
36
|
+
this.tracker_metered_wall_balance = 0;
|
|
37
|
+
/**
|
|
38
|
+
* State
|
|
39
|
+
*/
|
|
40
|
+
this.maxGracePeriod = 7;
|
|
41
|
+
}
|
|
42
|
+
formatDate(date) {
|
|
43
|
+
return format(new Date(date), 'dd MMM yyyy', { locale: id });
|
|
13
44
|
}
|
|
14
45
|
renderSkeletonLoading() {
|
|
15
46
|
return html `
|
|
@@ -33,7 +64,7 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
|
|
|
33
64
|
renderProfileContent() {
|
|
34
65
|
var _a;
|
|
35
66
|
/**
|
|
36
|
-
*
|
|
67
|
+
* Subs Button Element
|
|
37
68
|
*/
|
|
38
69
|
const subscribeButton = () => {
|
|
39
70
|
var _a, _b;
|
|
@@ -53,19 +84,6 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
|
|
|
53
84
|
</button>
|
|
54
85
|
</div>
|
|
55
86
|
`;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* expired Info Element
|
|
59
|
-
*/
|
|
60
|
-
const expiredInfo = () => {
|
|
61
|
-
var _a, _b;
|
|
62
|
-
const isNearExpired = (_a = this.userData) === null || _a === void 0 ? void 0 : _a.isNearExpired;
|
|
63
|
-
const expiredTextColor = isNearExpired
|
|
64
|
-
? `text-orange-400`
|
|
65
|
-
: `text-grey-600`;
|
|
66
|
-
return html `<p class="${expiredTextColor} font-bold">
|
|
67
|
-
${(_b = this.userData) === null || _b === void 0 ? void 0 : _b.expired}
|
|
68
|
-
</p>`;
|
|
69
87
|
};
|
|
70
88
|
/**
|
|
71
89
|
* membership icon element, show if isMebership has truthy value
|
|
@@ -88,15 +106,20 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
|
|
|
88
106
|
/**
|
|
89
107
|
* Active Info Element
|
|
90
108
|
*/
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
? `text-orange-400`
|
|
109
|
+
const activeInfoTemplate = () => {
|
|
110
|
+
const { isGracePeriod, totalGracePeriod, activeInfo } = this.userData;
|
|
111
|
+
const expiredTextColor = isGracePeriod
|
|
112
|
+
? `text-orange-500`
|
|
96
113
|
: `text-grey-600`;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
const startGracePeriodDate = this.formatDate(subDays(new Date().toLocaleDateString(), totalGracePeriod - 1));
|
|
115
|
+
const endGracePeriodDate = this.formatDate(addDays(new Date().toLocaleDateString(), this.maxGracePeriod - totalGracePeriod));
|
|
116
|
+
const text = isGracePeriod
|
|
117
|
+
? html `<span> Periode Masa Tenggang </span>
|
|
118
|
+
<p class="font-bold">
|
|
119
|
+
${startGracePeriodDate} - ${endGracePeriodDate}
|
|
120
|
+
</p> `
|
|
121
|
+
: activeInfo || '';
|
|
122
|
+
return html `<p class="capitalize text-sm ${expiredTextColor}">${text}</p>`;
|
|
100
123
|
};
|
|
101
124
|
return html `<div
|
|
102
125
|
class="active-info flex flex-col items-start leading-none text-left"
|
|
@@ -113,21 +136,37 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
|
|
|
113
136
|
|
|
114
137
|
<div class="flex flex-col text-left">
|
|
115
138
|
<p class="capitalize font-bold text-base text-blue-600">
|
|
116
|
-
${truncate(
|
|
139
|
+
${truncate(this.userData.userName, 25)}
|
|
117
140
|
</p>
|
|
118
|
-
${
|
|
141
|
+
${activeInfoTemplate()}
|
|
119
142
|
</div>
|
|
120
143
|
</div>
|
|
121
144
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
145
|
+
${((_a = this.userData) === null || _a === void 0 ? void 0 : _a.isGracePeriod)
|
|
146
|
+
? html `<div class="mt-4">
|
|
147
|
+
<kompasid-grace-period
|
|
148
|
+
totalGracePeriod=${this.userData.totalGracePeriod}
|
|
149
|
+
isColumn="true"
|
|
150
|
+
isShowButton="true"
|
|
151
|
+
isBackgroundOnContentOnly="true"
|
|
152
|
+
paywall_location=${this.paywall_location}
|
|
153
|
+
paywall_subscription_package=${this.paywall_subscription_package}
|
|
154
|
+
paywall_subscription_id=${this.paywall_subscription_id}
|
|
155
|
+
paywall_subscription_price=${this.paywall_subscription_price}
|
|
156
|
+
paywall_position=${this.paywall_position}
|
|
157
|
+
tracker_page_type=${this.tracker_page_type}
|
|
158
|
+
tracker_content_id=${this.tracker_content_id}
|
|
159
|
+
tracker_content_title=${this.tracker_content_title}
|
|
160
|
+
tracker_content_categories=${this.tracker_content_categories}
|
|
161
|
+
tracker_content_type=${this.tracker_content_type}
|
|
162
|
+
tracker_user_type=${this.tracker_user_type}
|
|
163
|
+
tracker_subscription_status=${this.tracker_subscription_status}
|
|
164
|
+
tracker_page_domain=${this.tracker_page_domain}
|
|
165
|
+
tracker_metered_wall_type=${this.tracker_metered_wall_type}
|
|
166
|
+
tracker_metered_wall_balance=${this.tracker_metered_wall_balance}
|
|
167
|
+
></kompasid-grace-period>
|
|
168
|
+
</div>`
|
|
169
|
+
: subscribeButton()}
|
|
131
170
|
</div>`;
|
|
132
171
|
}
|
|
133
172
|
async connectedCallback() {
|
|
@@ -165,6 +204,54 @@ __decorate([
|
|
|
165
204
|
__decorate([
|
|
166
205
|
property({ type: Number })
|
|
167
206
|
], KompasHeaderAccountProfile.prototype, "totalGracePeriod", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: String })
|
|
209
|
+
], KompasHeaderAccountProfile.prototype, "paywall_location", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: String })
|
|
212
|
+
], KompasHeaderAccountProfile.prototype, "paywall_subscription_package", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: Number })
|
|
215
|
+
], KompasHeaderAccountProfile.prototype, "paywall_subscription_id", void 0);
|
|
216
|
+
__decorate([
|
|
217
|
+
property({ type: Number })
|
|
218
|
+
], KompasHeaderAccountProfile.prototype, "paywall_subscription_price", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
property({ type: Number })
|
|
221
|
+
], KompasHeaderAccountProfile.prototype, "paywall_position", void 0);
|
|
222
|
+
__decorate([
|
|
223
|
+
property({ type: String })
|
|
224
|
+
], KompasHeaderAccountProfile.prototype, "tracker_page_type", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: String })
|
|
227
|
+
], KompasHeaderAccountProfile.prototype, "tracker_content_id", void 0);
|
|
228
|
+
__decorate([
|
|
229
|
+
property({ type: String })
|
|
230
|
+
], KompasHeaderAccountProfile.prototype, "tracker_content_title", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
property({ type: String })
|
|
233
|
+
], KompasHeaderAccountProfile.prototype, "tracker_content_categories", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
property({ type: String })
|
|
236
|
+
], KompasHeaderAccountProfile.prototype, "tracker_content_type", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
property({ type: String })
|
|
239
|
+
], KompasHeaderAccountProfile.prototype, "tracker_user_type", void 0);
|
|
240
|
+
__decorate([
|
|
241
|
+
property({ type: String })
|
|
242
|
+
], KompasHeaderAccountProfile.prototype, "tracker_subscription_status", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
property({ type: String })
|
|
245
|
+
], KompasHeaderAccountProfile.prototype, "tracker_page_domain", void 0);
|
|
246
|
+
__decorate([
|
|
247
|
+
property({ type: String })
|
|
248
|
+
], KompasHeaderAccountProfile.prototype, "tracker_metered_wall_type", void 0);
|
|
249
|
+
__decorate([
|
|
250
|
+
property({ type: Number })
|
|
251
|
+
], KompasHeaderAccountProfile.prototype, "tracker_metered_wall_balance", void 0);
|
|
252
|
+
__decorate([
|
|
253
|
+
state()
|
|
254
|
+
], KompasHeaderAccountProfile.prototype, "maxGracePeriod", void 0);
|
|
168
255
|
KompasHeaderAccountProfile = __decorate([
|
|
169
256
|
customElement('kompasid-header-account-profile')
|
|
170
257
|
], KompasHeaderAccountProfile);
|
package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KompasHeaderAccountProfile.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGvC,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ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GACpC,0BAA0B,CA0JtC;SA1JY,0BAA0B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { truncate } from '../../utils/text.js'\n\n@customElement('kompasid-header-account-profile')\nexport class KompasHeaderAccountProfile extends LitElement {\n static styles = [\n css`\n .header-account--membership-icon {\n position: absolute;\n bottom: -2px;\n right: -2px;\n }\n `,\n TWStyles,\n ]\n\n @property({ type: String }) userInitialName = ''\n @property({ type: Object }) userData = {}\n @property({ type: String }) subscriptionUrl = ''\n @property({ type: Number }) totalGracePeriod = 0\n\n private renderSkeletonLoading() {\n return html`\n <div>\n <div class=\"flex flex-row mb-5 items-center gap-4 leading-none\">\n <div\n class=\"bg-grey-300 py-5 rounded-full h-16 w-16 animate-pulse\"\n ></div>\n <div class=\"flex flex-col text-left w-40 gap-y-2\">\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n </div>\n </div>\n <div>\n <div class=\"h-6 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n </div>\n </div>\n `\n }\n\n private renderProfileContent() {\n /**\n * Expired Button Element\n */\n const subscribeButton = () => {\n if (!(this.userData as any)?.updateMembership) {\n return html``\n }\n const handleSubscribe = () => {\n window.location.href = this.subscriptionUrl\n }\n\n return html`\n <div class=\"w-full\">\n <button\n onClick=${handleSubscribe}\n class=\"w-full rounded-lg px-4 py-3 mt-4 h-10 flex justify-center items-center bg-green-500 text-grey-100 font-bold text-base focus:outline-none\"\n >\n ${(this.userData as any)?.updateMembership}\n </button>\n </div>\n `\n }\n /**\n * expired Info Element\n */\n const expiredInfo = () => {\n const isNearExpired = (this.userData as any)?.isNearExpired\n const expiredTextColor = isNearExpired\n ? `text-orange-400`\n : `text-grey-600`\n\n return html`<p class=\"${expiredTextColor} font-bold\">\n ${(this.userData as any)?.expired}\n </p>`\n }\n\n /**\n * membership icon element, show if isMebership has truthy value\n */\n const membershipIcon = () => {\n if (!(this.userData as any)?.isMembership) {\n return html``\n }\n\n return html`\n <div>\n <img\n class=\"header-account--membership-icon\"\n src=\"https://cdn-www.kompas.id/global-header/crown-blue-10.svg\"\n alt=\"membership-crown-icon\"\n />\n </div>\n `\n }\n\n /**\n * Active Info Element\n */\n\n const activeInfo = () => {\n const isNearExpired = (this.userData as any)?.isNearExpired\n const expiredTextColor = isNearExpired\n ? `text-orange-400`\n : `text-grey-600`\n\n return html`<p class=\"capitalize text-sm ${expiredTextColor}\">\n ${(this.userData as any)?.activeInfo}\n </p>`\n }\n\n return html`<div\n class=\"active-info flex flex-col items-start leading-none text-left\"\n >\n <div class=\"flex flex-row items-center gap-4\">\n <div\n class=\"flex bg-brand-1 flex-shrink-0 p-5 rounded-full h-16 w-16 items-center justify-center relative\"\n >\n <span class=\"capitalize text-2xl text-grey-100 font-bold\"\n >${this.userInitialName}</span\n >\n ${membershipIcon()}\n </div>\n\n <div class=\"flex flex-col text-left\">\n <p class=\"capitalize font-bold text-base text-blue-600\">\n ${truncate((this.userData as any)?.userName, 25)}\n </p>\n ${activeInfo()} ${expiredInfo()}\n </div>\n </div>\n\n <div class=\"mt-4\">\n <!-- <kompas-grace-period\n totalGracePeriod=\"{this.totalGracePeriod}\"\n isColoumn=\"{true}\"\n isShowButton=\"{true}\"\n /> -->\n </div>\n\n ${subscribeButton()}\n </div>`\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n }\n\n render() {\n return html`\n <div class=\"flex flex-shrink-0 flex-col bg-blue-100 p-4\">\n ${!this.userData\n ? this.renderSkeletonLoading()\n : this.renderProfileContent()}\n </div>\n `\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KompasHeaderAccountProfile.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts"],"names":[],"mappings":";AAAA,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EAAE,CAAC;wEAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+EAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6EAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gFAAiC;AAKnD;IAAR,KAAK,EAAE;kEAA2B;AA1CxB,0BAA0B;IADtC,aAAa,CAAC,iCAAiC,CAAC;GACpC,0BAA0B,CA2MtC;SA3MY,0BAA0B","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { format, subDays, addDays } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { truncate } from '../../utils/text.js'\nimport { User } from '../kompasid-header-account/types.js'\nimport '../kompasid-grace-period/KompasGracePeriod.js'\n\n@customElement('kompasid-header-account-profile')\nexport class KompasHeaderAccountProfile extends LitElement {\n static styles = [\n css`\n .header-account--membership-icon {\n position: absolute;\n bottom: -2px;\n right: -2px;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n @property({ type: String }) userInitialName = ''\n @property({ type: Object }) userData = {} as User\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 /**\n * State\n */\n @state() private maxGracePeriod = 7\n\n formatDate(date: Date | string) {\n return format(new Date(date), 'dd MMM yyyy', { locale: id })\n }\n\n private renderSkeletonLoading() {\n return html`\n <div>\n <div class=\"flex flex-row mb-5 items-center gap-4 leading-none\">\n <div\n class=\"bg-grey-300 py-5 rounded-full h-16 w-16 animate-pulse\"\n ></div>\n <div class=\"flex flex-col text-left w-40 gap-y-2\">\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n <div class=\"h-3 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n </div>\n </div>\n <div>\n <div class=\"h-6 rounded-sm w-full bg-grey-300 animate-pulse\"></div>\n </div>\n </div>\n `\n }\n\n private renderProfileContent() {\n /**\n * Subs Button Element\n */\n const subscribeButton = () => {\n if (!(this.userData as any)?.updateMembership) {\n return html``\n }\n const handleSubscribe = () => {\n window.location.href = this.subscriptionUrl\n }\n\n return html`\n <div class=\"w-full\">\n <button\n onClick=${handleSubscribe}\n class=\"w-full rounded-lg px-4 py-3 mt-4 h-10 flex justify-center items-center bg-green-500 text-grey-100 font-bold text-base focus:outline-none\"\n >\n ${(this.userData as any)?.updateMembership}\n </button>\n </div>\n `\n }\n /**\n * membership icon element, show if isMebership has truthy value\n */\n const membershipIcon = () => {\n if (!this.userData?.isMembership) {\n return html``\n }\n\n return html`\n <div>\n <img\n class=\"header-account--membership-icon\"\n src=\"https://cdn-www.kompas.id/global-header/crown-blue-10.svg\"\n alt=\"membership-crown-icon\"\n />\n </div>\n `\n }\n\n /**\n * Active Info Element\n */\n\n const activeInfoTemplate = () => {\n const { isGracePeriod, totalGracePeriod, activeInfo } = this.userData\n\n const expiredTextColor = isGracePeriod\n ? `text-orange-500`\n : `text-grey-600`\n\n const startGracePeriodDate = this.formatDate(\n subDays(new Date().toLocaleDateString(), totalGracePeriod - 1)\n )\n const endGracePeriodDate = this.formatDate(\n addDays(\n new Date().toLocaleDateString(),\n this.maxGracePeriod - totalGracePeriod\n )\n )\n\n const text = isGracePeriod\n ? html`<span> Periode Masa Tenggang </span>\n <p class=\"font-bold\">\n ${startGracePeriodDate} - ${endGracePeriodDate}\n </p> `\n : activeInfo || ''\n\n return html`<p class=\"capitalize text-sm ${expiredTextColor}\">${text}</p>`\n }\n\n return html`<div\n class=\"active-info flex flex-col items-start leading-none text-left\"\n >\n <div class=\"flex flex-row items-center gap-4\">\n <div\n class=\"flex bg-brand-1 flex-shrink-0 p-5 rounded-full h-16 w-16 items-center justify-center relative\"\n >\n <span class=\"capitalize text-2xl text-grey-100 font-bold\"\n >${this.userInitialName}</span\n >\n ${membershipIcon()}\n </div>\n\n <div class=\"flex flex-col text-left\">\n <p class=\"capitalize font-bold text-base text-blue-600\">\n ${truncate(this.userData.userName, 25)}\n </p>\n ${activeInfoTemplate()}\n </div>\n </div>\n\n ${this.userData?.isGracePeriod\n ? html`<div class=\"mt-4\">\n <kompasid-grace-period\n totalGracePeriod=${this.userData.totalGracePeriod}\n isColumn=\"true\"\n isShowButton=\"true\"\n isBackgroundOnContentOnly=\"true\"\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-grace-period>\n </div>`\n : subscribeButton()}\n </div>`\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n }\n\n render() {\n return html`\n <div class=\"flex flex-shrink-0 flex-col bg-blue-100 p-4\">\n ${!this.userData\n ? this.renderSkeletonLoading()\n : this.renderProfileContent()}\n </div>\n `\n }\n}\n"]}
|