@kompasid/lit-web-components 0.9.11 → 0.9.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/demo/index.html +2 -2
  2. package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +9 -24
  3. package/dist/src/components/kompasid-freewall/KompasFreewall.js +44 -100
  4. package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
  5. package/dist/src/components/kompasid-freewall/old_KompasFreewall.d.ts +96 -0
  6. package/dist/src/components/kompasid-freewall/old_KompasFreewall.js +305 -0
  7. package/dist/src/components/kompasid-freewall/old_KompasFreewall.js.map +1 -0
  8. package/dist/src/components/kompasid-freewall/types.d.ts +26 -0
  9. package/dist/src/components/kompasid-freewall/types.js.map +1 -1
  10. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +9 -14
  11. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +58 -102
  12. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -1
  13. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.d.ts +34 -0
  14. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js +228 -0
  15. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js.map +1 -0
  16. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +8 -19
  17. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +33 -52
  18. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -1
  19. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.d.ts +38 -0
  20. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js +125 -0
  21. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js.map +1 -0
  22. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +1 -1
  23. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
  24. package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +5 -7
  25. package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
  26. package/dist/tailwind/tailwind.js +48 -8
  27. package/dist/tailwind/tailwind.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/src/components/kompasid-freewall/KompasFreewall.ts +52 -85
  31. package/src/components/kompasid-freewall/old_KompasFreewall.ts +255 -0
  32. package/src/components/kompasid-freewall/readme.md +40 -84
  33. package/src/components/kompasid-freewall/types.ts +29 -0
  34. package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +59 -101
  35. package/src/components/kompasid-freewall-body/old_KompasFreewallBody.ts +224 -0
  36. package/src/components/kompasid-freewall-body/readme.md +31 -7
  37. package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +31 -39
  38. package/src/components/kompasid-freewall-head/old_KompasFreewallHead.ts +103 -0
  39. package/src/components/kompasid-freewall-head/readme.md +29 -13
  40. package/src/components/kompasid-grace-period/KompasGracePeriod.ts +1 -1
  41. package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +5 -7
  42. package/tailwind/tailwind.css +48 -6
  43. package/tailwind/tailwind.ts +48 -8
  44. package/tailwind.config.js +1 -1
@@ -2,14 +2,20 @@ import { html, css, LitElement, nothing } from 'lit'
2
2
  import { property, customElement } from 'lit/decorators.js'
3
3
  import { TWStyles } from '../../../tailwind/tailwind.js'
4
4
  import { addGoogleFonts } from '../../utils/googleFont.js'
5
- import { JsonPackageData, PackageData } from '../kompasid-freewall/types.js'
6
- import { faCheck } from '../../../assets/font-awesome.js'
7
- import { redirectToRegister } from '../../utils/cta.js'
5
+ import { formatRupiah } from '../../utils/formatRupiah.js'
6
+ import { CardPackage } from '../kompasid-freewall/types.js'
8
7
 
9
8
  @customElement('kompasid-freewall-body')
