Spaces:
Running
Running
Download components/chat-bubble.js from raysite/deepsite-companion: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/raysite/deepsite-companion/resolve/main/components/chat-bubble.js
- Command line
-
hf download hf://spaces/raysite/deepsite-companion/components/chat-bubble.js
-
curl -L -o chat-bubble.js https://huggingface.co/spaces/raysite/deepsite-companion/resolve/main/components/chat-bubble.js
1.22 kB
| class ChatBubble extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| const type = this.getAttribute('type') || 'received'; | |
| const timestamp = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| .chat-bubble { | |
| max-width: 80%; | |
| padding: 0.75rem 1rem; | |
| border-radius: 1rem; | |
| margin-bottom: 0.5rem; | |
| position: relative; | |
| word-wrap: break-word; | |
| } | |
| .received { | |
| background-color: #374151; | |
| color: white; | |
| align-self: flex-start; | |
| border-bottom-left-radius: 0.25rem; | |
| } | |
| .sent { | |
| background-color: #0ea5e9; | |
| color: white; | |
| align-self: flex-end; | |
| border-bottom-right-radius: 0.25rem; | |
| } | |
| .timestamp { | |
| font-size: 0.75rem; | |
| color: #9ca3af; | |
| margin-top: 0.25rem; | |
| text-align: right; | |
| } | |
| </style> | |
| <div class="chat-bubble ${type}"> | |
| <slot></slot> | |
| <div class="timestamp">${timestamp}</div> | |
| </div> | |
| `; | |
| } | |
| } | |
| customElements.define('chat-bubble', ChatBubble); |