@kompasid/lit-web-components 0.7.9 → 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.
Files changed (23) hide show
  1. package/demo/index.html +37 -1
  2. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.d.ts +8 -1
  3. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +95 -33
  4. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
  5. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.d.ts +18 -0
  6. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +78 -0
  7. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -1
  8. package/dist/src/components/kompasid-header-account/types.d.ts +2 -0
  9. package/dist/src/components/kompasid-header-account/types.js.map +1 -1
  10. package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.d.ts +29 -2
  11. package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +115 -57
  12. package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -1
  13. package/dist/tailwind/tailwind.js +151 -171
  14. package/dist/tailwind/tailwind.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/src/components/kompasid-grace-period/KompasGracePeriod.ts +93 -31
  18. package/src/components/kompasid-grace-period/readme.md +2 -0
  19. package/src/components/kompasid-header-account/KompasHeaderAccount.ts +34 -0
  20. package/src/components/kompasid-header-account/types.ts +2 -0
  21. package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +84 -56
  22. package/tailwind/tailwind.css +38 -99
  23. package/tailwind/tailwind.ts +151 -171
@@ -1,15 +1,45 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { LitElement, html, css } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
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
- this.subscriptionUrl = '';
12
17
  this.totalGracePeriod = 0;
18
+ /**
19
+ * Props For Grace Period Tracker
20
+ */
21
+ this.paywall_location = '';
22
+ this.paywall_subscription_package = '';
23
+ this.paywall_subscription_id = 0;
24
+ this.paywall_subscription_price = 0;
25
+ this.paywall_position = 0;
26
+ this.tracker_page_type = '';
27
+ this.tracker_content_id = '';
28
+ this.tracker_content_title = '';
29
+ this.tracker_content_categories = '';
30
+ this.tracker_content_type = '';
31
+ this.tracker_user_type = '';
32
+ this.tracker_subscription_status = '';
33
+ this.tracker_page_domain = '';
34
+ this.tracker_metered_wall_type = '';
35
+ this.tracker_metered_wall_balance = 0;
36
+ /**
37
+ * State
38
+ */
39
+ this.maxGracePeriod = 7;
40
+ }
41
+ formatDate(date) {
42
+ return format(new Date(date), 'dd MMM yyyy', { locale: id });
13
43
  }
14
44
  renderSkeletonLoading() {
15
45
  return html `
@@ -31,42 +61,6 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
31
61
  `;
32
62
  }