10
9
  export class KompasFreewallBody extends LitElement {
11
10
  static styles = [
12
11
  css`
12
+ .hideScroll::-webkit-scrollbar {
13
+ height: 0px;
14
+ }
15
+ .hideScroll {
16
+ scrollbar-width: none;
17
+ }
18
+
13
19
  .font-lora {
14
20
  font-family: 'Lora', 'Georgia', 'serif';
15
21
  }
@@ -81,24 +87,15 @@ export class KompasFreewallBody extends LitElement {
81
87
  * Props
82
88
  */
83
89
  /**
84
- * property isLogin untuk menghandle apakah user sudah login atau belum
85
- * property type untuk menghandle tipe freewall
86
- * property onSubscriptionClick to handle cta when subscription button is clicked
87
- * packageData sebagai data package yang diambil dari kompasid-freewall
90
+ * property bodyData to handle multiple data card CardPackage
91
+ * property onButtonClick to handle cta when button is clicked and set specific card url and position
88
92
  */
89
93
 
90
- @property({ type: Boolean }) isLogin = false
91
- @property({ type: String }) type: 'article' | 'landing_page' = 'article'
92
- @property() onSubscriptionClick = () => {}
93
- @property({ type: Object }) packageData: PackageData = {} as PackageData
94
- @property({ type: Object }) jsonPackageData: JsonPackageData =
95
- {} as JsonPackageData
96
-
97
- description = [
98
- 'Akses seluruh konten Kompas.id di web & aplikasi',
99
- 'ePaper hingga 30 edisi terakhir',
100
- 'Buku digital tiap bulannya di aplikasi ',
101
- ]
94
+ @property() onButtonClick = (url: string, position: number) => ({
95
+ url,
96
+ position,
97
+ })
98
+ @property({ type: Object }) bodyData: CardPackage[] = []
102
99
 
103
100
  /**
104
101
  * Lifecycle
@@ -114,99 +111,61 @@ export class KompasFreewallBody extends LitElement {
114
111
  * Component
115
112
  */
116
113
 
117
- private subscriptionCardComponent() {
114
+ private newCard(item: CardPackage) {
118
115
  return html`
119
- <div class="relative">
116
+ <div class="relative snap-start scroll-mx-4 w-[276px] flex lg:w-auto">
120
117
  <div
121
118
  id="subscription-card"
122
- class="flex justify-between items-center relative z-10 flex-col w-[328px] ${this
123
- .isLogin
124
- ? 'md:w-[580px]'
125
- : 'md:w-[350px] lg:w-[410px]'} py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] border-2 border-yellow-400 bg-white"
119
+ class="flex justify-between items-start relative z-10 flex-col w-[328px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white border border-grey-300"
126
120
  >
127
- <div
128
- class="flex w-full flex-col ${this.isLogin
129
- ? 'items-center md:w-[374px] text-center'
130
- : 'items-start text-start'}"
131
- >
132
- <h5
133
- class="font-lora text-lg md:text-xl font-bold leading-[30px] ${this
134
- .isLogin && 'w-60 md:w-full'} text-grey-600"
135
- >
136
- ${this.isLogin
137
- ? this.jsonPackageData.subscriptionTitle
138
- : this.jsonPackageData.subscriptionTitleGuest}
121
+ <div class="flex w-full flex-col items-start mb-4 text-start">
122
+ <h5 class="font-lora leading-[30px] text-grey-600">
123
+ ${item.title}
139
124
  </h5>
140
- ${this.descriptionSection()}
125
+ </div>
126
+ <div class="text-xl text-grey-600 font-lora mb-8">
127
+ <div>
128
+ ${item.priceDiscount
129
+ ? html`
130
+ <span class="text-sm text-grey-400"
131
+ ><s>${formatRupiah(item.priceBased)}</s></span
132
+ >
133
+ `
134
+ : nothing}
135
+ <span class="${item.priceDiscount ? 'text-orange-400' : ''}"
136
+ >${formatRupiah(
137
+ item.priceDiscount ? item.priceDiscount : item.priceBased
138
+ )}</span
139
+ >/<span>${item.duration}</span>
140
+ </div>
141
+ ${item.priceDiscount
142
+ ? html` <div class="text-sm text-grey-500 font-sans mt-3">
143
+ Selanjutnya ${formatRupiah(item.priceBased)}/${item.duration}
144
+ </div>`
145
+ : nothing}
141
146
  </div>
142
147
  <button
143
- @click=${this.onSubscriptionClick}
144
- class="bg-green-500 whitespace-nowrap w-full rounded ${this
145
- .isLogin &&
146
- 'md:w-[370px]'} md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
148
+ @click=${() => this.onButtonClick(item.cta.url, item.position)}
149
+ class="whitespace-nowrap w-full rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base font-bold leading-[18px] ${item.ribbon
150
+ ? 'text-white bg-brand-1'
151
+ : 'text-brand-1 bg-white border border-brand-1'}"
147
152
  >
148
- ${this.jsonPackageData.subscriptionButtonText}
153
+ ${item.cta.text}
149
154
  </button>
