@kompasid/lit-web-components 0.7.2 → 0.7.4

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 (21) hide show
  1. package/.github/workflows/npm-publish.yml +2 -2
  2. package/demo/index.html +68 -58
  3. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +34 -9
  4. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -1
  5. package/dist/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js +14 -10
  6. package/dist/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js.map +1 -1
  7. package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js +5 -2
  8. package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js.map +1 -1
  9. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.d.ts +5 -7
  10. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +26 -38
  11. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -1
  12. package/dist/src/components/kompasid-widget-recirculations-default/types.d.ts +0 -4
  13. package/dist/src/components/kompasid-widget-recirculations-default/types.js.map +1 -1
  14. package/dist/tsconfig.tsbuildinfo +1 -1
  15. package/package.json +1 -1
  16. package/src/components/kompasid-header-account/KompasHeaderAccount.ts +34 -9
  17. package/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.ts +14 -10
  18. package/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.ts +5 -2
  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
@@ -63,6 +63,31 @@ export class KompasHeaderAccount extends LitElement {
63
63
  font-family: 'PT Sans', sans-serif;
64
64
  font-size: 0.875rem;
65
65
  }
66
+ .z-index-max {
67
+ z-index: 99999;
68
+ }
69
+
70
+ /* Custom Scrollbar for header */
71
+ /* width */
72
+ ::-webkit-scrollbar {
73
+ width: 4px;
74
+ }
75
+
76
+ /* Track */
77
+ ::-webkit-scrollbar-track {
78
+ background: transparent;
79
+ }
80
+
81
+ /* Handle */
82
+ ::-webkit-scrollbar-thumb {
83
+ background: #0356a8;
84
+ border-radius: 100px;
85
+ }
86
+
87
+ /* Handle on hover */
88
+ ::-webkit-scrollbar-thumb:hover {
89
+ background: #0356a8;
90
+ }
66
91
  `,
67
92
  TWStyles,
68
93
  ]
@@ -113,7 +138,7 @@ export class KompasHeaderAccount extends LitElement {
113
138
  }
114
139
 
115
140
  return html`
116
- <button @click=${this.toggleSidebar} class="cursor-pointer p-3">
141
+ <button @click=${this.toggleSidebar} class="cursor-pointer ">
117
142
  <div class="flex flex-row items-center self-center">
118
143
  ${!this.getInitialUserName()
119
144
  ? html`<div
@@ -143,11 +168,15 @@ export class KompasHeaderAccount extends LitElement {
143
168
 
144
169
  private accountSidebar() {
145
170
  return html`
146
- <nav @keyup="${this.onkeyup}" @click=${this.toggleSidebar}>
171
+ <nav
172
+ class="w-screen fixed right-0 top-0 bottom-0"
173
+ @keyup="${this.onkeyup}"
174
+ @click=${this.toggleSidebar}
175
+ >
147
176
  <div
177
+ class="bg-grey-100 pb-20 pt-0 shadow-lg w-76 z-index-max ml-auto"
178
+ style=${`margin-top: ${this.sidebarTopSpacing}px;height:100vh;overflow-y:auto`}
148
179
  @keyup="${this.onkeyup}"
149
- class="bg-grey-100 pb-20 pt-0 shadow-lg w-76 z-99 ml-auto"
150
- style=${`margin-top: ${this.sidebarTopSpacing}px`}
151
180
  @click=${(ev: any) => ev.stopPropagation()}
152
181
  >
153
182
  <kompasid-header-account-profile
@@ -187,11 +216,7 @@ export class KompasHeaderAccount extends LitElement {
187
216
 
188
217
  render() {
189
218
  return html`
190
- <header class="header flex flex-row justify-end h-[49px] relative z-50">
191
- <div class="text-end">
192
- ${this.account()} ${this.isShowSidebar ? this.accountSidebar() : ''}
193
- </div>
194
- </header>
219
+ ${this.account()} ${this.isShowSidebar ? this.accountSidebar() : ''}
195
220
  `
196
221
  }
197
222
  }
@@ -15,23 +15,27 @@ export class KompasHeaderAccountHelpCenter extends LitElement {
15
15
  display: flex;
16
16
  flex-direction: row;
17
17
  align-items: center;
18
- padding: 0.75rem;
19
- transition: background-color 0.3s ease-in-out;
20
- border-radius: 0.25rem;
18
+ padding: 0 0.75rem;
21
19
  }
22
- .header-account-help-center--item:hover {
23
- background-color: #e5e7eb;
24
- }
25
- .header-help-center--content {
26
- text-align: left;
20
+ .header-account-help-center--content {
21
+ display: flex;
22
+ flex-direction: column;
23
+ flex-grow: 1;
24
+ margin-left: 1rem; /* Equivalent to mx-4 (margin-left: 1rem and margin-right: 1rem) */
25
+ margin-right: 1rem;
26
+ line-height: 1.25rem; /* Equivalent to leading-4 (line-height: 1.25rem) */
27
+ font-size: 1rem; /* Equivalent to text-base (font-size: 1rem) */
28
+ gap: 0.5rem; /* Equivalent to gap-y-2 (gap between rows: 0.5rem) */
27
29
  }
28
30
  .icon {
29
- width: 20px;
30
- height: 20px;
31
31
  margin-top: auto;
32
32
  margin-bottom: auto;
33
33
  color: rgb(0 85 154);
34
34
  }
35
+ .icon svg {
36
+ width: 20px;
37
+ height: 20px;
38
+ }
35
39
  `,
36
40
  TWStyles,
37
41
  ]
@@ -40,12 +40,15 @@ export class KompasHeaderAccountMenu extends LitElement {
40
40
  width: 1.75rem;
41
41
  }
42
42
  .icon {
43
- width: 20px;
44
- height: 20px;
45
43
  margin-top: auto;
46
44
  margin-bottom: auto;
47
45
  color: rgb(0 85 154);
48
46
  }
47
+ .icon svg {
48
+ width: 20px;
49
+ height: 20px;
50
+ }
51
+ .
49
52
  `,
50
53
  TWStyles,
51
54
  ]
@@ -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
- }