|
|
class ClaudeExamples extends HTMLElement { |
|
|
constructor() { |
|
|
super(); |
|
|
} |
|
|
|
|
|
connectedCallback() { |
|
|
this.attachShadow({ mode: 'open' }); |
|
|
this.render(); |
|
|
this.setupEventListeners(); |
|
|
} |
|
|
|
|
|
render() { |
|
|
this.shadowRoot.innerHTML = ` |
|
|
<style> |
|
|
.examples-container { |
|
|
max-width: 1200px; |
|
|
margin: 0 auto; |
|
|
padding: 2rem 1.5rem 1rem; |
|
|
transition: all 0.3s ease; |
|
|
} |
|
|
|
|
|
.examples-container.hidden { |
|
|
opacity: 0; |
|
|
height: 0; |
|
|
padding: 0; |
|
|
overflow: hidden; |
|
|
} |
|
|
|
|
|
.examples-title { |
|
|
font-size: 1.125rem; |
|
|
font-weight: 600; |
|
|
color: #1e293b; |
|
|
margin-bottom: 1rem; |
|
|
} |
|
|
|
|
|
.examples-grid { |
|
|
display: grid; |
|
|
grid-template-columns: repeat(4, 1fr); |
|
|
gap: 1rem; |
|
|
} |
|
|
|
|
|
.example-button { |
|
|
padding: 1rem; |
|
|
background: white; |
|
|
border: 1px solid #e2e8f0; |
|
|
border-radius: 0.75rem; |
|
|
text-align: left; |
|
|
cursor: pointer; |
|
|
transition: all 0.2s; |
|
|
font-size: 0.875rem; |
|
|
color: #475569; |
|
|
} |
|
|
|
|
|
.example-button:hover { |
|
|
border-color: var(--primary-blue); |
|
|
background: #f8fafc; |
|
|
transform: translateY(-2px); |
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05); |
|
|
} |
|
|
|
|
|
@media (max-width: 1023px) and (min-width: 768px) { |
|
|
.examples-grid { |
|
|
grid-template-columns: repeat(2, 1fr); |
|
|
} |
|
|
} |
|
|
|
|
|
@media (max-width: 767px) { |
|
|
.examples-container { |
|
|
padding: 1.5rem 1rem 0.5rem; |
|
|
} |
|
|
|
|
|
.examples-grid { |
|
|
grid-template-columns: 1fr; |
|
|
gap: 0.75rem; |
|
|
} |
|
|
|
|
|
.example-button { |
|
|
width: 100%; |
|
|
} |
|
|
} |
|
|
</style> |
|
|
|
|
|
<div class="examples-container" id="examplesContainer"> |
|
|
<div class="examples-title">Try these examples:</div> |
|
|
<div class="examples-grid" id="examplesGrid"> |
|
|
<button class="example-button" data-prompt="Explain quantum computing in simple terms"> |
|
|
Explain quantum computing in simple terms |
|
|
</button> |
|
|
<button class="example-button" data-prompt="Write a detailed essay on AI impact"> |
|
|
Write a detailed essay on AI impact |
|
|
</button> |
|
|
<button class="example-button" data-prompt="Write a short poem about coding"> |
|
|
Write a short poem about coding |
|
|
</button> |
|
|
<button class="example-button" data-prompt="Generate a JavaScript function to sort an array"> |
|
|
Generate a JavaScript function to sort an array |
|
|
</button> |
|
|
</div> |
|
|
</div> |
|
|
`; |
|
|
} |
|
|
|
|
|
setupEventListeners() { |
|
|
const exampleButtons = this.shadowRoot.querySelectorAll('.example-button'); |
|
|
|
|
|
exampleButtons.forEach(button => { |
|
|
button.addEventListener('click', () => { |
|
|
const prompt = button.dataset.prompt; |
|
|
document.dispatchEvent(new CustomEvent('claude-fill-input', { |
|
|
detail: { prompt } |
|
|
})); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('claude-user-message-sent', () => { |
|
|
const container = this.shadowRoot.getElementById('examplesContainer'); |
|
|
container.classList.add('hidden'); |
|
|
}); |
|
|
|
|
|
|
|
|
document.addEventListener('claude-new-chat', () => { |
|
|
const container = this.shadowRoot.getElementById('examplesContainer'); |
|
|
container.classList.remove('hidden'); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
customElements.define('claude-examples', ClaudeExamples); |