File size: 1,955 Bytes
c00d809
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomSearchBar extends HTMLElement {
  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `
      <style>
        :host {
          display: block;
        }
        
        .search-container {
          position: relative;
          max-width: 600px;
          margin: 0 auto;
        }
        
        .search-input {
          width: 100%;
          padding: 1rem 1rem 1rem 3rem;
          border-radius: 50px;
          border: 1px solid #e5e7eb;
          background: #fff;
          font-size: 1rem;
          transition: all 0.3s;
          box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        }
        
        .dark .search-input {
          background: #1f2937;
          border: 1px solid #374151;
          color: #f9fafb;
        }
        
        .search-input:focus {
          outline: none;
          border-color: #6366f1;
          box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
        }
        
        .search-icon {
          position: absolute;
          left: 1rem;
          top: 50%;
          transform: translateY(-50%);
          color: #9ca3af;
        }
        
        .dark .search-icon {
          color: #6b7280;
        }
      </style>
      <div class="search-container">
        <i data-feather="search" class="search-icon w-5 h-5"></i>
        <input type="text" class="search-input" placeholder="Search prompts or tags..." id="searchInput">
      </div>
    `;
    
    // Add event listener after rendering
    setTimeout(() => {
      const searchInput = this.shadowRoot.getElementById('searchInput');
      searchInput.addEventListener('input', (e) => {
        // Access the global search function
        if (typeof searchPrompts === 'function') {
          searchPrompts(e.target.value);
        }
      });
      
      // Initialize feather icons
      feather.replace();
    }, 0);
  }
}

customElements.define('custom-search-bar', CustomSearchBar);