@kompasid/lit-web-components 0.9.14 → 0.9.16
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/dist/src/components/kompasid-freewall/KompasFreewall.js +1 -1
- package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.d.ts +1 -0
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +131 -28
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
- package/dist/tailwind/tailwind.js +5 -0
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-freewall/KompasFreewall.ts +1 -1
- package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +159 -41
- package/tailwind/tailwind.ts +5 -0
|
@@ -50,6 +50,7 @@ interface dataType {
|
|
|
50
50
|
interface DataSideBarLink {
|
|
51
51
|
feature: dataType[]
|
|
52
52
|
category: dataType[]
|
|
53
|
+
lainnya: dataType[]
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
@customElement('kompasid-menu-side-bar')
|
|
@@ -113,6 +114,7 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
113
114
|
this.handleFetchError(error)
|
|
114
115
|
}
|
|
115
116
|
}
|
|
117
|
+
|
|
116
118
|
handleFetchError(error: unknown) {
|
|
117
119
|
const errorMessage =
|
|
118
120
|
error instanceof Error ? error.message : 'Kesalahan tidak diketahui'
|
|
@@ -122,10 +124,12 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
122
124
|
dataSidebar: DataSideBarLink = {
|
|
123
125
|
feature: [],
|
|
124
126
|
category: [],
|
|
127
|
+
lainnya: [],
|
|
125
128
|
}
|
|
129
|
+
|
|
126
130
|
async fetchExternal() {
|
|
127
131
|
// External
|
|
128
|
-
const endpointExternal = `https://cdn-www.kompas.id/assets/json/
|
|
132
|
+
const endpointExternal = `https://cdn-dev-www.kompas.id/assets/json/ApiMenuExternalLinkV2.json`
|
|
129
133
|
const response = await fetch(endpointExternal, {
|
|
130
134
|
headers: {
|
|
131
135
|
'Content-Type': 'application/json',
|
|
@@ -152,8 +156,9 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
152
156
|
})
|
|
153
157
|
)
|
|
154
158
|
}
|
|
159
|
+
|
|
155
160
|
// Sidebar
|
|
156
|
-
const endpointSidebar = `https://cdn-www.kompas.id/assets/json/
|
|
161
|
+
const endpointSidebar = `https://cdn-dev-www.kompas.id/assets/json/ApiMenuSideV3.json`
|
|
157
162
|
const responseSidebar = await fetch(endpointSidebar, {
|
|
158
163
|
headers: {
|
|
159
164
|
'Content-Type': 'application/json',
|
|
@@ -168,7 +173,11 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
168
173
|
|
|
169
174
|
// Convert object to an array
|
|
170
175
|
const sidebarArray = Object.values(resultSidebar)
|
|
171
|
-
const [featureArray, categoryArray] = sidebarArray as [
|
|
176
|
+
const [featureArray, categoryArray, othersArray] = sidebarArray as [
|
|
177
|
+
any[],
|
|
178
|
+
any[],
|
|
179
|
+
any[]
|
|
180
|
+
]
|
|
172
181
|
const features: dataType[] =
|
|
173
182
|
featureArray?.map((item: any) => ({
|
|
174
183
|
href: item?.href ?? '',
|
|
@@ -233,7 +242,45 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
233
242
|
}))
|
|
234
243
|
: [],
|
|
235
244
|
})) ?? []
|
|
236
|
-
|
|
245
|
+
|
|
246
|
+
// Map others data
|
|
247
|
+
const others: dataType[] =
|
|
248
|
+
othersArray?.map((item: any) => ({
|
|
249
|
+
href: item?.href ?? '',
|
|
250
|
+
external: item?.external ?? false,
|
|
251
|
+
icon: item?.icon ?? null,
|
|
252
|
+
iconify: item?.iconify ?? null,
|
|
253
|
+
name: item?.name ?? '',
|
|
254
|
+
slug: item?.slug ?? '',
|
|
255
|
+
redDot: [
|
|
256
|
+
{
|
|
257
|
+
start: item?.redDot?.start ?? '',
|
|
258
|
+
end: item?.redDot?.end ?? '',
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
children: Array.isArray(item?.children)
|
|
262
|
+
? item.children.map((child: any) => ({
|
|
263
|
+
href: child?.href ?? '',
|
|
264
|
+
external: child?.external ?? false,
|
|
265
|
+
icon: child?.icon ?? '',
|
|
266
|
+
iconify: child?.iconify ?? '',
|
|
267
|
+
name: child?.name ?? '',
|
|
268
|
+
slug: child?.slug ?? '',
|
|
269
|
+
redDot: [
|
|
270
|
+
{
|
|
271
|
+
start: child?.redDot?.start ?? '',
|
|
272
|
+
end: child?.redDot?.end ?? '',
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
}))
|
|
276
|
+
: [],
|
|
277
|
+
})) ?? []
|
|
278
|
+
|
|
279
|
+
this.dataSidebar = {
|
|
280
|
+
feature: features,
|
|
281
|
+
category: categories,
|
|
282
|
+
lainnya: others,
|
|
283
|
+
}
|
|
237
284
|
this.requestUpdate()
|
|
238
285
|
}
|
|
239
286
|
|
|
@@ -341,10 +388,10 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
341
388
|
/>
|
|
342
389
|
</a>
|
|
343
390
|
<span
|
|
344
|
-
class="
|
|
391
|
+
class="font-bold cursor-pointer text-grey-400 flex h-10 items-center justify-center rounded text-base w-10 py-4"
|
|
345
392
|
@click=${this.toggleNavSidebar}
|
|
346
393
|
>
|
|
347
|
-
${unsafeSVG(getFontAwesomeIcon('fa', 'times',
|
|
394
|
+
${unsafeSVG(getFontAwesomeIcon('fa', 'times', 20, 20))}
|
|
348
395
|
</span>
|
|
349
396
|
</div>
|
|
350
397
|
<div class="flex flex-wrap px-4 w-full">
|
|
@@ -394,23 +441,7 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
394
441
|
>
|
|
395
442
|
<div class="flex items-center space-x-3">
|
|
396
443
|
<span
|
|
397
|
-
class="text-
|
|
398
|
-
${item.icon === null ? 'w-8' : 'max-w-max w-8'}"
|
|
399
|
-
>
|
|
400
|
-
${item.icon &&
|
|
401
|
-
Array.isArray(item.icon) &&
|
|
402
|
-
item.icon.length >= 2
|
|
403
|
-
? unsafeSVG(
|
|
404
|
-
getFontAwesomeIcon(
|
|
405
|
-
item.icon[0],
|
|
406
|
-
item.icon[1],
|
|
407
|
-
20,
|
|
408
|
-
20
|
|
409
|
-
)
|
|
410
|
-
)
|
|
411
|
-
: ''}
|
|
412
|
-
</span>
|
|
413
|
-
<span class="font-bold relative text-[#333] w-full"
|
|
444
|
+
class="text-sm font-bold relative text-[#333] w-full"
|
|
414
445
|
>${decodeSpecialChars(item.name)}</span
|
|
415
446
|
>
|
|
416
447
|
${timedContent(
|
|
@@ -495,34 +526,21 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
495
526
|
<!-- category -->
|
|
496
527
|
<div class="flex">
|
|
497
528
|
<div class="w-full flex justify-between flex-col">
|
|
529
|
+
<span class="text-sm text-grey-400 px-6 font-normal"
|
|
530
|
+
>Redaksional</span
|
|
531
|
+
>
|
|
498
532
|
${this.dataSidebar.category.map(
|
|
499
533
|
item => html`
|
|
500
534
|
<div class="w-full font-sans">
|
|
501
535
|
<!-- Parent item -->
|
|
502
536
|
<div
|
|
503
|
-
class="flex items-center justify-between text-sm font-medium px-
|
|
537
|
+
class="flex items-center justify-between text-sm font-medium px-6 transition-all cursor-pointer"
|
|
504
538
|
@click=${(e: Event) => this.rubricClicked(item, e)}
|
|
505
539
|
>
|
|
506
540
|
<div
|
|
507
541
|
class="w-[216px] hover:bg-[#f3f4f6] rounded h-12 flex items-center"
|
|
508
542
|
>
|
|
509
543
|
<div class="flex items-center space-x-3">
|
|
510
|
-
<span
|
|
511
|
-
class="text-xl text-brand-1 max-w-max w-8 h-8 flex items-center"
|
|
512
|
-
>
|
|
513
|
-
${item.icon &&
|
|
514
|
-
Array.isArray(item.icon) &&
|
|
515
|
-
item.icon.length >= 2
|
|
516
|
-
? unsafeSVG(
|
|
517
|
-
getFontAwesomeIcon(
|
|
518
|
-
item.icon[0],
|
|
519
|
-
item.icon[1],
|
|
520
|
-
20,
|
|
521
|
-
20
|
|
522
|
-
)
|
|
523
|
-
)
|
|
524
|
-
: ''}
|
|
525
|
-
</span>
|
|
526
544
|
<span
|
|
527
545
|
class="font-bold ${item.name === 'Beranda'
|
|
528
546
|
? 'text-[#00559a]'
|
|
@@ -545,7 +563,107 @@ export class KompasMenuSideBar extends LitElement {
|
|
|
545
563
|
${this.hasChildren(item)
|
|
546
564
|
? html`
|
|
547
565
|
<span
|
|
548
|
-
class="
|
|
566
|
+
class="flex justify-center items-center rounded my-1 py-4 w-10 h-10 cursor-pointer font-bold"
|
|
567
|
+
@click=${(e: Event) => {
|
|
568
|
+
e.stopPropagation() // Prevents click from bubbling to parent
|
|
569
|
+
this.toggleChildren(item)
|
|
570
|
+
}}
|
|
571
|
+
>
|
|
572
|
+
${this.expandedSlug === item.slug
|
|
573
|
+
? unsafeSVG(
|
|
574
|
+
getFontAwesomeIcon(
|
|
575
|
+
'fas',
|
|
576
|
+
'chevron-up',
|
|
577
|
+
12,
|
|
578
|
+
12
|
|
579
|
+
)
|
|
580
|
+
)
|
|
581
|
+
: unsafeSVG(
|
|
582
|
+
getFontAwesomeIcon(
|
|
583
|
+
'fas',
|
|
584
|
+
'chevron-down',
|
|
585
|
+
12,
|
|
586
|
+
12
|
|
587
|
+
)
|
|
588
|
+
)}
|
|
589
|
+
</span>
|
|
590
|
+
`
|
|
591
|
+
: null}
|
|
592
|
+
</div>
|
|
593
|
+
|
|
594
|
+
<!-- Children items -->
|
|
595
|
+
${this.hasChildren(item) && this.expandedSlug === item.slug
|
|
596
|
+
? html`
|
|
597
|
+
<div class="pt-1 pb-2 space-y-1">
|
|
598
|
+
${item.children.map(
|
|
599
|
+
child => html`
|
|
600
|
+
<div
|
|
601
|
+
class="flex items-center text-sm text-[#333] px-4 cursor-pointer transition-all"
|
|
602
|
+
@click=${() => this.rubricClicked(child)}
|
|
603
|
+
>
|
|
604
|
+
<div
|
|
605
|
+
class="w-[216px] hover:bg-[#f3f4f6] rounded h-12 flex items-center pl-11"
|
|
606
|
+
>
|
|
607
|
+
${decodeSpecialChars(child.name)}
|
|
608
|
+
${timedContent(
|
|
609
|
+
child.redDot[0].start,
|
|
610
|
+
child.redDot[0].end
|
|
611
|
+
)
|
|
612
|
+
? html`<span
|
|
613
|
+
class="bg-orange-400 h-2 relative rounded-full w-2 flex shrink-0 -top-[12px]"
|
|
614
|
+
></span>`
|
|
615
|
+
: ''}
|
|
616
|
+
</div>
|
|
617
|
+
</div>
|
|
618
|
+
`
|
|
619
|
+
)}
|
|
620
|
+
</div>
|
|
621
|
+
`
|
|
622
|
+
: ''}
|
|
623
|
+
</div>
|
|
624
|
+
`
|
|
625
|
+
)}
|
|
626
|
+
</div>
|
|
627
|
+
</div>
|
|
628
|
+
|
|
629
|
+
<div class="border-b border-[#DDD] m-6 "></div>
|
|
630
|
+
<!-- Lainnya -->
|
|
631
|
+
<div class="flex">
|
|
632
|
+
<div class="w-full flex justify-between flex-col">
|
|
633
|
+
<span class="text-sm text-grey-400 px-6 font-normal"
|
|
634
|
+
>Lainnya</span
|
|
635
|
+
>
|
|
636
|
+
${this.dataSidebar.lainnya.map(
|
|
637
|
+
item => html`
|
|
638
|
+
<div class="w-full font-sans">
|
|
639
|
+
<!-- Parent item -->
|
|
640
|
+
<div
|
|
641
|
+
class="flex items-center justify-between text-sm font-medium px-6 transition-all cursor-pointer"
|
|
642
|
+
@click=${(e: Event) => this.rubricClicked(item, e)}
|
|
643
|
+
>
|
|
644
|
+
<div
|
|
645
|
+
class="w-[216px] hover:bg-[#f3f4f6] rounded h-12 flex items-center"
|
|
646
|
+
>
|
|
647
|
+
<div class="flex items-center space-x-3">
|
|
648
|
+
<span class="font-bold"
|
|
649
|
+
>${decodeSpecialChars(item.name)}</span
|
|
650
|
+
>
|
|
651
|
+
${timedContent(
|
|
652
|
+
item.redDot[0].start,
|
|
653
|
+
item.redDot[0].end
|
|
654
|
+
)
|
|
655
|
+
? html`<span
|
|
656
|
+
class="bg-orange-400 h-2 relative rounded-full w-2 flex shrink-0 -top-[12px]"
|
|
657
|
+
></span>`
|
|
658
|
+
: ''}
|
|
659
|
+
</div>
|
|
660
|
+
</div>
|
|
661
|
+
|
|
662
|
+
<!-- Toggle chevron -->
|
|
663
|
+
${this.hasChildren(item)
|
|
664
|
+
? html`
|
|
665
|
+
<span
|
|
666
|
+
class="flex justify-center items-center rounded my-1 py-4 w-10 h-10 cursor-pointer font-bold"
|
|
549
667
|
@click=${(e: Event) => {
|
|
550
668
|
e.stopPropagation() // Prevents click from bubbling to parent
|
|
551
669
|
this.toggleChildren(item)
|
package/tailwind/tailwind.ts
CHANGED
|
@@ -1646,6 +1646,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
|
|
|
1646
1646
|
padding-right: 1.25rem;
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
|
+
.px-6 {
|
|
1650
|
+
padding-left: 1.5rem;
|
|
1651
|
+
padding-right: 1.5rem;
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1649
1654
|
.px-8 {
|
|
1650
1655
|
padding-left: 2rem;
|
|
1651
1656
|
padding-right: 2rem;
|