@kompasid/lit-web-components 0.6.3 → 0.6.6
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/assets/kompas-free-trial.png +0 -0
- package/assets/qr-code.png +0 -0
- package/demo/index.html +33 -2
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.d.ts +27 -0
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +233 -0
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -0
- package/dist/src/components/kompasid-header-account/types.d.ts +8 -0
- package/dist/src/components/kompasid-header-account/types.js +2 -0
- package/dist/src/components/kompasid-header-account/types.js.map +1 -0
- package/dist/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.d.ts +13 -0
- package/dist/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js +172 -0
- package/dist/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js.map +1 -0
- package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.d.ts +37 -0
- package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js +185 -0
- package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js.map +1 -0
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.d.ts +12 -0
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +172 -0
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -0
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js +8 -8
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js.map +1 -1
- package/dist/src/components/kompasid-paywall/KompasPaywall.js +7 -20
- package/dist/src/components/kompasid-paywall/KompasPaywall.js.map +1 -1
- package/dist/src/components/kompasid-paywall/types.d.ts +5 -0
- package/dist/src/components/kompasid-paywall/types.js.map +1 -1
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.d.ts +4 -0
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js +178 -28
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/utils/text.d.ts +2 -0
- package/dist/src/utils/text.js +9 -0
- package/dist/src/utils/text.js.map +1 -0
- package/dist/tailwind/tailwind.js +391 -5
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-header-account/KompasHeaderAccount.ts +197 -0
- package/src/components/kompasid-header-account/types.ts +8 -0
- package/src/components/kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.ts +177 -0
- package/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.ts +172 -0
- package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +161 -0
- package/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts +8 -8
- package/src/components/kompasid-paywall/KompasPaywall.ts +7 -20
- package/src/components/kompasid-paywall/types.ts +5 -0
- package/src/components/kompasid-paywall-body/KompasPaywallBody.ts +189 -36
- package/src/index.ts +1 -0
- package/src/utils/text.ts +9 -0
- package/tailwind/tailwind.css +382 -5
- package/tailwind/tailwind.ts +391 -5
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit'
|
|
2
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
|
|
4
|
+
import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
|
|
5
|
+
import { User } from './types.js'
|
|
6
|
+
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
7
|
+
import '../kompasid-header-account-profile/KompasHeaderAccountProfile.js'
|
|
8
|
+
import '../kompasid-header-account-help-center/KompasHeaderAccountHelpCenter.js'
|
|
9
|
+
import '../kompasid-header-account-menu/KompasHeaderAccountMenu.js'
|
|
10
|
+
|
|
11
|
+
@customElement('kompasid-header-account')
|
|
12
|
+
export class KompasHeaderAccount extends LitElement {
|
|
13
|
+
static styles = [
|
|
14
|
+
css`
|
|
15
|
+
:host {
|
|
16
|
+
font-family: 'PT Sans', sans-serif;
|
|
17
|
+
}
|
|
18
|
+
.header {
|
|
19
|
+
background-color: #0356a8;
|
|
20
|
+
}
|
|
21
|
+
.account-profile {
|
|
22
|
+
overflow-y: auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.header-account-help-center--item {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
align-items: center;
|
|
29
|
+
padding: 0.75rem;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.header-account-help-center--content {
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
flex-grow: 1;
|
|
36
|
+
margin-left: 1rem;
|
|
37
|
+
line-height: 1.5rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.header-account--membership-icon {
|
|
41
|
+
position: absolute;
|
|
42
|
+
bottom: -2px;
|
|
43
|
+
right: -2px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.header-account--notification-indicator {
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 0;
|
|
49
|
+
height: 0.5rem;
|
|
50
|
+
width: 0.5rem;
|
|
51
|
+
background-color: #f6ad55;
|
|
52
|
+
border-radius: 50%;
|
|
53
|
+
right: -0.563rem;
|
|
54
|
+
top: -0.281rem;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.header-account-sidebar {
|
|
58
|
+
width: 19rem;
|
|
59
|
+
background-color: #edf2f7;
|
|
60
|
+
box-shadow: 0px 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
font-family: 'PT Sans', sans-serif;
|
|
64
|
+
font-size: 0.875rem;
|
|
65
|
+
}
|
|
66
|
+
`,
|
|
67
|
+
TWStyles,
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
@state() isShowSidebar: boolean = false
|
|
71
|
+
|
|
72
|
+
formattedUserData: User = {} as User
|
|
73
|
+
|
|
74
|
+
@property({ type: String }) cartUrl = ''
|
|
75
|
+
@property({ type: String }) logoutUrl = ''
|
|
76
|
+
@property({ type: String }) manageAccountUrl = ''
|
|
77
|
+
@property({ type: Number }) notificationTotal = 0
|
|
78
|
+
@property({ type: String }) notificationUrl = ''
|
|
79
|
+
@property({ type: String }) ordersUrl = ''
|
|
80
|
+
@property({ type: String }) readLaterUrl = ''
|
|
81
|
+
@property({ type: Object }) userData = {}
|
|
82
|
+
@property({ type: Number }) sidebarTopSpacing = 0
|
|
83
|
+
@property({ type: String }) subscriptionUrl = ''
|
|
84
|
+
@property({ type: Number }) totalGracePeriod = 0
|
|
85
|
+
|
|
86
|
+
private toggleSidebar() {
|
|
87
|
+
this.isShowSidebar = !this.isShowSidebar
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private getInitialUserName() {
|
|
91
|
+
return this.formattedUserData?.userName
|
|
92
|
+
? this.formattedUserData.userName.charAt(0)
|
|
93
|
+
: ''
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private account() {
|
|
97
|
+
const notificationIndicator = () => {
|
|
98
|
+
if (!this.notificationTotal) return html``
|
|
99
|
+
return html`<div class="header-account--notification-indicator"></div>`
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const membershipIcon = () => {
|
|
103
|
+
if (!this.formattedUserData?.isMembership) return html``
|
|
104
|
+
return html`
|
|
105
|
+
<div>
|
|
106
|
+
<img
|
|
107
|
+
class="header-account--membership-icon h-2.5 w-2.5"
|
|
108
|
+
src="https://d3w4qaq4xm1ncv.cloudfront.net/global-header/crown-royal-blue-60.svg"
|
|
109
|
+
alt="membership-crown-icon"
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
`
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return html`
|
|
116
|
+
<button @click=${this.toggleSidebar} class="cursor-pointer p-3">
|
|
117
|
+
<div class="flex flex-row items-center self-center">
|
|
118
|
+
${!this.getInitialUserName()
|
|
119
|
+
? html`<div
|
|
120
|
+
class="bg-grey-300 rounded-full h-6 w-6 animate-pulse"
|
|
121
|
+
></div>`
|
|
122
|
+
: html`
|
|
123
|
+
<div
|
|
124
|
+
class="flex bg-grey-100 rounded-full h-6 w-6 items-center justify-center relative"
|
|
125
|
+
>
|
|
126
|
+
<span class="capitalize text-xxs text-blue-600 font-bold"
|
|
127
|
+
>${this.getInitialUserName()}</span
|
|
128
|
+
>
|
|
129
|
+
${notificationIndicator()} ${membershipIcon()}
|
|
130
|
+
</div>
|
|
131
|
+
`}
|
|
132
|
+
<div
|
|
133
|
+
class="ml-3 icon-xs text-white chevron-icon ${this.isShowSidebar
|
|
134
|
+
? 'chevron-down'
|
|
135
|
+
: 'rotate-180'}"
|
|
136
|
+
>
|
|
137
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-up'))}
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
</button>
|
|
141
|
+
`
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private accountSidebar() {
|
|
145
|
+
return html`
|
|
146
|
+
<nav @keyup="${this.onkeyup}" @click=${this.toggleSidebar}>
|
|
147
|
+
<div
|
|
148
|
+
@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
|
+
@click=${(ev: any) => ev.stopPropagation()}
|
|
152
|
+
>
|
|
153
|
+
<kompasid-header-account-profile
|
|
154
|
+
.userInitialName=${this.getInitialUserName()}
|
|
155
|
+
.userData=${this.formattedUserData}
|
|
156
|
+
.subscriptionUrl=${this.subscriptionUrl}
|
|
157
|
+
.totalGracePeriod=${this.totalGracePeriod}
|
|
158
|
+
></kompasid-header-account-profile>
|
|
159
|
+
<div class="pl-4 pr-3 py-4 text-left">
|
|
160
|
+
<kompasid-header-account-menu
|
|
161
|
+
.cart-url=${this.cartUrl}
|
|
162
|
+
.manage-account-url=${this.manageAccountUrl}
|
|
163
|
+
.logout-url=${this.logoutUrl}
|
|
164
|
+
.notification-url=${this.notificationUrl}
|
|
165
|
+
.notification-total=${this.notificationTotal}
|
|
166
|
+
.orders-url=${this.ordersUrl}
|
|
167
|
+
.read-later-url=${this.readLaterUrl}
|
|
168
|
+
></kompasid-header-account-menu>
|
|
169
|
+
<kompasid-header-account-help-center></kompasid-header-account-help-center>
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
</nav>
|
|
173
|
+
`
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
override async connectedCallback() {
|
|
177
|
+
super.connectedCallback()
|
|
178
|
+
this.isShowSidebar = false
|
|
179
|
+
if (typeof this.userData === 'string') {
|
|
180
|
+
this.formattedUserData = JSON.parse(this.userData)
|
|
181
|
+
} else if (typeof this.userData === 'object' && this.userData !== null) {
|
|
182
|
+
// If userData is already an object, you might not need to parse it.
|
|
183
|
+
// You can assign it directly to formattedUserData:
|
|
184
|
+
this.formattedUserData = this.userData as User
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
render() {
|
|
189
|
+
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>
|
|
195
|
+
`
|
|
196
|
+
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit'
|
|
2
|
+
import { customElement, state } from 'lit/decorators.js'
|
|
3
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
|
|
4
|
+
import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
|
|
5
|
+
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
6
|
+
|
|
7
|
+
@customElement('kompasid-header-account-help-center')
|
|
8
|
+
export class KompasHeaderAccountHelpCenter extends LitElement {
|
|
9
|
+
static styles = [
|
|
10
|
+
css`
|
|
11
|
+
:host {
|
|
12
|
+
font-family: 'PT Sans', sans-serif;
|
|
13
|
+
}
|
|
14
|
+
.header-account-help-center--item {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
align-items: center;
|
|
18
|
+
padding: 0.75rem;
|
|
19
|
+
transition: background-color 0.3s ease-in-out;
|
|
20
|
+
border-radius: 0.25rem;
|
|
21
|
+
}
|
|
22
|
+
.header-account-help-center--item:hover {
|
|
23
|
+
background-color: #e5e7eb;
|
|
24
|
+
}
|
|
25
|
+
.header-help-center--content {
|
|
26
|
+
text-align: left;
|
|
27
|
+
}
|
|
28
|
+
.icon {
|
|
29
|
+
width: 20px;
|
|
30
|
+
height: 20px;
|
|
31
|
+
margin-top: auto;
|
|
32
|
+
margin-bottom: auto;
|
|
33
|
+
color: rgb(0 85 154);
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
TWStyles,
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
kompasKring?: HTMLInputElement
|
|
40
|
+
|
|
41
|
+
@state() clipboardClicked: boolean = false
|
|
42
|
+
|
|
43
|
+
// Q & A
|
|
44
|
+
private qna = () =>
|
|
45
|
+
html` <div class="header-account-help-center--item">
|
|
46
|
+
<div class="icon">
|
|
47
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'comments'))}
|
|
48
|
+
</div>
|
|
49
|
+
<div
|
|
50
|
+
class="header-account-help-center--content mx-4 leading-4 gap-y-2 text-base"
|
|
51
|
+
>
|
|
52
|
+
<p>Tanya Jawab</p>
|
|
53
|
+
<a href="http://kb.kompas.id/" class="font-bold hover:underline"
|
|
54
|
+
>http://kb.kompas.id/</a
|
|
55
|
+
>
|
|
56
|
+
</div>
|
|
57
|
+
</div>`
|
|
58
|
+
|
|
59
|
+
// Telephone
|
|
60
|
+
private telephone = () => {
|
|
61
|
+
// Clipboard Action
|
|
62
|
+
const clipboardAction = async () => {
|
|
63
|
+
const phoneNumberCopy =
|
|
64
|
+
this.shadowRoot?.getElementById('kompasKring')?.innerHTML
|
|
65
|
+
if (phoneNumberCopy) {
|
|
66
|
+
try {
|
|
67
|
+
await navigator.clipboard.writeText(phoneNumberCopy)
|
|
68
|
+
this.clipboardClicked = true
|
|
69
|
+
setTimeout(() => {
|
|
70
|
+
this.clipboardClicked = false
|
|
71
|
+
}, 2000)
|
|
72
|
+
} catch (error) {
|
|
73
|
+
// Handle clipboard write error
|
|
74
|
+
console.error('Failed to copy to clipboard:', error)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Keyboard event handler
|
|
80
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
81
|
+
if (event.key === 'Enter') {
|
|
82
|
+
clipboardAction()
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return html`<div class="header-account-help-center--item">
|
|
87
|
+
<div class="icon">${unsafeSVG(getFontAwesomeIcon('fas', 'phone'))}</div>
|
|
88
|
+
<div
|
|
89
|
+
class="relative header-account-help-center--content mx-4 leading-4 gap-y-2 text-base"
|
|
90
|
+
>
|
|
91
|
+
${this.clipboardClicked
|
|
92
|
+
? html`<p
|
|
93
|
+
class="absolute bg-grey-200 rounded-md h-full top-0 w-full flex items-center justify-center"
|
|
94
|
+
>
|
|
95
|
+
Berhasil menyalin!
|
|
96
|
+
</p>`
|
|
97
|
+
: html``}
|
|
98
|
+
<p>Kompas Kring</p>
|
|
99
|
+
<p id="kompasKring" class="font-bold">+6221 2567 6000</p>
|
|
100
|
+
</div>
|
|
101
|
+
<div
|
|
102
|
+
class="bg-grey-200 px-3 py-2 rounded cursor-pointer"
|
|
103
|
+
@click=${clipboardAction}
|
|
104
|
+
@keydown=${handleKeyDown}
|
|
105
|
+
tabindex="0"
|
|
106
|
+
>
|
|
107
|
+
<div class="icon-sm icon-grey-600">
|
|
108
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'copy'))}
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
</div>`
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Whatsapp
|
|
115
|
+
private whatsapp = () =>
|
|
116
|
+
html`<a
|
|
117
|
+
href="https://api.whatsapp.com/send?phone=6281290050800"
|
|
118
|
+
class="header-account-help-center--item"
|
|
119
|
+
>
|
|
120
|
+
<div class="icon">
|
|
121
|
+
${unsafeSVG(getFontAwesomeIcon('fab', 'whatsapp'))}
|
|
122
|
+
</div>
|
|
123
|
+
<div
|
|
124
|
+
class="header-account-help-center--content mx-4 leading-4 gap-y-2 text-base"
|
|
125
|
+
>
|
|
126
|
+
<p>Whatsapp</p>
|
|
127
|
+
<p class="font-bold hover:underline">+62812 900 50 800</p>
|
|
128
|
+
</div>
|
|
129
|
+
</a>`
|
|
130
|
+
|
|
131
|
+
// Email
|
|
132
|
+
private email = () =>
|
|
133
|
+
html`<a
|
|
134
|
+
href="mailto:hotline@kompas.id"
|
|
135
|
+
class="header-account-help-center--item"
|
|
136
|
+
>
|
|
137
|
+
<div class="icon-md text-brand-1">
|
|
138
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'envelope'))}
|
|
139
|
+
</div>
|
|
140
|
+
<div
|
|
141
|
+
class="header-account-help-center--content mx-4 leading-4 gap-y-2 text-base"
|
|
142
|
+
>
|
|
143
|
+
<p>Email</p>
|
|
144
|
+
<p class="font-bold hover:underline">hotline@kompas.id</p>
|
|
145
|
+
</div>
|
|
146
|
+
</a>`
|
|
147
|
+
|
|
148
|
+
// Working Hour
|
|
149
|
+
private workingHour = () =>
|
|
150
|
+
html`<div class="header-account-help-center--item">
|
|
151
|
+
<div class="icon-md text-brand-1">
|
|
152
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'clock'))}
|
|
153
|
+
</div>
|
|
154
|
+
<div class="flex flex-col mx-4 leading-4 gap-y-2 text-base">
|
|
155
|
+
<p>Jam Kerja</p>
|
|
156
|
+
<p class="font-bold">06.00 - 16.00 WIB</p>
|
|
157
|
+
</div>
|
|
158
|
+
</div>`
|
|
159
|
+
|
|
160
|
+
override async connectedCallback() {
|
|
161
|
+
super.connectedCallback()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
render() {
|
|
165
|
+
return html`
|
|
166
|
+
<div
|
|
167
|
+
class="account-help-center-container text-left leading-none mt-4 text-grey-600"
|
|
168
|
+
>
|
|
169
|
+
<p class="text-base mx-1">Pusat Bantuan</p>
|
|
170
|
+
<div class="flex flex-col text-sm gap-y-4 my-4">
|
|
171
|
+
${this.qna()} ${this.telephone()} ${this.whatsapp()} ${this.email()}
|
|
172
|
+
${this.workingHour()}
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
`
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { LitElement, html, css } from 'lit'
|
|
2
|
+
import { customElement, state, property } from 'lit/decorators.js'
|
|
3
|
+
import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
|
|
4
|
+
import { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'
|
|
5
|
+
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
6
|
+
|
|
7
|
+
@customElement('kompasid-header-account-menu')
|
|
8
|
+
export class KompasHeaderAccountMenu extends LitElement {
|
|
9
|
+
static styles = [
|
|
10
|
+
css`
|
|
11
|
+
:host {
|
|
12
|
+
font-family: 'PT Sans', sans-serif;
|
|
13
|
+
}
|
|
14
|
+
.header-account-menu--item {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: row;
|
|
17
|
+
align-items: center;
|
|
18
|
+
padding: 0.75rem;
|
|
19
|
+
transition: background-color 0.3s ease-in-out;
|
|
20
|
+
border-radius: 0.25rem;
|
|
21
|
+
}
|
|
22
|
+
.header-account-menu--item:hover {
|
|
23
|
+
background-color: #e5e7eb; /* Assuming grey-200 */
|
|
24
|
+
}
|
|
25
|
+
.header-account-menu--title {
|
|
26
|
+
flex-grow: 1;
|
|
27
|
+
font-size: 1rem;
|
|
28
|
+
font-weight: bold;
|
|
29
|
+
margin-left: 1rem;
|
|
30
|
+
}
|
|
31
|
+
.header-account-menu--notification-info {
|
|
32
|
+
font-size: 0.875rem;
|
|
33
|
+
border-radius: 1.5rem;
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
background-color: rgb(255, 122, 0);
|
|
38
|
+
color: #f7fafc;
|
|
39
|
+
height: 1.75rem;
|
|
40
|
+
width: 1.75rem;
|
|
41
|
+
}
|
|
42
|
+
.icon {
|
|
43
|
+
width: 20px;
|
|
44
|
+
height: 20px;
|
|
45
|
+
margin-top: auto;
|
|
46
|
+
margin-bottom: auto;
|
|
47
|
+
color: rgb(0 85 154);
|
|
48
|
+
}
|
|
49
|
+
`,
|
|
50
|
+
TWStyles,
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
kompasKring?: HTMLInputElement
|
|
54
|
+
|
|
55
|
+
@state() clipboardClicked: boolean = false
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Cart Url
|
|
59
|
+
*/
|
|
60
|
+
@property({ type: String }) cartUrl = 'https://gerai.kompas.id/cart'
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Logout Url
|
|
64
|
+
*/
|
|
65
|
+
@property({ type: String }) logoutUrl = 'https://account.kompas.id/logout'
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Manage Account Url
|
|
69
|
+
*/
|
|
70
|
+
@property({ type: String }) manageAccountUrl =
|
|
71
|
+
'https://account.kompas.id/manage-account/my-account'
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Notification Url
|
|
75
|
+
*/
|
|
76
|
+
@property({ type: String }) notificationUrl =
|
|
77
|
+
'https://account.kompas.id/manage-account/notification'
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Orders Url
|
|
81
|
+
*/
|
|
82
|
+
@property({ type: String }) ordersUrl =
|
|
83
|
+
'https://gerai.kompas.id/my-account/orders'
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Read Later Url
|
|
87
|
+
*/
|
|
88
|
+
@property({ type: String }) readLaterUrl = 'https://www.kompas.id/baca-nanti'
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Total Notification Count
|
|
92
|
+
*/
|
|
93
|
+
@property({ type: Number }) notificationTotal: number = 0
|
|
94
|
+
|
|
95
|
+
// Render Total Bubble
|
|
96
|
+
private renderTotalBubble = (total: number) => {
|
|
97
|
+
if (!total) {
|
|
98
|
+
return html``
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isOneDigitNotification = total > 0 && total <= 9
|
|
102
|
+
const additionalStyling = isOneDigitNotification ? '' : 'pl-0.5'
|
|
103
|
+
|
|
104
|
+
return html`
|
|
105
|
+
<div
|
|
106
|
+
class=${`header-account-menu--notification-info ${additionalStyling}`}
|
|
107
|
+
>
|
|
108
|
+
<!-- Limit Display to use "9+"" if total notification exceed 9 -->
|
|
109
|
+
${isOneDigitNotification
|
|
110
|
+
? total
|
|
111
|
+
: html`<span>9<span class="pl-px">+</span></span>`}
|
|
112
|
+
</div>
|
|
113
|
+
`
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
override async connectedCallback() {
|
|
117
|
+
super.connectedCallback()
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
render() {
|
|
121
|
+
return html`
|
|
122
|
+
<div class="border-b border-grey-300 text-grey-600">
|
|
123
|
+
<li
|
|
124
|
+
class="font-bold flex flex-shrink-0 flex-col text-left text-sm mb-4"
|
|
125
|
+
>
|
|
126
|
+
<!-- Cart -->
|
|
127
|
+
<!--<a href={this.cartUrl} class="header-account-menu--item">
|
|
128
|
+
<div class="icon icon-md icon-blue-600">{unsafeSVG(getFontAwesomeIcon('fas', 'cart-shopping'))}</div>
|
|
129
|
+
<p class="header-account-menu--title">Keranjang</p>
|
|
130
|
+
</a> -->
|
|
131
|
+
<!-- Manage Account -->
|
|
132
|
+
<a href=${this.manageAccountUrl} class="header-account-menu--item">
|
|
133
|
+
<div class="icon icon-md icon-blue-600">
|
|
134
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'user-gear'))}
|
|
135
|
+
</div>
|
|
136
|
+
<p class="header-account-menu--title">Kelola Akun</p>
|
|
137
|
+
</a>
|
|
138
|
+
<!-- Transaction -->
|
|
139
|
+
<!-- <a href={this.ordersUrl} class="header-account-menu--item">
|
|
140
|
+
<div class="icon icon-md icon-blue-600">{unsafeSVG(getFontAwesomeIcon('fas', 'arrow-right-arrow-left'))}</div>
|
|
141
|
+
<p class="header-account-menu--title">Transaksi</p>
|
|
142
|
+
</a> -->
|
|
143
|
+
<!-- Notifications -->
|
|
144
|
+
<a href=${this.notificationUrl} class="header-account-menu--item">
|
|
145
|
+
<div class="icon icon-md icon-blue-600">
|
|
146
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'bell'))}
|
|
147
|
+
</div>
|
|
148
|
+
<p class="header-account-menu--title">Notifikasi</p>
|
|
149
|
+
<p class="flex-none">
|
|
150
|
+
<!-- Conditional rendering based on notification count -->
|
|
151
|
+
${this.renderTotalBubble(this.notificationTotal)}
|
|
152
|
+
</p>
|
|
153
|
+
</a>
|
|
154
|
+
<!-- Read Later -->
|
|
155
|
+
<a href=${this.readLaterUrl} class="header-account-menu--item">
|
|
156
|
+
<div class="icon icon-md icon-blue-600">
|
|
157
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'bookmark'))}
|
|
158
|
+
</div>
|
|
159
|
+
<p class="header-account-menu--title">Baca Nanti</p>
|
|
160
|
+
</a>
|
|
161
|
+
<!-- Logout -->
|
|
162
|
+
<a href=${this.logoutUrl} class="header-account-menu--item">
|
|
163
|
+
<div class="icon icon-md icon-blue-600">
|
|
164
|
+
${unsafeSVG(getFontAwesomeIcon('fas', 'right-from-bracket'))}
|
|
165
|
+
</div>
|
|
166
|
+
<p class="header-account-menu--title">Keluar</p>
|
|
167
|
+
</a>
|
|
168
|
+
</li>
|
|
169
|
+
</div>
|
|
170
|
+
`
|
|
171
|
+
}
|
|
172
|
+
}
|