import '@gameon/on-ui-components/base/badge';
import '@gameon/on-ui-components/chat/notification';
import { Message, Speaker } from '@gameon/on-ui-components/types';
import { ContextConsumer } from '@lit-labs/context';
import { css, html, LitElement, nothing } from 'lit';
import { customElement, property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { notificationsContext } from './notifications.context';
@customElement('on-chat-bot-notifications')
export class OnChatBotNotifications extends LitElement {
static override styles = css`
:host {
--on-chat-notification-background-color: #ffffff;
bottom: calc(var(--on-chat-widget-bottom, 1rem) + 80px + 8px);
position: fixed;
right: var(--on-chat-widget-right, 1rem);
z-index: var(--on-chat-widget-z-index, 999999);
}
.on-chat-notifications {
display: flex;
flex-direction: column;
gap: 8px;
opacity: 0.5;
align-items: flex-end;
}
.close-badge {
cursor: pointer;
}
.close-badge.hide {
display: none;
}
.close-badge.show {
display: unset;
}
.active {
opacity: unset;
}
`;
@property({ type: Object })
speaker?: Speaker;
@state()
private active = false;
private lastSeenMessage = new ContextConsumer(
this,
notificationsContext,
undefined,
true
);
private onMouseOver() {
if (!this.active) {
this.active = true;
}
}
private onMouseOut() {
if (this.active) {
this.active = false;
}
}
private renderCloseBadge() {
const handleBadgeDeleted = () => {
this.active = false;
this.dispatchEvent(new CustomEvent('on-notification-reset'));
};
return html`