File size: 4,685 Bytes
20fda5d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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 }
                }));
            });
        });

        // Hide examples after first user message
        document.addEventListener('claude-user-message-sent', () => {
            const container = this.shadowRoot.getElementById('examplesContainer');
            container.classList.add('hidden');
        });

        // Show examples when starting new chat
        document.addEventListener('claude-new-chat', () => {
            const container = this.shadowRoot.getElementById('examplesContainer');
            container.classList.remove('hidden');
        });
    }
}

customElements.define('claude-examples', ClaudeExamples);