150
155
  </div>
151
- <div id="ribbon-container">
152
- <div
153
- class="text-[11px] font-medium text-grey-600 font-roboto-condensed flex justify-center items-center"
154
- >
155
- <span class="-ml-2">Penawaran Terbaik</span>
156
- </div>
157
- </div>
156
+ ${item.ribbon
157
+ ? html`<div id="ribbon-container">
158
+ <div
159
+ class="text-[11px] font-medium text-grey-600 font-roboto-condensed flex justify-center items-center"
160
+ >
161
+ <span class="-ml-2">Penawaran Terbaik</span>
162
+ </div>
163
+ </div>`
164
+ : nothing}
158
165
  </div>
159
166
  `
160
167
  }
161
168
 
162
- private registerCardComponent() {
163
- return html`
164
- <div
165
- class="flex flex-col justify-between md:min-h-[244px] lg:min-h-[220px] w-[328px] md:w-[350px] lg:w-[410px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white"
166
- >
167
- <div>
168
- <h5
169
- class="font-lora text-lg md:text-xl font-bold leading-[30px] text-grey-600"
170
- >
171
- ${this.jsonPackageData.registerTitle}
172
- </h5>
173
- <div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
174
- ${this.jsonPackageData.registerDescription.map(
175
- item => html`
176
- <div class="flex items-start lg:items-center">
177
- <div class="mt-1 lg:mt-0">${faCheck()}</div>
178
- <h6 class="text-base text-grey-600 ml-1 text-start">
179
- ${item}
180
- </h6>
181
- </div>
182
- `
183
- )}
184
- </div>
185
- </div>
186
- <button
187
- @click=${() => redirectToRegister('freewall')}
188
- class="bg-white border border-brand-1 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-brand-1 font-bold leading-[18px]"
189
- >
190
- ${this.jsonPackageData.registerButtonText}
191
- </button>
192
- </div>
193
- `
194
- }
195
-
196
- private descriptionSection() {
197
- return html`<div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
198
- ${this.jsonPackageData.subscriptionDescription.map(
199
- item =>
200
- html`
201
- <div class="flex items-start lg:items-center">
202
- <div class="mt-1 lg:mt-0">${faCheck()}</div>
203
- <h6 class="text-base text-grey-600 ml-1 text-start">${item}</h6>
204
- </div>
205
- `
206
- )}
207
- </div>`
208
- }
209
-
210
169
  /**
211
170
  * Render Statement
212
171
  */
@@ -214,10 +173,9 @@ export class KompasFreewallBody extends LitElement {
214
173
  render() {
215
174
  return html`
216
175
  <div
217
- class="w-full h-full flex flex-col md:flex-row pt-[5px] relative space-y-4 md:space-x-5 md:space-y-0 justify-center items-center"
176
+ class="w-full h-full flex flex-row pt-[5px] relative snap-x overflow-x-scroll gap-4 hideScroll px-4 sm:px-0 sm:gap-6 sm:justify-center"
218
177
  >
219
- ${this.subscriptionCardComponent()}
220
- ${!this.isLogin ? this.registerCardComponent() : nothing}
178
+ ${this.bodyData.map(item => this.newCard(item))}
221
179
  </div>
