@spectrumsense/spectrum-chat-dev
Version:
Embeddable AI Widget - Add trusted, evidence-based answers directly to your website. Simple installation, enterprise-grade security.
231 lines (201 loc) • 7.63 kB
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 <spectrum-chat> tag.
</p>
<div class="code-block">
<!-- Include the script once per page -->
<script src="dist/spectrum-chat.js"></script>
<!-- Minimal usage - uses built-in defaults -->
<spectrum-chat></spectrum-chat>
<!-- Or with custom configuration -->
<spectrum-chat
api-url="http://localhost:8000/api/v1/conversations"
tenant-id="your-tenant-id"
title="AI Assistant"
debug="true"
></spectrum-chat>
</div>
<div class="success">
<h4>🎉 Success Criteria</h4>
<ul>
<li>Chat widget appears in bottom-right corner</li>
<li>Uses built-in defaults (320px × 350px)</li>
<li>Customizable via HTML attributes (optional)</li>
<li>Works on individual pages</li>
<li>No JavaScript configuration needed</li>
<li>Single-line installation possible</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">
<spectrum-chat
api-url="http://localhost:8000/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 -->
></spectrum-chat>
</div>
</div>
</div>
<!-- The actual chat widget - uses built-in defaults -->
<spectrum-chat
api-url="http://localhost:8000/api/v1/conversations"
tenant-id="test-tenant"
title="Plain HTML Example Chat"
debug="true">
</spectrum-chat>
<script>
console.log('Plain HTML example loaded');
console.log('Spectrum Chat custom element available:', !!customElements.get('spectrum-chat'));
// Wait for everything to load and test the widget
setTimeout(() => {
console.log('=== TESTING CHAT WIDGET ===');
const chatElement = document.querySelector('spectrum-chat');
console.log('Chat element:', chatElement);
if (chatElement && chatElement.shadowRoot) {
const fab = chatElement.shadowRoot.querySelector('.spectrum-chat-fab');
console.log('FAB element:', fab);
if (fab) {
console.log('✅ Chat widget loaded successfully with built-in defaults');
console.log('Widget configuration:', chatElement.getConfig());
} else {
console.error('❌ FAB element not found!');
}
} else {
console.error('❌ Chat element or shadow root not found!');
}
console.log('=== PLAIN HTML EXAMPLE READY ===');
}, 2000);
</script>
</body>
</html>