2025-07-14 14:54:54 +00:00
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
property,
|
|
|
|
|
html,
|
|
|
|
|
customElement,
|
|
|
|
|
type TemplateResult,
|
|
|
|
|
cssManager,
|
|
|
|
|
css,
|
|
|
|
|
unsafeCSS,
|
|
|
|
|
state,
|
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
|
|
// Import design tokens
|
|
|
|
|
import { colors, bdTheme } from './00colors.js';
|
|
|
|
|
import { spacing, radius, shadows, transitions } from './00tokens.js';
|
|
|
|
|
import { fontFamilies, typography } from './00fonts.js';
|
|
|
|
|
|
|
|
|
|
// Types
|
|
|
|
|
export interface IConversation {
|
|
|
|
|
id: string;
|
|
|
|
|
title: string;
|
|
|
|
|
lastMessage: string;
|
|
|
|
|
time: string;
|
|
|
|
|
unread?: boolean;
|
|
|
|
|
avatar?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
declare global {
|
|
|
|
|
interface HTMLElementTagNameMap {
|
|
|
|
|
'sio-conversation-selector': SioConversationSelector;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@customElement('sio-conversation-selector')
|
|
|
|
|
export class SioConversationSelector extends DeesElement {
|
|
|
|
|
public static demo = () => html`
|
|
|
|
|
<sio-conversation-selector style="width: 320px; height: 600px;"></sio-conversation-selector>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
@property({ type: Array })
|
2025-12-08 23:03:02 +00:00
|
|
|
public accessor conversations: IConversation[] = [];
|
2025-07-14 14:54:54 +00:00
|
|
|
|
|
|
|
|
@property({ type: String })
|
2025-12-08 23:03:02 +00:00
|
|
|
public accessor selectedConversationId: string | null = null;
|
2025-07-14 14:54:54 +00:00
|
|
|
|
|
|
|
|
@state()
|
2025-12-08 23:03:02 +00:00
|
|
|
private accessor searchQuery: string = '';
|
2025-07-14 14:54:54 +00:00
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
css`
|
|
|
|
|
:host {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: ${bdTheme('card')};
|
|
|
|
|
border-right: 1px solid ${bdTheme('border')};
|
|
|
|
|
font-family: ${unsafeCSS(fontFamilies.sans)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header {
|
2025-07-14 15:07:39 +00:00
|
|
|
padding: ${unsafeCSS(spacing["5"])} ${unsafeCSS(spacing["4"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
border-bottom: 1px solid ${bdTheme('border')};
|
2025-07-14 15:07:39 +00:00
|
|
|
background: ${bdTheme('background')};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
2025-07-14 18:26:14 +00:00
|
|
|
.header-top {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-bottom: ${unsafeCSS(spacing["4"])};
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-14 14:54:54 +00:00
|
|
|
.title {
|
2025-07-14 15:07:39 +00:00
|
|
|
font-size: 1.25rem;
|
|
|
|
|
line-height: 1.2;
|
2025-07-14 14:54:54 +00:00
|
|
|
font-weight: 600;
|
2025-07-14 18:26:14 +00:00
|
|
|
margin: 0;
|
2025-07-14 14:54:54 +00:00
|
|
|
color: ${bdTheme('foreground')};
|
2025-07-14 15:07:39 +00:00
|
|
|
letter-spacing: -0.025em;
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-box {
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
|
width: 100%;
|
2025-07-14 15:07:39 +00:00
|
|
|
padding: ${unsafeCSS(spacing["2.5"])} ${unsafeCSS(spacing["10"])} ${unsafeCSS(spacing["2.5"])} ${unsafeCSS(spacing["3"])};
|
|
|
|
|
background: ${bdTheme('background')};
|
2025-07-14 14:54:54 +00:00
|
|
|
border: 1px solid ${bdTheme('border')};
|
2025-07-14 15:07:39 +00:00
|
|
|
border-radius: ${unsafeCSS(radius.lg)};
|
|
|
|
|
font-size: 0.875rem;
|
2025-07-14 14:54:54 +00:00
|
|
|
color: ${bdTheme('foreground')};
|
|
|
|
|
outline: none;
|
|
|
|
|
transition: ${unsafeCSS(transitions.all)};
|
|
|
|
|
font-family: ${unsafeCSS(fontFamilies.sans)};
|
2025-07-14 15:07:39 +00:00
|
|
|
box-shadow: ${unsafeCSS(shadows.sm)};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input::placeholder {
|
|
|
|
|
color: ${bdTheme('mutedForeground')};
|
2025-07-14 15:07:39 +00:00
|
|
|
font-weight: 400;
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input:focus {
|
|
|
|
|
border-color: ${bdTheme('ring')};
|
2025-07-14 15:07:39 +00:00
|
|
|
box-shadow: 0 0 0 3px ${bdTheme('ring')}20;
|
|
|
|
|
background: ${bdTheme('background')};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-icon {
|
|
|
|
|
position: absolute;
|
2025-07-14 15:07:39 +00:00
|
|
|
right: ${unsafeCSS(spacing["3"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
top: 50%;
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
color: ${bdTheme('mutedForeground')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-list {
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow-y: auto;
|
2025-07-14 15:07:39 +00:00
|
|
|
padding: ${unsafeCSS(spacing["2"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-item {
|
2025-07-14 15:07:39 +00:00
|
|
|
padding: ${unsafeCSS(spacing["3.5"])};
|
|
|
|
|
margin-bottom: ${unsafeCSS(spacing["1.5"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
background: ${bdTheme('background')};
|
2025-07-14 15:07:39 +00:00
|
|
|
border: 1px solid transparent;
|
|
|
|
|
border-radius: ${unsafeCSS(radius.lg)};
|
2025-07-14 14:54:54 +00:00
|
|
|
cursor: pointer;
|
|
|
|
|
transition: ${unsafeCSS(transitions.all)};
|
2025-07-14 15:07:39 +00:00
|
|
|
position: relative;
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-item:hover {
|
|
|
|
|
background: ${bdTheme('accent')};
|
2025-07-14 15:07:39 +00:00
|
|
|
transform: translateX(2px);
|
|
|
|
|
box-shadow: ${unsafeCSS(shadows.sm)};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-item.selected {
|
|
|
|
|
background: ${bdTheme('accent')};
|
2025-07-14 15:07:39 +00:00
|
|
|
border-color: ${bdTheme('border')};
|
|
|
|
|
box-shadow: ${unsafeCSS(shadows.sm)};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-item.selected::before {
|
|
|
|
|
content: '';
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0;
|
|
|
|
|
top: 50%;
|
|
|
|
|
transform: translateY(-50%);
|
|
|
|
|
width: 3px;
|
|
|
|
|
height: 60%;
|
|
|
|
|
background: ${bdTheme('primary')};
|
|
|
|
|
border-radius: 0 3px 3px 0;
|
|
|
|
|
animation: slideIn 200ms ease-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes slideIn {
|
|
|
|
|
from {
|
|
|
|
|
width: 0;
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
to {
|
|
|
|
|
width: 3px;
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
2025-07-14 15:07:39 +00:00
|
|
|
margin-bottom: ${unsafeCSS(spacing["1"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-title {
|
2025-07-14 15:07:39 +00:00
|
|
|
font-weight: 500;
|
2025-07-14 14:54:54 +00:00
|
|
|
color: ${bdTheme('foreground')};
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2025-07-14 15:07:39 +00:00
|
|
|
gap: ${unsafeCSS(spacing["2"])};
|
|
|
|
|
font-size: 0.9375rem;
|
|
|
|
|
letter-spacing: -0.01em;
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-time {
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
line-height: 1.5;
|
|
|
|
|
color: ${bdTheme('mutedForeground')};
|
2025-07-14 15:07:39 +00:00
|
|
|
opacity: 0.8;
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-preview {
|
2025-07-14 15:07:39 +00:00
|
|
|
font-size: 0.8125rem;
|
2025-07-14 14:54:54 +00:00
|
|
|
line-height: 1.5;
|
|
|
|
|
color: ${bdTheme('mutedForeground')};
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
2025-07-14 15:07:39 +00:00
|
|
|
margin-top: ${unsafeCSS(spacing["0.5"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.unread-dot {
|
|
|
|
|
display: inline-block;
|
2025-07-14 15:07:39 +00:00
|
|
|
width: 6px;
|
|
|
|
|
height: 6px;
|
2025-07-14 14:54:54 +00:00
|
|
|
background: ${bdTheme('primary')};
|
|
|
|
|
border-radius: 50%;
|
2025-07-14 15:07:39 +00:00
|
|
|
animation: pulse 2s ease-in-out infinite;
|
|
|
|
|
box-shadow: 0 0 0 0 ${bdTheme('primary')};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes pulse {
|
|
|
|
|
0% {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
transform: scale(1);
|
|
|
|
|
box-shadow: 0 0 0 0 ${bdTheme('primary')}40;
|
|
|
|
|
}
|
|
|
|
|
50% {
|
|
|
|
|
opacity: 0.9;
|
|
|
|
|
transform: scale(1.05);
|
|
|
|
|
box-shadow: 0 0 0 4px ${bdTheme('primary')}00;
|
|
|
|
|
}
|
|
|
|
|
100% {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
transform: scale(1);
|
|
|
|
|
box-shadow: 0 0 0 0 ${bdTheme('primary')}00;
|
|
|
|
|
}
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.empty-state {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
height: 100%;
|
2025-07-14 15:07:39 +00:00
|
|
|
padding: ${unsafeCSS(spacing["4"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
text-align: center;
|
|
|
|
|
color: ${bdTheme('mutedForeground')};
|
2025-07-14 15:07:39 +00:00
|
|
|
gap: ${unsafeCSS(spacing["3"])};
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.empty-icon {
|
|
|
|
|
font-size: 48px;
|
|
|
|
|
opacity: 0.5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Scrollbar styling */
|
|
|
|
|
.conversation-list::-webkit-scrollbar {
|
|
|
|
|
width: 6px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-list::-webkit-scrollbar-track {
|
|
|
|
|
background: transparent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-list::-webkit-scrollbar-thumb {
|
|
|
|
|
background: ${bdTheme('border')};
|
|
|
|
|
border-radius: 3px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-list::-webkit-scrollbar-thumb:hover {
|
|
|
|
|
background: ${bdTheme('mutedForeground')};
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
const filteredConversations = this.conversations.filter(conv =>
|
|
|
|
|
conv.title.toLowerCase().includes(this.searchQuery.toLowerCase()) ||
|
|
|
|
|
conv.lastMessage.toLowerCase().includes(this.searchQuery.toLowerCase())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div class="header">
|
2025-07-14 18:26:14 +00:00
|
|
|
<div class="header-top">
|
|
|
|
|
<h2 class="title">Messages</h2>
|
|
|
|
|
<sio-button
|
|
|
|
|
type="primary"
|
|
|
|
|
size="sm"
|
|
|
|
|
@click=${() => this.startNewConversation()}
|
|
|
|
|
>
|
|
|
|
|
<sio-icon icon="plus" size="16"></sio-icon>
|
|
|
|
|
New
|
|
|
|
|
</sio-button>
|
|
|
|
|
</div>
|
2025-07-14 14:54:54 +00:00
|
|
|
<div class="search-box">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
class="search-input"
|
|
|
|
|
placeholder="Search conversations..."
|
|
|
|
|
.value=${this.searchQuery}
|
|
|
|
|
@input=${(e: Event) => this.searchQuery = (e.target as HTMLInputElement).value}
|
|
|
|
|
/>
|
|
|
|
|
<sio-icon class="search-icon" icon="search" size="16"></sio-icon>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
${filteredConversations.length > 0 ? html`
|
|
|
|
|
<div class="conversation-list">
|
|
|
|
|
${filteredConversations.map(conv => html`
|
|
|
|
|
<div
|
|
|
|
|
class="conversation-item ${this.selectedConversationId === conv.id ? 'selected' : ''}"
|
|
|
|
|
@click=${() => this.selectConversation(conv)}
|
|
|
|
|
>
|
|
|
|
|
<div class="conversation-header">
|
|
|
|
|
<span class="conversation-title">
|
|
|
|
|
${conv.title}
|
|
|
|
|
${conv.unread ? html`<span class="unread-dot"></span>` : ''}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="conversation-time">${conv.time}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="conversation-preview">${conv.lastMessage}</div>
|
|
|
|
|
</div>
|
|
|
|
|
`)}
|
|
|
|
|
</div>
|
|
|
|
|
` : html`
|
|
|
|
|
<div class="empty-state">
|
|
|
|
|
<sio-icon class="empty-icon" icon="message-square"></sio-icon>
|
|
|
|
|
<h3>${this.searchQuery ? 'No matching conversations' : 'No conversations yet'}</h3>
|
|
|
|
|
<p>${this.searchQuery ? 'Try a different search term' : 'Start a new conversation to get started'}</p>
|
|
|
|
|
</div>
|
|
|
|
|
`}
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private selectConversation(conversation: IConversation) {
|
|
|
|
|
this.selectedConversationId = conversation.id;
|
|
|
|
|
|
|
|
|
|
// Dispatch event for parent components
|
|
|
|
|
this.dispatchEvent(new CustomEvent('conversation-selected', {
|
|
|
|
|
detail: { conversation },
|
|
|
|
|
bubbles: true,
|
|
|
|
|
composed: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
2025-07-14 18:26:14 +00:00
|
|
|
|
|
|
|
|
private startNewConversation() {
|
|
|
|
|
// Dispatch event for parent components to handle new conversation creation
|
|
|
|
|
this.dispatchEvent(new CustomEvent('new-conversation', {
|
|
|
|
|
bubbles: true,
|
|
|
|
|
composed: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
2025-07-14 14:54:54 +00:00
|
|
|
}
|