33
63
  renderProfileContent() {
34
- var _a;
35
- /**
36
- * Expired Button Element
37
- */
38
- const subscribeButton = () => {
39
- var _a, _b;
40
- if (!((_a = this.userData) === null || _a === void 0 ? void 0 : _a.updateMembership)) {
41
- return html ``;
42
- }
43
- const handleSubscribe = () => {
44
- window.location.href = this.subscriptionUrl;
45
- };
46
- return html `
47
- <div class="w-full">
48
- <button
49
- onClick=${handleSubscribe}
50
- 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"
51
- >
52
- ${(_b = this.userData) === null || _b === void 0 ? void 0 : _b.updateMembership}
53
- </button>
54
- </div>
55
- `;
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
- };
70
64
  /**
71
65
  * membership icon element, show if isMebership has truthy value
72
66
  */
@@ -88,15 +82,20 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
88
82
  /**
89
83
  * Active Info Element
90
84
  */
91
- const activeInfo = () => {
92
- var _a, _b;
93
- const isNearExpired = (_a = this.userData) === null || _a === void 0 ? void 0 : _a.isNearExpired;
94
- const expiredTextColor = isNearExpired
95
- ? `text-orange-400`
85
+ const activeInfoTemplate = () => {
86
+ const { isGracePeriod, totalGracePeriod, activeInfo } = this.userData;
87
+ const expiredTextColor = isGracePeriod
88
+ ? `text-orange-500`
96
89
  : `text-grey-600`;
97
- return html `<p class="capitalize text-sm ${expiredTextColor}">
98
- ${(_b = this.userData) === null || _b === void 0 ? void 0 : _b.activeInfo}
99
- </p>`;
90
+ const startGracePeriodDate = this.formatDate(subDays(new Date().toLocaleDateString(), totalGracePeriod - 1));
91
+ const endGracePeriodDate = this.formatDate(addDays(new Date().toLocaleDateString(), this.maxGracePeriod - totalGracePeriod));
92
+ const text = isGracePeriod
93
+ ? html `<span> Periode Masa Tenggang </span>
94
+ <p class="font-bold">
95
+ ${startGracePeriodDate} - ${endGracePeriodDate}
96
+ </p> `
97
+ : activeInfo || '';
98
+ return html `<p class="capitalize text-sm ${expiredTextColor}">${text}</p>`;
100
99
  };
101
100
  return html `<div
102
101
  class="active-info flex flex-col items-start leading-none text-left"
@@ -113,21 +112,35 @@ let KompasHeaderAccountProfile = class KompasHeaderAccountProfile extends LitEle
113
112
 
114
113
  <div class="flex flex-col text-left">
115
114
  <p class="capitalize font-bold text-base text-blue-600">
116
- ${truncate((_a = this.userData) === null || _a === void 0 ? void 0 : _a.userName, 25)}
115
+ ${truncate(this.userData.userName, 25)}
117
116
  </p>
118
- ${activeInfo()} ${expiredInfo()}
117
+ ${activeInfoTemplate()}
119
118
  </div>
120
119
  </div>
121
120
 
122
121
  <div class="mt-4">
123
- <!-- <kompas-grace-period
124
- totalGracePeriod="{this.totalGracePeriod}"
125
- isColoumn="{true}"
126
- isShowButton="{true}"
127
- /> -->
122
+ <kompasid-grace-period
123
+ totalGracePeriod=${this.userData.totalGracePeriod}
124
+ isColumn="true"
125
+ isShowButton="true"
126
+ isBackgroundOnContentOnly="true"
127
+ paywall_location=${this.paywall_location}
128
+ paywall_subscription_package=${this.paywall_subscription_package}
129
+ paywall_subscription_id=${this.paywall_subscription_id}
130
+ paywall_subscription_price=${this.paywall_subscription_price}
131
+ paywall_position=${this.paywall_position}
132
+ tracker_page_type=${this.tracker_page_type}
133
+ tracker_content_id=${this.tracker_content_id}
134
+ tracker_content_title=${this.tracker_content_title}
135
+ tracker_content_categories=${this.tracker_content_categories}
136
+ tracker_content_type=${this.tracker_content_type}
137
+ tracker_user_type=${this.tracker_user_type}
138
+ tracker_subscription_status=${this.tracker_subscription_status}
139
+ tracker_page_domain=${this.tracker_page_domain}
140
+ tracker_metered_wall_type=${this.tracker_metered_wall_type}
141
+ tracker_metered_wall_balance=${this.tracker_metered_wall_balance}
142
+ ></kompasid-grace-period>
128
143
  </div>
129
-
130
- ${subscribeButton()}
131
144
  </div>`;
132
145
  }
133
146
  async connectedCallback() {
@@ -159,12 +172,57 @@ __decorate([
159
172
  __decorate([
160
173
  property({ type: Object })
161
174
  ], KompasHeaderAccountProfile.prototype, "userData", void 0);
175
+ __decorate([
176
+ property({ type: Number })
177
+ ], KompasHeaderAccountProfile.prototype, "totalGracePeriod", void 0);
178
+ __decorate([
179
+ property({ type: String })
180
+ ], KompasHeaderAccountProfile.prototype, "paywall_location", void 0);
162
181
  __decorate([
163
182
  property({ type: String })
164
- ], KompasHeaderAccountProfile.prototype, "subscriptionUrl", void 0);
183
+ ], KompasHeaderAccountProfile.prototype, "paywall_subscription_package", void 0);
165
184
  __decorate([
166
185
  property({ type: Number })
167
- ], KompasHeaderAccountProfile.prototype, "totalGracePeriod", void 0);
186
+ ], KompasHeaderAccountProfile.prototype, "paywall_subscription_id", void 0);
187
+ __decorate([
188
+ property({ type: Number })
189
+ ], KompasHeaderAccountProfile.prototype, "paywall_subscription_price", void 0);
190
+ __decorate([
191
+ property({ type: Number })
192
+ ], KompasHeaderAccountProfile.prototype, "paywall_position", void 0);
193
+ __decorate([
194
+ property({ type: String })
195
+ ], KompasHeaderAccountProfile.prototype, "tracker_page_type", void 0);
196
+ __decorate([
197
+ property({ type: String })
198
+ ], KompasHeaderAccountProfile.prototype, "tracker_content_id", void 0);
199
+ __decorate([
200
+ property({ type: String })
201
+ ], KompasHeaderAccountProfile.prototype, "tracker_content_title", void 0);
202
+ __decorate([
203
+ property({ type: String })
204
+ ], KompasHeaderAccountProfile.prototype, "tracker_content_categories", void 0);
205
+ __decorate([
206
+ property({ type: String })
207
+ ], KompasHeaderAccountProfile.prototype, "tracker_content_type", void 0);
208
+ __decorate([
209
+ property({ type: String })
210
+ ], KompasHeaderAccountProfile.prototype, "tracker_user_type", void 0);
211
+ __decorate([
212
+ property({ type: String })
213
+ ], KompasHeaderAccountProfile.prototype, "tracker_subscription_status", void 0);
214
+ __decorate([
215
+ property({ type: String })
216
+ ], KompasHeaderAccountProfile.prototype, "tracker_page_domain", void 0);
217
+ __decorate([
218
+ property({ type: String })
219
+ ], KompasHeaderAccountProfile.prototype, "tracker_metered_wall_type", void 0);
220
+ __decorate([
221
+ property({ type: Number })
222
+ ], KompasHeaderAccountProfile.prototype, "tracker_metered_wall_balance", void 0);
223
+ __decorate([
224
+ state()
225
+ ], KompasHeaderAccountProfile.prototype, "maxGracePeriod", void 0);
168
226
  KompasHeaderAccountProfile = __decorate([
169
227
  customElement('kompasid-header-account-profile')
170
228
  ], KompasHeaderAccountProfile);
