@kompasid/lit-web-components 0.7.1 → 0.7.3

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 (24) hide show
  1. package/demo/index.html +7 -10
  2. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.d.ts +29 -0
  3. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +146 -0
  4. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -0
  5. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.d.ts +5 -7
  6. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +26 -38
  7. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -1
  8. package/dist/src/components/kompasid-widget-recirculations-default/types.d.ts +0 -4
  9. package/dist/src/components/kompasid-widget-recirculations-default/types.js.map +1 -1
  10. package/dist/src/index.d.ts +1 -0
  11. package/dist/src/index.js +1 -0
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/tailwind/tailwind.js +29 -21
  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 +133 -0
  18. package/src/components/kompasid-grace-period/readme.md +17 -0
  19. package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +22 -36
  20. package/src/components/kompasid-widget-recirculations-default/readme.md +6 -11
  21. package/src/components/kompasid-widget-recirculations-default/types.ts +0 -5
  22. package/src/index.ts +1 -0
  23. package/tailwind/tailwind.css +29 -21
  24. package/tailwind/tailwind.ts +29 -21
@@ -0,0 +1,17 @@
1
+ # kompasid-grace-period
2
+
3
+ Ini adalah redesign komponen _grace period_ yang digunakan pada [kompas.id](https://kompas.id).
4
+
5
+ ## Properties
6
+
7
+ | Property | Attribute | Description | Type | Default |
8
+ | ------------------------------ | ------------------------------ | ----------- | ------------------------------------------- | ----------- |
9
+ | `totalGracePeriod` | `total-grace-period` | how many days are left in grace period | `number` | `0` |
10
+ | `isColumn` | `is-column` | changes how the component looks on different screen sizes | `boolean` | `false` |
11
+ | `isShowButton` | `is-show-button` | shows or hides a subscription button | `boolean` | `false` |
12
+ | `subscriptionId` | `subscription-id` | used for renewal subs | `string` | `false` |
13
+
14
+
15
+ ----------------------------------------------
16
+
17
+ *Terbikin oleh tim front-end kompas.id*
@@ -3,7 +3,7 @@ import { customElement, property } from 'lit/decorators.js'
3
3
  import { format } from 'date-fns'
4
4
  import { id } from 'date-fns/locale/id'
5
5
  import { TWStyles } from '../../../tailwind/tailwind.js'
6
- import { Post, Navigation } from './types.js'
6
+ import { Post } from './types.js'
7
7
 
8
8
  @customElement('kompasid-widget-recirculations-default')
9
9
  export class KompasWidgetRecirculationsDefault extends LitElement {
@@ -33,7 +33,6 @@ export class KompasWidgetRecirculationsDefault extends LitElement {
33
33
  * Props
34
34
  */
35
35
  @property({ type: Array }) posts: Post[][] = []
36
- @property({ type: Object }) navigation: Navigation | undefined = undefined
37
36
  @property({ type: String }) accessToken = ''
38
37
  @property({ type: String }) permalinkArticle = ''
39
38
  @property({ type: String }) userGuid = '0'
@@ -41,13 +40,8 @@ export class KompasWidgetRecirculationsDefault extends LitElement {
41
40
  @property({ type: String }) type: 'relatedArticle' | 'otherArticle' =
42
41
  'relatedArticle'
43
42
  @property({ type: String }) mainCategory = ''
44
-
45
- /**
46
- * Getters
47
- */
48
- get navigationPermalink(): string | undefined {
49
- return this.navigation?.permalink
50
- }
43
+ @property({ type: String }) titleName = '' // contoh: Artikel Terkait / Lainnya dalam 'kategori'
44
+ @property({ type: String }) titleLink = '' // contoh: /kategori/opini
51
45
 
52
46
  /**
53
47
  * Fetch Data
@@ -174,41 +168,31 @@ export class KompasWidgetRecirculationsDefault extends LitElement {
174
168
  * Render widget components
175
169
  */
176
170
 
177
- private WidgetTitle() {
178
- if (this.navigationPermalink) {
179
- return html`
180
- <a
181
- href="${this.navigationPermalink}"
182
- class="flex font-sans uppercase items-start mb-6 mt-8"
183
- >
184
- <h5
185
- class="${[
186
- 'capitalize font-bold font-sans',
187
- this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
188
- ].join(' ')}"
189
- >
190
- ${this.navigation?.name}
191
- </h5>
192
- </a>
193
- `
194
- }
195
-
171
+ private titleRelatedArticle() {
196
172
  return html`
197
173
  <div class="flex font-sans uppercase items-start mb-6 mt-8">
198
174
  <div>
199
- <h5
200
- class="${[
201
- 'capitalize font-bold font-sans',
202
- this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
203
- ].join(' ')}"
204
- >
205
- ${this.navigation?.name}
175
+ <h5 class="capitalize font-bold font-sans text-grey-600">
176
+ Artikel Terkait
206
177
  </h5>
207
178
  </div>
208
179
  </div>
209
180
  `
210
181
  }
211
182
 
183
+ private titleOtherArticle() {
184
+ return html`
185
+ <a
186
+ href="${this.titleLink}"
187
+ class="flex font-sans uppercase items-start mb-6 mt-8"
188
+ >
189
+ <h5 class="capitalize font-bold font-sans text-brand-1">
190
+ ${this.titleName}
191
+ </h5>
192
+ </a>
193
+ `
194
+ }
195
+
212
196
  renderChips(post: Post) {
213
197
  const chips = []
214
198
  const isAnalisis = post.postTag?.some(tag => tag.slug === 'analisis')
@@ -271,7 +255,9 @@ export class KompasWidgetRecirculationsDefault extends LitElement {
271
255
  return html`
272
256
  <div class="w-full">
273
257
  <!-- start: widget title -->
274
- ${this.WidgetTitle()}
258
+ ${this.type === 'relatedArticle'
259
+ ? this.titleRelatedArticle()
260
+ : this.titleOtherArticle()}
275
261
  <!-- end: widget title -->
276
262
 
277
263
  <div class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
@@ -6,30 +6,24 @@ Komponen ini adalah komponen web berbasis LitElement yang digunakan untuk menamp
6
6
 
7
7
  ```javascript
8
8
  const widgetRelatedPost = {
9
- navigation: {
10
- name: 'Artikel Terkait',
11
- permalink: undefined
12
- },
13
9
  permalinkArticle: 'https://www.kompas.id/baca/opini/2024/05/02/pesan-bung-karno-jaga-persatuan-dan-keutuhan?open_from=Section_Artikel_Lainnya',
14
10
  slugs: 'persatuan,bung-karno, surat pembaca, eduard lukman, bharoto, wira hardiprakoso, vision'
15
11
  }
16
12
 
17
13
  const widgetOtherPost = {
18
- navigation: {
19
- name: 'Lainnya Dalam Opini',
20
- permalink: '/kategori/opini'
21
- }
14
+ titleName: 'Lainnya Dalam Opini',
15
+ titleLink: '/kategori/opini'
22
16
  }
23
17
 
24
18
  <div>
25
19
  <kompasid-widget-recirculations-default
26
- .navigation=${widgetRelatedPost.navigation}
27
20
  .permalinkArticle=${widgetRelatedPost.permalinkArticle}
28
21
  .slugs=${widgetRelatedPost.slugs}
29
22
  ></kompasid-widget-recirculations-default>
30
23
 
31
24
  <kompasid-widget-recirculations-default
32
- .navigation=${widgetOtherPost.navigation}
25
+ .titleName=${widgetOtherPost.titleName}
26
+ .titleLink=${widgetOtherPost.titleLink}
33
27
  type='otherArticle'
34
28
  mainCategory='opini'
35
29
  ></kompasid-widget-recirculations-default>
@@ -40,7 +34,8 @@ const widgetOtherPost = {
40
34
 
41
35
  | Property | Attribute | Deskripsi | Tipe | Default | Konten |
42
36
  | ------------------ | --------------- | -------------------------------------------------------------------------------------------------- | -------- | --------------- | ------------------------------------------- |
43
- | `navigation` | `navigation` | Navigasi yang berisi nama dan tautan ke kategori atau halaman terkait. Mengecek value `name` dan `permalink` | `Object` | `undefined` | `Navigation` |
37
+ | `titleName` | `titleName` | Nama judul yang akan ditampilkan di widget. (Digunakan jika memakai props type=otherArticle) | `String` | `''` |
38
+ | `titleLink` | `titleLink` | Tautan yang akan ditetapkan pada judul di widget. (Digunakan jika memakai props type=otherArticle) | `String` | `''` |
44
39
  | `userGuid` | `userGuid` | GUID pengguna yang sedang menggunakan aplikasi untuk fetch data artikel terkait. | `String` | `'0'` | |
45
40
  | `slugs` | `slugs` | Daftar slug kategori atau tag yang terkait dengan artikel untuk artikel terkait. | `String` | `''` | |
46
41
  | `permalinkArticle` | `permalinkArticle` | Tautan kategori artikel yang sedang ditampilkan atau dibaca untuk rekomendasi artikel terkait. | `String` | `''` | |
@@ -21,8 +21,3 @@ export interface Post {
21
21
  }
22
22
  }
23
23
  }
24
-
25
- export interface Navigation {
26
- name: string
27
- permalink: string
28
- }
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@ export { KompasMeteredPaywall } from './components/kompasid-metered-paywall/Komp
7
7
  export { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js'
8
8
  export { KompasMeteredWallRegister } from './components/kompasid-metered-wall-register/KompasMeteredWallRegister.js'
9
9
  export { KompasHeaderAccount } from './components/kompasid-header-account/KompasHeaderAccount.js'
10
+ export { KompasGracePeriod } from './components/kompasid-grace-period/KompasGracePeriod.js'
10
11
 
11
12
  declare global {
12
13
  interface Window {
@@ -974,14 +974,6 @@ video {
974
974
  width: 100%;
975
975
  }
976
976
 
977
- .w-\[165px\] {
978
- width: 165px;
979
- }
980
-
981
- .min-w-\[165px\] {
982
- min-width: 165px;
983
- }
984
-
985
977
  .max-w-7xl {
986
978
  max-width: 80rem;
987
979
  }
@@ -1002,10 +994,6 @@ video {
1002
994
  max-width: 20rem;
1003
995
  }
1004
996
 
1005
- .max-w-\[165px\] {
1006
- max-width: 165px;
1007
- }
1008
-
1009
997
  .flex-none {
1010
998
  flex: none;
1011
999
  }
@@ -1470,6 +1458,11 @@ video {
1470
1458
  padding-right: 1rem;
1471
1459
  }
1472
1460
 
1461
+ .px-5 {
1462
+ padding-left: 1.25rem;
1463
+ padding-right: 1.25rem;
1464
+ }
1465
+
1473
1466
  .px-8 {
1474
1467
  padding-left: 2rem;
1475
1468
  padding-right: 2rem;
@@ -1520,11 +1513,6 @@ video {
1520
1513
  padding-bottom: 5.6px;
1521
1514
  }
1522
1515
 
1523
- .px-5 {
1524
- padding-left: 1.25rem;
1525
- padding-right: 1.25rem;
1526
- }
1527
-
1528
1516
  .pb-1 {
1529
1517
  padding-bottom: 0.25rem;
1530
1518
  }
@@ -2004,6 +1992,10 @@ video {
2004
1992
  width: 13rem;
2005
1993
  }
2006
1994
 
1995
+ .md\:w-\[165px\] {
1996
+ width: 165px;
1997
+ }
1998
+
2007
1999
  .md\:w-\[350px\] {
2008
2000
  width: 350px;
2009
2001
  }
@@ -2032,10 +2024,6 @@ video {
2032
2024
  width: auto;
2033
2025
  }
2034
2026
 
2035
- .md\:w-\[165px\] {
2036
- width: 165px;
2037
- }
2038
-
2039
2027
  .md\:max-w-\[137px\] {
2040
2028
  max-width: 137px;
2041
2029
  }
@@ -2100,6 +2088,12 @@ video {
2100
2088
  margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
2101
2089
  }
2102
2090
 
2091
+ .md\:space-x-4 > :not([hidden]) ~ :not([hidden]) {
2092
+ --tw-space-x-reverse: 0;
2093
+ margin-right: calc(1rem * var(--tw-space-x-reverse));
2094
+ margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
2095
+ }
2096
+
2103
2097
  .md\:space-x-5 > :not([hidden]) ~ :not([hidden]) {
2104
2098
  --tw-space-x-reverse: 0;
2105
2099
  margin-right: calc(1.25rem * var(--tw-space-x-reverse));
@@ -2200,6 +2194,10 @@ video {
2200
2194
  padding-bottom: 1.75rem;
2201
2195
  }
2202
2196
 
2197
+ .md\:pt-0 {
2198
+ padding-top: 0px;
2199
+ }
2200
+
2203
2201
  .md\:pt-3 {
2204
2202
  padding-top: 0.75rem;
2205
2203
  }
@@ -2363,6 +2361,11 @@ video {
2363
2361
  padding-right: 0px;
2364
2362
  }
2365
2363
 
2364
+ .lg\:px-20 {
2365
+ padding-left: 5rem;
2366
+ padding-right: 5rem;
2367
+ }
2368
+
2366
2369
  .lg\:px-24 {
2367
2370
  padding-left: 6rem;
2368
2371
  padding-right: 6rem;
@@ -2373,6 +2376,11 @@ video {
2373
2376
  padding-bottom: 2.5rem;
2374
2377
  }
2375
2378
 
2379
+ .lg\:px-8 {
2380
+ padding-left: 2rem;
2381
+ padding-right: 2rem;
2382
+ }
2383
+
2376
2384
  .lg\:pb-0 {
2377
2385
  padding-bottom: 0px;
2378
2386
  }
@@ -984,14 +984,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
984
984
  width: 100%;
985
985
  }
986
986
 
987
- .w-\\[165px\\] {
988
- width: 165px;
989
- }
990
-
991
- .min-w-\\[165px\\] {
992
- min-width: 165px;
993
- }
994
-
995
987
  .max-w-7xl {
996
988
  max-width: 80rem;
997
989
  }
@@ -1012,10 +1004,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1012
1004
  max-width: 20rem;
1013
1005
  }
1014
1006
 
1015
- .max-w-\\[165px\\] {
1016
- max-width: 165px;
1017
- }
1018
-
1019
1007
  .flex-none {
1020
1008
  flex: none;
1021
1009
  }
@@ -1484,6 +1472,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1484
1472
  padding-right: 1rem;
1485
1473
  }
1486
1474
 
1475
+ .px-5 {
1476
+ padding-left: 1.25rem;
1477
+ padding-right: 1.25rem;
1478
+ }
1479
+
1487
1480
  .px-8 {
1488
1481
  padding-left: 2rem;
1489
1482
  padding-right: 2rem;
@@ -1534,11 +1527,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1534
1527
  padding-bottom: 5.6px;
1535
1528
  }
1536
1529
 
1537
- .px-5 {
1538
- padding-left: 1.25rem;
1539
- padding-right: 1.25rem;
1540
- }
1541
-
1542
1530
  .pb-1 {
1543
1531
  padding-bottom: 0.25rem;
1544
1532
  }
@@ -2031,6 +2019,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2031
2019
  width: 13rem;
2032
2020
  }
2033
2021
 
2022
+ .md\\:w-\\[165px\\] {
2023
+ width: 165px;
2024
+ }
2025
+
2034
2026
  .md\\:w-\\[350px\\] {
2035
2027
  width: 350px;
2036
2028
  }
@@ -2059,10 +2051,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2059
2051
  width: auto;
2060
2052
  }
2061
2053
 
2062
- .md\\:w-\\[165px\\] {
2063
- width: 165px;
2064
- }
2065
-
2066
2054
  .md\\:max-w-\\[137px\\] {
2067
2055
  max-width: 137px;
2068
2056
  }
@@ -2127,6 +2115,12 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2127
2115
  margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
2128
2116
  }
2129
2117
 
2118
+ .md\\:space-x-4 > :not([hidden]) ~ :not([hidden]) {
2119
+ --tw-space-x-reverse: 0;
2120
+ margin-right: calc(1rem * var(--tw-space-x-reverse));
2121
+ margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
2122
+ }
2123
+
2130
2124
  .md\\:space-x-5 > :not([hidden]) ~ :not([hidden]) {
2131
2125
  --tw-space-x-reverse: 0;
2132
2126
  margin-right: calc(1.25rem * var(--tw-space-x-reverse));
@@ -2227,6 +2221,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2227
2221
  padding-bottom: 1.75rem;
2228
2222
  }
2229
2223
 
2224
+ .md\\:pt-0 {
2225
+ padding-top: 0px;
2226
+ }
2227
+
2230
2228
  .md\\:pt-3 {
2231
2229
  padding-top: 0.75rem;
2232
2230
  }
@@ -2390,6 +2388,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2390
2388
  padding-right: 0px;
2391
2389
  }
2392
2390
 
2391
+ .lg\\:px-20 {
2392
+ padding-left: 5rem;
2393
+ padding-right: 5rem;
2394
+ }
2395
+
2393
2396
  .lg\\:px-24 {
2394
2397
  padding-left: 6rem;
2395
2398
  padding-right: 6rem;
@@ -2400,6 +2403,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2400
2403
  padding-bottom: 2.5rem;
2401
2404
  }
2402
2405
 
2406
+ .lg\\:px-8 {
2407
+ padding-left: 2rem;
2408
+ padding-right: 2rem;
2409
+ }
2410
+
2403
2411
  .lg\\:pb-0 {
2404
2412
  padding-bottom: 0px;
2405
2413
  }