222
180
  `
223
181
  }
@@ -0,0 +1,224 @@
1
+ import { html, css, LitElement, nothing } from 'lit'
2
+ import { property, customElement } from 'lit/decorators.js'
3
+ import { TWStyles } from '../../../tailwind/tailwind.js'
4
+ import { addGoogleFonts } from '../../utils/googleFont.js'
5
+ import { JsonPackageData, PackageData } from '../kompasid-freewall/types.js'
6
+ import { faCheck } from '../../../assets/font-awesome.js'
7
+ import { redirectToRegister } from '../../utils/cta.js'
8
+
9
+ @customElement('kompasid-freewall-body')
10
+ export class KompasFreewallBody extends LitElement {
11
+ static styles = [
12
+ css`
13
+ .font-lora {
14
+ font-family: 'Lora', 'Georgia', 'serif';
15
+ }
16
+
17
+ .font-roboto-condensed {
18
+ font-family: 'Roboto Condensed', sans-serif;
19
+ }
20
+
21
+ /* ----- Ribbon Container ---------------------------------------*/
22
+ #ribbon-container {
23
+ background: transparent;
24
+ height: 130px;
25
+ width: 200px;
26
+ position: absolute;
27
+ top: -5px;
28
+ right: -5px;
29
+ overflow: hidden;
30
+ }
31
+
32
+ /* ----- Top Curl ---------------------------------------*/
33
+ #ribbon-container:before {
34
+ content: '';
35
+ display: block;
36
+ -webkit-border-radius: 10px 10px 0px 0px;
37
+ border-radius: 10px 10px 0px 0px;
38
+ width: 35px;
39
+ height: 10px;
40
+ position: absolute;
41
+ right: 60px;
42
+ background: #b78b00;
43
+ z-index: 1;
44
+ }
45
+
46
+ /* ----- Right Curl ---------------------------------------*/
47
+ #ribbon-container:after {
48
+ content: '';
49
+ display: block;
50
+ -webkit-border-radius: 0px 10px 10px 0px;
51
+ border-radius: 0px 10px 10px 0px;
52
+ width: 10px;
53
+ height: 35px;
54
+ position: absolute;
55
+ right: 0px;
56
+ top: 60px;
57
+ background: #b78b00;
58
+ }
59
+
60
+ /* ----- Ribbon ---------------------------------------*/
61
+ #ribbon-container > div {
62
+ width: 140px;
63
+ height: 28px;
64
+ position: relative;
65
+ top: 24px;
66
+ right: -100px;
67
+ z-index: 11;
68
+ overflow: hidden;
69
+ transform: rotate(45deg);
70
+ -ms-transform: rotate(45deg); /* IE 9 */
71
+ -moz-transform: rotate(45deg); /* Firefox */
72
+ -webkit-transform: rotate(45deg); /* Safari and Chrome */
73
+ -o-transform: rotate(45deg); /* Opera */
74
+ background: #ffcc00;
75
+ }
76
+ `,
77
+ TWStyles,
78
+ ]
79
+
80
+ /**
81
+ * Props
82
+ */
83
+ /**
84
+ * property isLogin untuk menghandle apakah user sudah login atau belum
85
+ * property type untuk menghandle tipe freewall
86
+ * property onSubscriptionClick to handle cta when subscription button is clicked
87
+ * packageData sebagai data package yang diambil dari kompasid-freewall
88
+ */
89
+
90
+ @property({ type: Boolean }) isLogin = false
91
+ @property({ type: String }) type: 'article' | 'landing_page' = 'article'
92
+ @property() onSubscriptionClick = () => {}
93
+ @property({ type: Object }) packageData: PackageData = {} as PackageData
94
+ @property({ type: Object }) jsonPackageData: JsonPackageData =
95
+ {} as JsonPackageData
96
+
97
+ description = [
98
+ 'Akses seluruh konten Kompas.id di web & aplikasi',
99
+ 'ePaper hingga 30 edisi terakhir',
100
+ 'Buku digital tiap bulannya di aplikasi ',
101
+ ]
102
+
103
+ /**
104
+ * Lifecycle
105
+ */
106
+
107
+ override async connectedCallback() {
108
+ super.connectedCallback()
109
+ await this.updateComplete
110
+ addGoogleFonts(['pt-sans', 'lora', 'roboto-condensed'])
111
+ }
112
+
113
+ /**
114
+ * Component
115
+ */
116
+
117
+ private subscriptionCardComponent() {
118
+ return html`
119
+ <div class="relative">
120
+ <div
121
+ id="subscription-card"
122
+ class="flex justify-between items-center relative z-10 flex-col w-[328px] ${this
123
+ .isLogin
124
+ ? 'md:w-[580px]'
125
+ : 'md:w-[350px] lg:w-[410px]'} py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] border-2 border-yellow-400 bg-white"
126
+ >
127
+ <div
128
+ class="flex w-full flex-col ${this.isLogin
129
+ ? 'items-center md:w-[374px] text-center'
130
+ : 'items-start text-start'}"
131
+ >
132
+ <h5
133
+ class="font-lora text-lg md:text-xl font-bold leading-[30px] ${this
134
+ .isLogin && 'w-60 md:w-full'} text-grey-600"
135
+ >
136
+ ${this.isLogin
137
+ ? this.jsonPackageData.subscriptionTitle
138
+ : this.jsonPackageData.subscriptionTitleGuest}
139
+ </h5>
140
+ ${this.descriptionSection()}
141
+ </div>
142
+ <button
143
+ @click=${this.onSubscriptionClick}
144
+ class="bg-green-500 whitespace-nowrap w-full rounded ${this
145
+ .isLogin &&
146
+ 'md:w-[370px]'} md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
147
+ >
148
+ ${this.jsonPackageData.subscriptionButtonText}
149
+ </button>
150
+ </div>
151
+ <div id="ribbon-container">
152
+ <div
153
+ class="text-[11px] font-medium text-grey-600 font-roboto-condensed flex justify-center items-center"
154
+ >
155
+ <span class="-ml-2">Penawaran Terbaik</span>
156
+ </div>
157
+ </div>
158
+ </div>
159
+ `
160
+ }
161
+
162
+ private registerCardComponent() {
163
+ return html`
164
+ <div
165
+ class="flex flex-col justify-between md:min-h-[244px] lg:min-h-[220px] w-[328px] md:w-[350px] lg:w-[410px] py-3 px-[10px] md:p-5 md:pt-3 rounded-[10px] bg-white"
166
+ >
167
+ <div>
168
+ <h5
169
+ class="font-lora text-lg md:text-xl font-bold leading-[30px] text-grey-600"
170
+ >
171
+ ${this.jsonPackageData.registerTitle}
172
+ </h5>
173
+ <div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
174
+ ${this.jsonPackageData.registerDescription.map(
175
+ item => html`
176
+ <div class="flex items-start lg:items-center">
177
+ <div class="mt-1 lg:mt-0">${faCheck()}</div>
178
+ <h6 class="text-base text-grey-600 ml-1 text-start">
179
+ ${item}
180
+ </h6>
181
+ </div>
182
+ `
183
+ )}
184
+ </div>
185
+ </div>
186
+ <button
187
+ @click=${() => redirectToRegister('freewall')}
188
+ class="bg-white border border-brand-1 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-brand-1 font-bold leading-[18px]"
189
+ >
190
+ ${this.jsonPackageData.registerButtonText}
191
+ </button>
192
+ </div>
193
+ `
194
+ }
195
+
196
+ private descriptionSection() {
197
+ return html`<div class="flex flex-col space-y-1 mt-3 mb-4 md:mt-4 md:mb-5">
198
+ ${this.jsonPackageData.subscriptionDescription.map(
199
+ item =>
200
+ html`
201
+ <div class="flex items-start lg:items-center">
202
+ <div class="mt-1 lg:mt-0">${faCheck()}</div>
203
+ <h6 class="text-base text-grey-600 ml-1 text-start">${item}</h6>
204
+ </div>
205
+ `
206
+ )}
207
+ </div>`
208
+ }
209
+
210
+ /**
211
+ * Render Statement
212
+ */
213
+
214
+ render() {
215
+ return html`
216
+ <div
217
+ class="w-full h-full flex flex-col md:flex-row pt-[5px] relative space-y-4 md:space-x-5 md:space-y-0 justify-center items-center"
218
+ >
219
+ ${this.subscriptionCardComponent()}
220
+ ${!this.isLogin ? this.registerCardComponent() : nothing}
221
+ </div>
222
+ `
223
+ }
224
+ }
@@ -2,12 +2,36 @@
2
2
 
3
3
  ## Properties
4
4
 
5
- | Property | Attribute | Description | Type | Default |
6
- | ------------------------------ | ------------------------------ | ---------------------------------------------------------------------------------------- | -------- | ------- |
7
- | `isLogin` | `isLogin` | property isLogin untuk menghandle apakah user sudah login atau belum | `boolean` | `false` |
8
- | `type` | `type` | property type untuk menghandle tipe freewall | `"article" \| "landing_page"` | `"article"` |
9
- | `packageData` | `packageData` | packageData sebagai data package yang akan di offer | `PackageData` | `{}` |
5
+ | Property | Attribute | Description | Type | Default |
6
+ | ---------------- | ----------- | ------------------------------------------------------------------------------------------------- | ----------------- | ------------------------ |
7
+ | `bodyData` | | Data array berisi daftar paket langganan (berupa kartu) yang akan ditampilkan. | `CardPackage[]` | `[]` |
8
+ | `onButtonClick` | | Fungsi untuk menangani klik tombol CTA di tiap kartu. Menerima parameter URL dan posisi paket. | `Function` | `(url: string, position: number) => ({ url, position })` |
10
9
 
11
- ----------------------------------------------
10
+ ---
12
11
 
13
- *Terbikin oleh tim front-end kompas.id*
12
+ ## CardPackage Structure
13
+
14
+ Struktur objek yang digunakan di dalam `bodyData[]`:
15
+
16
+ | Property | Type | Description |
17
+ | ---------------- | ---------- | ----------------------------------------------------------------- |
18
+ | `position` | `number` | Posisi urutan kartu di dalam tampilan. |
19
+ | `packageId` | `string` | ID unik paket. |
20
+ | `packageSlug` | `string` | Slug URL untuk paket tersebut. |
21
+ | `title` | `string` | Judul atau nama paket langganan. |
22
+ | `ribbon` | `boolean` | Menandai apakah paket adalah penawaran spesial ("Penawaran Terbaik"). |
23
+ | `priceBased` | `string` | Harga asli (tanpa diskon). |
24
+ | `priceDiscount` | `string` | Harga setelah diskon (opsional). |
25
+ | `duration` | `string` | Durasi langganan (contoh: `"12 bulan"` atau `"bulan"`). |
26
+ | `cta` | `object` | Data tombol CTA. |
27
+
28
+ **cta structure:**
29
+
30
+ | Property | Type | Description |
31
+ | -------- | -------- | ------------------------------ |
32
+ | `text` | `string` | Label tombol CTA. |
33
+ | `url` | `string` | URL tujuan saat tombol diklik. |
34
+
35
+ ---
36
+
37
+ *Dibuat oleh tim front-end kompas.id*
@@ -4,7 +4,7 @@ import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
4
4
  import { TWStyles } from '../../../tailwind/tailwind.js'
5
5
  import { addGoogleFonts } from '../../utils/googleFont.js'
6
6
  import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
7
- import { JsonPackageData, PackageData } from '../kompasid-freewall/types.js'
7
+ import { HeadDataFreeWall } from '../kompasid-freewall/types.js'
8
8
 
9
9
  @customElement('kompasid-freewall-head')
10
10
  export class KompasFreewallHead extends LitElement {
@@ -13,36 +13,30 @@ export class KompasFreewallHead extends LitElement {
13
13
  /**
14
14
  * Props
15
15
  */
16
- /**
17
- * property isLogin untuk menghandle apakah user sudah login atau belum
18
- * property type untuk menghandle tipe freewall
19
- * property head_copy_expand to update copy header when expand
20
- * property head_copy_collapse to update copy header when collapse
21
- * property expand to handle expand/collapse
22
- * property toggleExpand to handle toggle expand/collapse
23
- * property onSubscriptionClick to handle cta when subscription button is clicked
24
- */
25
-
26
- @property({ type: Boolean }) isLogin = false
27
- @property({ type: String }) type: 'article' | 'landing_page' = 'article'
28
- @property({ type: String }) head_copy_expand = ''
29
- @property({ type: String }) head_copy_collapse = ''
30
- @property({ type: Boolean }) expand = true
31
- @property() toggleExpand = () => {}
32
- @property() onSubscriptionClick = () => {}
33
- @property({ type: Object }) packageData: PackageData = {} as PackageData
34
- @property({ type: Object }) jsonPackageData: JsonPackageData =
35
- {} as JsonPackageData
36
16
 
37
17
  /**
38
- * Getter
18
+ * property headData to handle data copy text and cta button
19
+ * property expand to handle what copy text is used
20
+ * property onButtonClick to handle cta when button is clicked and set specific card url
21
+ * property toggleExpand to handle expand and collpase button
39
22
  */
23
+ @property() toggleExpand = () => {}
24
+ @property({ type: Boolean }) expand = true
25
+ @property() onButtonClick = (url: string) => url
26
+ @property({ type: Object }) headData: HeadDataFreeWall = {
27
+ headCopyExpand: 'Expand Default.',
28
+ headCopyCollapse: 'Collapse Default.',
29
+ cta: {
30
+ text: 'Langganan',
31
+ url: '#',
32
+ },
33
+ }
40
34
 
35
+ // Getter
41
36
  get headCopy() {
42
- return (
43
- (this.expand ? this.head_copy_expand : this.head_copy_collapse) ||
44
- 'Akses seluruh konten dan fitur Kompas.id dengan berlangganan.'
45
- )
37
+ return this.expand
38
+ ? this.headData.headCopyExpand
39
+ : this.headData.headCopyCollapse
46
40
  }
47
41
 
48
42
  /**
@@ -63,17 +57,15 @@ export class KompasFreewallHead extends LitElement {
63
57
  return html`
