UNPKG

@spectrumsense/spectrum-chat-dev

Version:

Embeddable AI Widget - Add trusted, evidence-based answers directly to your website. Simple installation, enterprise-grade security.

231 lines (206 loc) 7.52 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Plain HTML Example - Spectrum Chat</title> <!-- Include the Spectrum Chat script --> <script src="../../dist/spectrum-chat.js"></script> <style> body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 0; padding: 2rem; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; color: white; } .container { max-width: 1200px; margin: 0 auto; } h1 { font-size: 2.5rem; font-weight: 700; margin-bottom: 1rem; text-align: center; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); } .demo-section { background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(10px); border-radius: 1rem; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); } .demo-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 1rem; } .demo-description { opacity: 0.9; margin-bottom: 1.5rem; line-height: 1.6; } .success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; padding: 1.5rem; border-radius: 0.75rem; margin: 1.5rem 0; text-align: center; } .success h4 { font-size: 1.25rem; margin-bottom: 0.5rem; } .button { background: rgba(255, 255, 255, 0.2); color: white; border: 1px solid rgba(255, 255, 255, 0.3); padding: 0.75rem 1.5rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.9rem; margin: 0.25rem; text-decoration: none; display: inline-block; transition: all 0.3s ease; backdrop-filter: blur(10px); } .button:hover { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); } .button-container { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; justify-content: center; } .code-block { background: rgba(0, 0, 0, 0.3); border-radius: 0.5rem; padding: 1rem; margin: 1rem 0; font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace; font-size: 0.9rem; overflow-x: auto; border: 1px solid rgba(255, 255, 255, 0.2); } </style> </head> <body> <div class="container"> <h1>🚀 Plain HTML Example</h1> <div class="success"> <h4>🎉 Custom Element Implementation!</h4> <p>This demonstrates how customers would implement the chat widget on individual HTML pages using the custom element approach.</p> </div> <div class="demo-section"> <h2 class="demo-title">✨ Custom Element Usage</h2> <p class="demo-description"> For plain HTML pages, customers need to add the chat widget to each page individually. This uses the custom element approach with the &lt;spectrum-chat&gt; tag. </p> <div class="code-block"> &lt;!-- Include the script once per page --&gt; &lt;script src="dist/spectrum-chat.js"&gt;&lt;/script&gt; &lt;!-- Add the chat widget with configuration --&gt; &lt;spectrum-chat api-url="http://localhost:8001/api/v1/conversations" tenant-id="your-tenant-id" title="AI Assistant" intro-text="Hello! How can I help you today?" primary-color="hsl(220 15% 25%)" user-color="hsl(220 15% 45%)" ai-color="hsl(220 15% 25%)" position="bottom-right" width="320px" height="350px" show-intro="true" citations="false" &gt;&lt;/spectrum-chat&gt; </div> <div class="success"> <h4>🎉 Success Criteria</h4> <ul> <li>Chat widget appears in bottom-right corner</li> <li>Customizable via HTML attributes</li> <li>Works on individual pages</li> <li>No global configuration needed</li> <li>Easy to integrate per page</li> </ul> </div> <div class="button-container"> <button class="button" onclick="document.querySelector('spectrum-chat').open()">Open Chat</button> <button class="button" onclick="document.querySelector('spectrum-chat').close()">Close Chat</button> <button class="button" onclick="alert('Chat is ' + (document.querySelector('spectrum-chat').isChatOpen() ? 'open' : 'closed'))">Check Status</button> </div> </div> <div class="demo-section"> <h2 class="demo-title">🔧 Configuration Options</h2> <p class="demo-description"> The custom element supports many configuration options via HTML attributes. All attributes are optional and have sensible defaults. </p> <div class="code-block"> &lt;spectrum-chat api-url="http://localhost:8001/api/v1/conversations" <!-- API endpoint --> tenant-id="your-tenant-id" <!-- Tenant identifier --> title="AI Assistant" <!-- Chat title --> intro-text="Hello! How can I help?" <!-- Intro message --> primary-color="hsl(220 15% 25%)" <!-- Primary color --> user-color="hsl(220 15% 45%)" <!-- User message color --> ai-color="hsl(220 15% 25%)" <!-- AI message color --> position="bottom-right" <!-- Position: bottom-right, bottom-left, top-right, top-left --> width="320px" <!-- Chat width --> height="350px" <!-- Chat height --> show-intro="true" <!-- Show intro message --> citations="false" <!-- Enable citations --> max-messages="100" <!-- Max messages to store --> browser-storage="true" <!-- Enable browser storage --> fab-icon="✦" <!-- FAB icon --> fab-color="hsl(220 15% 25%)" <!-- FAB color --> panel-border-radius="1rem" <!-- Panel border radius --> panel-shadow="0 8px 32px -8px rgba(0,0,0,0.2)" <!-- Panel shadow --> &gt;&lt;/spectrum-chat&gt; </div> </div> </div> <!-- The actual chat widget --> <spectrum-chat api-url="http://localhost:8001/api/v1/conversations" tenant-id="brightspectrum-tenant-123" title="Bright Spectrum AI Assistant" intro-text="I am Bright Spectrum AI Assistant. I can answer questions about our programs, costs, and services." primary-color="hsl(145 73% 35%)" user-color="hsl(195 82% 45%)" ai-color="hsl(145 73% 35%)" position="bottom-right" width="320px" height="350px" show-intro="true" citations="false" debug="true" ></spectrum-chat> <script> console.log('Plain HTML example loaded'); console.log('Spectrum Chat custom element available:', !!customElements.get('spectrum-chat')); // Log when the page loads setTimeout(() => { const chatElement = document.querySelector('spectrum-chat'); if (chatElement) { console.log('✅ SUCCESS: Chat element found and ready'); console.log('Chat configuration:', chatElement.getConfig()); } else { console.log('❌ ERROR: Chat element not found'); } }, 1000); </script> </body> </html>