@@ -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,UAAU;IAAnD;;QAYuB,oBAAe,GAAG,EAAE,CAAA;QACpB,aAAQ,GAAG,EAAE,CAAA;QACb,oBAAe,GAAG,EAAE,CAAA;QACpB,qBAAgB,GAAG,CAAC,CAAA;IA2IlD,CAAC;IAzIS,qBAAqB;QAC3B,OAAO,IAAI,CAAA;;;;;;;;;;;;;;;;KAgBV,CAAA;IACH,CAAC;IAEO,oBAAoB;;QAC1B;;WAEG;QACH,MAAM,eAAe,GAAG,GAAG,EAAE;;YAC3B,IAAI,CAAC,CAAA,MAAC,IAAI,CAAC,QAAgB,0CAAE,gBAAgB,CAAA,EAAE;gBAC7C,OAAO,IAAI,CAAA,EAAE,CAAA;aACd;YACD,MAAM,eAAe,GAAG,GAAG,EAAE;gBAC3B,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAA;YAC7C,CAAC,CAAA;YAED,OAAO,IAAI,CAAA;;;sBAGK,eAAe;;;cAGvB,MAAC,IAAI,CAAC,QAAgB,0CAAE,gBAAgB;;;OAG/C,CAAA;QACH,CAAC,CAAA;QACD;;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AA;;UAEL,CAAC,IAAI,CAAC,QAAQ;YACd,CAAC,CAAC,IAAI,CAAC,qBAAqB,EAAE;YAC9B,CAAC,CAAC,IAAI,CAAC,oBAAoB,EAAE;;KAElC,CAAA;IACH,CAAC;;AAxJM,iCAAM,GAAG;IACd,GAAG,CAAA;;;;;;KAMF;IACD,QAAQ;CACT,CAAA;AAE2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAqB;AACpB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAqB;AAfrC,0BAA0B;IADtC,aAAa,CAAC,iCAAiC,CAAC;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,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAE9C,OAAO,+CAA+C,CAAA;AAG/C,IAAM,0BAA0B,GAAhC,MAAM,0BAA2B,SAAQ,UAAU;IAAnD;;QAYL;;WAEG;QACyB,oBAAe,GAAG,EAAE,CAAA;QACpB,aAAQ,GAAG,EAAU,CAAA;QACrB,qBAAgB,GAAG,CAAC,CAAA;QAEhD;;WAEG;QACyB,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC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;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;AAzCxB,0BAA0B;IADtC,aAAa,CAAC,iCAAiC,CAAC;GACpC,0BAA0B,CAkLtC;SAlLY,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: 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 * 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 <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 </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"]}