64
58
  <div class="flex flex-col px-4 md:px-0 space-y-4 pt-4 pb-5 md:py-2">
65
59
  <div class="flex justify-between items-center h-full">
66
- <div
67
- class="hidden ${this.expand ? 'md:block' : 'lg:block'} w-9 h-9"
68
- ></div>
60
+ <div class="hidden sm:block w-9 h-9"></div>
69
61
  <div class="flex items-center md:justify-start">
70
- <p class="w-full text-grey-600">${this.headCopy}</p>
71
- ${!this.expand
62
+ <p class="w-full text-grey-600 font-bold">${this.headCopy}</p>
63
+ ${!this.expand && this.headData.cta.url
72
64
  ? html`<button
73
- @click=${this.onSubscriptionClick}
74
- class="bg-green-500 hidden md:block ml-3 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
65
+ @click=${() => this.onButtonClick(this.headData.cta.url)}
66
+ class="bg-brand-1 hidden md:block ml-3 whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
75
67
  >
76
- ${this.jsonPackageData.subscriptionButtonText}
68
+ ${this.headData.cta.text}
77
69
  </button>`
78
70
  : nothing}
79
71
  </div>
@@ -83,18 +75,18 @@ export class KompasFreewallHead extends LitElement {
83
75
  aria-label="Toggle Expand"
84
76
  class="h-9 w-9 flex ml-2 items-center justify-center text-blue-500 rounded bg-blue-200"
85
77
  >
86
- <div class="${!this.expand && 'rotate-180'}">
78
+ <div class="transition-all ${!this.expand && 'rotate-180'}">
87
79
  ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}
88
80
  </div>
89
81
  </button>
90
82
  </div>
91
83
  </div>
92
- ${!this.expand
84
+ ${!this.expand && this.headData.cta.url && this.headData.cta.text
93
85
  ? html`<button
94
- @click=${this.onSubscriptionClick}
95
- class="bg-green-500 block md:hidden whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
86
+ @click=${() => this.onButtonClick(this.headData.cta.url)}
87
+ class="bg-brand-1 block md:hidden whitespace-nowrap rounded md:rounded h-10 px-4 md:px-5 text-sm md:text-base text-white font-bold leading-[18px]"
96
88
  >
97
- ${this.jsonPackageData.subscriptionButtonText}
89
+ ${this.headData.cta.text}
98
90
  </button>`
99
91
  : nothing}
100
92
  </div>